mardi 23 mars 2021

Ruby on Rails Tutorial Chapter 7 Integration Test Argument Error

Just starting with Rails and am working my way through Ruby on Rails Tutorial 6th edition. Things have been going great, been able to fix all issues, until now! I'm stuck on Chapter 7.3.4 while testing for Invalid Form Submissions. When running tests I receive the following:

ERROR["test_invalid_signup_information", #<Minitest::Reporters::Suite:0x00000001390c2d78 @name="UsersSignupTest">, 0.7315919999964535]
 test_invalid_signup_information#UsersSignupTest (0.73s)
Minitest::UnexpectedError:         ArgumentError: wrong number of arguments (given 2, expected 1)
            test/integration/users_signup_test.rb:8:in `block in <class:UsersSignupTest>'

  17/17: [===============================================================================] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.82379s
17 tests, 33 assertions, 0 failures, 1 errors, 0 skips

Here is the test file. I've tried testing both files and they produce the same error:

require "test_helper"

class UsersSignupTest < ActionDispatch::IntegrationTest

  test "invalid signup information" do
    get signup_path
    before_count = User.count
    post users_path, params: { user: { name: '',
                                       email: 'user@invalid',
                                       password:              'foo',
                                       password_confirmation: 'bar' } }
    after_count = User.count
    assert_equal before_count, after_count
    assert_template 'users/new'
  end
end
require 'test_helper'

class UsersSignupTest < ActionDispatch::IntegrationTest

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

This is my first experience with Rails so any help would be super appreciated!

Aucun commentaire:

Enregistrer un commentaire