nmerouze/machinist_mongo

Rails 3 + Mongoid: undefined method `blueprint'

Closed this issue · 3 comments

I'm using mongoid and rails 3. I'm getting the error: undefined method `blueprint' when I try to run the test. Here's the trace:

/Users/ScottMessinger/code/congoid/test/blueprints.rb:9: undefined method `blueprint' for Course:Class (NoMethodError)
from /Users/ScottMessinger/code/src/rails/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/ScottMessinger/code/src/rails/activesupport/lib/active_support/dependencies.rb:209:in `require'
from /Users/ScottMessinger/code/src/rails/activesupport/lib/active_support/dependencies.rb:197:in `load_dependency'
from /Users/ScottMessinger/code/src/rails/activesupport/lib/active_support/dependencies.rb:209:in `require'
from ./test/test_helper.rb:3
from ./test/integration/create_course_test.rb:1:in `require'
from ./test/integration/create_course_test.rb:1
from /Users/ScottMessinger/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /Users/ScottMessinger/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /Users/ScottMessinger/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /Users/ScottMessinger/.rvm/gems/ruby-1.8.7-p249%global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5

I have the gems installed:
machinist (1.0.6)
machinist_mongo (1.1.0)

and declared in my gemfile:
gem 'machinist_mongo'

My blueprints file looks like this:

require 'machinist/mongoid'
require 'sham'
require 'faker'

Sham.title { Faker::Lorem.sentence }
Sham.body  { Faker::Lorem.paragraph }
Sham.time_string {Faker::Lorem.words}

Course.blueprint do
 title
end

Sequence.blueprint do
 course { Course.make }
 time_string
end


My test_helper.rb looks like this:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/blueprints')
require 'rails/test_help'
require 'shoulda'
require "webrat"


Webrat.configure do |config|
 config.mode = :rails
end

class ActiveSupport::TestCase
 setup { Sham.reset }  
 fixtures :all
end
odf commented

Try using
gem 'machinist_mongo', :require => 'machinist/mongoid'
in your Gemfile.

I've updated the README file to not confuse people anymore.