ruby on rails - Rspec issue with method -



ruby on rails - Rspec issue with method -

i'm trying create simple validation, main issue thing rails version (i have been using rspec rails 4) because i'm using rails 3.2 , ruby 1.9.3.

this code in model

expect(section).to have(1).errors_on(:name)

and homecoming error

1) admin::section invalid without name failure/error: expect(section).to have(1).errors_on(:name) nomethoderror: undefined method `have' #<rspec::examplegroups::adminsection:0x007f81cf6e72d0>

my gem list

* rspec-core (3.0.1) * rspec-expectations (3.0.1) * rspec-mocks (3.0.1) * rspec-rails (3.0.1) * rspec-support (3.0.0)

i can create pass should be_valid deprecated.

if utilize have_at_least error on errors_on

see pull request. have(n) extracted rspec-collection_matchers gem

you can include or utilize 1 of following:

expect(section.error_on(:name)size).to eq(1) expect(section.error_on(:name)).to be_present expect(section).to have_validation_error("your error message").on(:name)

ruby-on-rails ruby-on-rails-3 rspec ruby-on-rails-3.2

Comments