1

I have this test:

test "invalid signup" do
  get signup_path
  assert_no_difference 'User.count' do
    post users_path, user: {
      name: '', email: '', password: '',
      password_confirmation:''
    }
  end
  assert_template 'users/new'
end

but when I run it with rake test, I see this error:

Error: UsersSignupTest#test_invalid_signup: ArgumentError: unknown keyword: user test/integration/users_signup_test.rb:9:in block (2 levels) in ' test/integration/users_signup_test.rb:8:in block in '

How to pass data for POST method ?

1 Answer 1

2

Here is the code that you were supposed to copy:

assert_no_difference 'User.count' do
  post users_path, params: { user: { name:  "",
                                     email: "user@invalid",
                                     password:              "foo",
                                     password_confirmation: "bar" } }
end

The key-value pair params: some_hash is the second argument to post()--not the key-value pair user: some_hash.

The params hash is a pretty important concept in rails.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.