Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you load Machinist's blueprints when using Spork?

How do you load Machinist's blueprints when using Spork?

Gems:

  • mongoid (2.0.0.rc.6)
  • capybara (0.4.1.1)
  • steak (1.1.0)
  • spork (0.9.0.rc2)
  • rspec (2.4.0)
  • machinist (2.0.0.beta2)

I get this error in every acceptance test:

Machinist::NoBlueprintError:
   No master blueprint defined for class School

All test fail, because it doesn't find any blueprint. I some of these errors on V2(I still get a couple of No master blueprint..), but I get another error too:

Professor Create a new professor
 Failure/Error: click_link("Profesores")
 RangeError:
   0x000000821461e4 is recycled object

I got config.cache_classes = false in test environment for this one.

Both spec_helper versions:

https://gist.github.com/801814

like image 437
Nerian Avatar asked Oct 13 '22 17:10

Nerian


1 Answers

I'd been bashing my head against a brick wall trying to run tests on windows with all the gems you've mentioned. I wrote an article on my blog in case anyone's interested, and yes I already know, windows is balls, but I'm having to use it out of necessity:

Setting up a fast efficient testing environment using Ruby192, Rails 3.0.4, RSpec 2.5.0, Cucumber 0.10.0 and Spork!

The blog itself doesn't mention machinist but I'm actually using that 2.0.0.beta2 gem myself with spork to run my cucumber tests.

Just to rule out the obvious have you included something like this in your application.rb file:

config.generators do |g|
  g.fixture_replacement :machinist      
end

Also have you set up your blueprints files in:

features/support/blueprints.rb for cucumber   
spec/support/blueprints.rb for rspec

and made sure you've included:

require 'machinist/active_record'

in the top of your blueprints.

Also just on another note for when you get it up and running. Machinist caches a lot of objects to make it run faster, but it may occasionally trip you up when constantly trying to clear out the database. If you run into problems you can turn off Machinists caching by adding this to your config/environments/test.rb file:

Machinist.configure do |config|
  config.cache_objects = false
end
like image 145
2potatocakes Avatar answered Nov 15 '22 14:11

2potatocakes