Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `[]' for nil:NilClass for POST on resource #110

Closed
lalitchandnani opened this issue Jul 26, 2016 · 0 comments

Comments

@lalitchandnani
Copy link

I'm using airborne to write test cases around APIs i've created and it works great except a scenario when i'm trying to pass an empty json for a POST endpoint which has some of parameters as required. I'm using grape to create REST APIs.

Example:

describe "Empty POST on Resource" do
      let(:req_params) {
        {
        }
      }
      it "fails to create a new lead" do
        post "/v1/resource/", req_params
        expect(response).to have_http_status(422)
      end
    end

I'm receiving following response, if required fields are not present in test case.

 undefined method `[]' for nil:NilClass
     # /path/to/directory/api/exceptions.rb:43:in `notify'
     #/path/to/directory/api/base.rb:104:in `block (2 levels) in <module:Base>'
     # ./spec/api/pulpit/api_v1_spec.rb:62:in `block (4 levels) in <top (required)>'

However, If i make mandatory params in api as optional, things work fine. Not sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant