You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User Story:
As a user I'd like airborne to throw an error if object called is not present within the json_body so that I have better clarity on my malformed test
Test - POST:
it 'should add new members or update existing members in bulk' do
$faker_members = Faker::Internet.safe_email
post '/members', {"members" => [{"email" => "#{$faker_members}"}]}
$post_member_from_members = json_body[:member_id]
puts "#{$post_member_from_members} - Members"
expect_status(200)
end
Test - PUT:
it 'should add a single member to one or more groups' do
put "/members/#{$post_member_from_members}/groups", {}
expect_status(200)
end
json_body object called in test:
$post_member_from_members = json_body[:member_id]
Actual json_body:
{
"import_id": 1234
}
Result of puts:
- Members
Failure on PUT:
1) PUT - Members should add a single member to one or more groups
Failure/Error: expect_status(200)
expected: 200
got: 404
(compared using ==)
# /Users/dhale/.rvm/gems/ruby-2.1.0/gems/airborne-0.1.13/lib/airborne/request_expectations.rb:35:in `expect_status'
# /Users/dhale/.rvm/gems/ruby-2.1.0/gems/airborne-0.1.13/lib/airborne/request_expectations.rb:62:in `call'
# /Users/dhale/.rvm/gems/ruby-2.1.0/gems/airborne-0.1.13/lib/airborne/request_expectations.rb:62:in `block (2 levels) in <module:RequestExpectations>'
# ./spec/api_spec.rb:313:in `block (2 levels) in <top (required)>'
The text was updated successfully, but these errors were encountered:
json_body is a standard ruby hash, which, when accessed with a key that doesn't exist, returns nil. I wouldn't want to throw an error when trying to access it with a key that doesn't exist, but rather, in your test case, I would tell you to test for the response you're expecting:
it'should add new members or update existing members in bulk'do
$faker_members =Faker::Internet.safe_emailpost'/members',{"members"=>[{"email"=>"#{$faker_members}"}]}
$post_member_from_members =json_body[:member_id]expect_json_types({member_id: :integer})expect_status(200)end
This way, you'll know exactly where your issue is and what exactly is failing.
User Story:
As a user I'd like airborne to throw an error if object called is not present within the
json_body
so that I have better clarity on my malformed testTest - POST:
Test - PUT:
json_body
object called in test:Actual
json_body
:Result of
puts
:Failure on PUT:
The text was updated successfully, but these errors were encountered: