Permalink
Browse files

Improve spec_helper to make use of FactoryGirl 2's reload function

Fixes most (or all) potential issues with Factory loading and Spork
Use FactoryGirl 2.1.2
  • Loading branch information...
1 parent b5bac01 commit 638032b266630a422a5a615e00480e257195c2e1 Jamie Winsor committed Sep 26, 2011
Showing with 24 additions and 22 deletions.
  1. +1 −1 Gemfile
  2. +6 −2 Gemfile.lock
  3. +10 −12 spec/spec_helper.rb
  4. +7 −7 testing/lib/generators/files/spec/spec_helper.rb
View
@@ -33,7 +33,7 @@ group :development do
end
group :development, :test do
- gem 'refinerycms-testing', '~> 2.0.0'
+ gem 'refinerycms-testing', '~> 2.0.0', :require => false
gem 'rcov', :platform => :mri_18
gem 'simplecov', :platform => :mri_19
gem 'capybara-webkit', '~> 0.6.1'
View
@@ -68,7 +68,7 @@ PATH
json_pure
launchy
rack-test (>= 0.5.6)
- refinerycms-core (= 2.0.0)
+ refinerycms (= 2.0.0)
rspec-instafail
rspec-rails (= 2.6.1)
@@ -140,7 +140,8 @@ GEM
erubis (2.7.0)
execjs (1.2.7)
multi_json (~> 1.0)
- factory_girl (2.1.0)
+ factory_girl (2.1.2)
+ activesupport
factory_girl_rails (1.2.0)
factory_girl (~> 2.1.0)
railties (>= 3.0.0)
@@ -203,6 +204,8 @@ GEM
activesupport (= 3.1.1.rc1)
bundler (~> 1.0)
railties (= 3.1.1.rc1)
+ rails-dev-tweaks (0.5.0)
+ rails (~> 3.1.0)
railties (3.1.1.rc1)
actionpack (= 3.1.1.rc1)
activesupport (= 3.1.1.rc1)
@@ -284,6 +287,7 @@ DEPENDENCIES
jquery-rails
mysql2
rails (= 3.1.1.rc1)
+ rails-dev-tweaks (~> 0.5.0)
rb-fchange (~> 0.0.5)
rb-fsevent (>= 0.3.9)
rb-notifu (~> 0.0.4)
View
@@ -25,21 +25,10 @@ def setup_environment
require 'rspec/rails'
require 'capybara/rspec'
-
- require 'refinery/testing/factories'
- require 'refinery/testing/controller_macros'
- require 'refinery/testing/request_macros'
+ require 'factory_girl_rails'
Rails.backtrace_cleaner.remove_silencers!
- # Requires supporting files with custom matchers and macros, etc,
- # in ./support/ and its subdirectories including factories.
- ([Rails.root] | ::Refinery::Plugins.registered.pathnames).map{|p|
- Dir[p.join('spec', 'support', '**', '*.rb').to_s]
- }.flatten.sort.each do |support_file|
- require support_file
- end
-
RSpec.configure do |config|
config.mock_with :rspec
end
@@ -49,6 +38,15 @@ def setup_environment
end
def each_run
+ FactoryGirl.reload
+
+ # Requires supporting files with custom matchers and macros, etc,
+ # in ./support/ and its subdirectories including factories.
+ ([Rails.root] | ::Refinery::Plugins.registered.pathnames).map{|p|
+ Dir[p.join('spec', 'support', '**', '*.rb').to_s]
+ }.flatten.sort.each do |support_file|
+ require support_file
+ end
end
# If spork is available in the Gemfile it'll be used but we don't force it.
@@ -7,23 +7,23 @@ def setup_environment
require 'rspec/rails'
require 'capybara/rspec'
- require 'factory_girl'
- require 'refinerycms-testing'
+ require 'factory_girl_rails'
Rails.backtrace_cleaner.remove_silencers!
- Dir[
- File.expand_path("../support/**/*.rb", __FILE__),
- File.expand_path("../factories/**/*.rb", __FILE__)
- ].each {|f| require f}
-
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false
end
end
def each_run
+ FactoryGirl.reload
+
+ Dir[
+ Rails.root.join('spec/support/**/*.rb'),
+ Rails.root.join('spec/factories/**/*.rb')
+ ].each { |f| require f }
end
# If spork is available in the Gemfile it'll be used but we don't force it.

0 comments on commit 638032b

Please sign in to comment.