Avatar Edgar Gonzalez

  • Random
  • Archive
  • RSS

Replacing fixture generation on Rails 3

Because I don’t like fixtures (I use factory_girl), I change my Rails generators to generate factories instead of fixtures

To do this, just add this to your config/application.rb:

config.generators do |g|
  g.test_framework :test_unit, :fixture_replacement => :factory_girl
end

But in my case, because I prefer rspec instead of test_unit, I use this:

config.generators do |g|
  g.fixture_replacement :factory_girl, :dir => "spec/factories"
end

Changing the factories directory from test/factories (default) to spec/factories.

Because I’m using the rspec-rails gem, I don’t have to define the test framework (but I can), so this works too:

config.generators do |g|
  g.test_framework :rspec
  g.fixture_replacement :factory_girl, :dir => "spec/factories"
end

    • #rails
    • #rails3
    • #fixtures
    • #factory_girl
    • #generators
    • #RSpec
    • #test
  • 2 years ago
  • 7
  • Comments
  • Permalink
  • Share
    Tweet

RSpec with Mongoid

If you are using Mongoid as ORM and RSpec for testing maybe you are interested in use the mongoid-rspec gem.

mongoid-rspec provide several RSpec matchers and macros for Mongoid.

If you are using the new master branch of Mongoid (which is my case), probably you are facing this error when try to run your specs (rake spec):

no such file to load -- mongoid/associations (LoadError)

This is because the new master branch of Mongoid has deleted the file mongoid/associations. You need use the safe_master branch. Or you can try to use this fork of Mongoid-rspec compatible with Mongoid 2.0.0.rc1:

https://github.com/shingara/mongoid-rspec/tree/mongoid-2.0.0.rc1

To do this, just add this gem to your gemfile:

gem 'mongoid-rspec', :git => 'git://github.com/shingara/mongoid-rspec.git', 
                     :branch => 'mongoid-2.0.0.rc1'
    • #rails3
    • #rails
    • #rspec
    • #MongoDB
    • #mongo
    • #mongoid
    • #test
    • #bdd
    • #nosql
    • #gemfile
  • 2 years ago
  • 2
  • Comments
  • Permalink
  • Share
    Tweet

Efficient Rails Test-Driven Development

There are six videos that teaches you how to test in Rails, by Wolfram Arnold:

  • Class 1 of 6
  • Class 2 of 6
  • Class 3 of 6
  • Class 4 of 6
  • Class 5 of 6
  • Class 6 of 6
    • #rails
    • #test
    • #tutorial
    • #video
  • 2 years ago
  • 2
  • Comments
  • Permalink
  • Share
    Tweet

Portrait/Logo

About

Edgar Gonzalez

Father, husband, and software developer. I'm building web applications since 1994 for a living and I love it.

Rubyist, Rails developer since 2006, believer of Agile Development and Lean startups, NoSQL enthusiast.

Born in Caracas - Venezuela, living in New York.

Me, Elsewhere

  • @edgar on Twitter
  • Facebook Profile
  • edgargonzaleznetve on Youtube
  • egg on Flickr
  • edgar on Foursquare
  • My Skype Info
  • Linkedin Profile
  • edgar on github

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr