describe ReportsController do subject { last_response } describe :create do let(:payload) { { :serial => serial, :version => "1.0.0" } } before { post reports_path, payload.to_json } context "with present serial" do let(:serial) { "123abc" } it { should be_ok } its(:status) { should eq 200 } end context "with missing serial" do let(:serial) { nil } it { should_not be_ok } its(:status) { should eq 400 } end end end