lib/napa/rspec_extensions/response_helpers.rb in napa-0.3.0 vs lib/napa/rspec_extensions/response_helpers.rb in napa-0.4.0

- old
+ new

@@ -10,8 +10,37 @@ end def response_body last_response.body end + + def result_count + parsed_response.data.count + end + + def first_result + parsed_response.data.first + end + + def result_with_id(id) + parsed_response.data.select { |r| r.id == id }.first + end + + def expect_count_of(count) + expect(result_count).to eq(count) + end + + def expect_only(object) + expect_count_of 1 + expect(first_result.id).to eq(object.id) + end + + def expect_to_have(object) + expect(!!result_with_id(object.id)).to be_truthy + end + + def expect_to_not_have(object) + expect(!!result_with_id(object.id)).to be_falsy + end end end end