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

undefined method `has_fields?' #7

Closed
msolli opened this issue Sep 13, 2010 · 3 comments
Closed

undefined method `has_fields?' #7

msolli opened this issue Sep 13, 2010 · 3 comments

Comments

@msolli
Copy link

msolli commented Sep 13, 2010

Hello

I just installed mongoid-spec 1.2.1 alongside mongoid 2.0.0.beta.17 and Rails 3.0.0. I have the following model spec:

require 'spec_helper'
describe Article do
  it { should have_field(:headword) }
end

article.rb:

class Article
  include Mongoid::Document
  field :headword
end

When I run the spec, I get the following error:

Failures:
  1) Article 
     Failure/Error: it { should have_field(:headword) }
     undefined method `has_field?' for #<Article:0x102bc6008>
     # /Users/martin/.rvm/gems/ruby-1.8.7-p302/gems/mongoid-2.0.0.beta.17/lib/mongoid/attributes.rb:23:in `method_missing'
     # ./spec/models/article_spec.rb:5
     # /Users/martin/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `inject'

Any idea what could be causing this?

Best regards,
Martin Solli

@jeyb
Copy link
Contributor

jeyb commented Sep 13, 2010

Did you include the Mongoid::Matchers in spec_helper.rb within the RSpec config block?

RSpec.configure do |config|
  config.include Mongoid::Matchers
end

@msolli
Copy link
Author

msolli commented Sep 13, 2010

That did the trick, thanks! It should probably be documented in the readme, for RSpec noobs like me.

@raycohen
Copy link

Yeah adding this to the docs would be handy

This issue was closed.
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

3 participants