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

page.should have_field fails #506

Closed
tmaier opened this issue Sep 26, 2011 · 5 comments
Closed

page.should have_field fails #506

tmaier opened this issue Sep 26, 2011 · 5 comments

Comments

@tmaier
Copy link

tmaier commented Sep 26, 2011

All my checks for have_field fail.

For example, when I run

          page.should have_field "Manufacturer", with: "Siemens"
          page.should have_field "Product name", with: "Lufthaken"
          page.should have_field "Unit", with: "Stk."
          page.should have_checked_field "Accepted"

I get the following error message:

  Failure/Error: page.should have_field "Manufacturer", with: "Siemens"
  NoMethodError:
   undefined method `fields' for Capybara::Session:Class

The matcher have_checked_field works as expected.

@KL-7
Copy link

KL-7 commented Nov 26, 2011

Are you using mongoid-rspec gem?

I had similar issue and the problem was in capybara and mongoid-rspec both having have_field matcher. I solved it by restricting usage of Mongoid::Matchers to model specs using

configuration.include Mongoid::Matchers, :type => :model

in rspec config. If that doesn't help you can run rspec with -b option to see full backtrace. That can give some idea about what's wrong in your case.

@tmaier
Copy link
Author

tmaier commented Dec 2, 2011

Hi Kirill,

you were right.
Thanks for your help.

@tmaier tmaier closed this as completed Dec 2, 2011
@hosamaly
Copy link

Thanks @KL-7 . I might mention that this line of code should be in spec/support/mongoid.rb.

@gurix
Copy link
Contributor

gurix commented Sep 11, 2013

Thanks, saved my day!

@vlaguzman
Copy link

It does´t work for my, then I used the "page.has_field? notation"

page.has_field?("field_name").should == true

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants