Browse files

Add failing feature for fixture directory override

For projects configured with rspec as the test framework, the railtie
overrides any user-specified fixture directory that might be included in
config/application.rb.

This patch modifies the required behaviour so that if such configuration
is detected, it is not overridden. It also expects the auto-added
configuration to match the generator's default of 'test/factories'.
  • Loading branch information...
1 parent f3321f9 commit f2cf240170078e9727b9cf86aac159d152014644 @urbanautomaton urbanautomaton committed Jun 18, 2012
Showing with 24 additions and 2 deletions.
  1. +13 −2 features/fixture_replacement_config.feature
  2. +11 −0 features/step_definitions/rails_steps.rb
View
15 features/fixture_replacement_config.feature
@@ -26,6 +26,17 @@ Feature:
And I successfully run `bundle install`
And I successfully run `bundle exec rails generate model User name:string`
Then the following files should exist:
- | spec/factories/users.rb |
+ | test/factories/users.rb |
And the following files should not exist:
- | spec/fixtures/users.yml |
+ | test/fixtures/users.yml |
+
+ Scenario: Using Factory Girl and Factory Girl Rails does not override a
+ manually-configured factories directory
+ And I add "rspec-rails" as a dependency
+ And I configure the factories directory as "custom/dir"
+ And I successfully run `bundle install`
+ And I successfully run `bundle exec rails generate model User name:string`
+ Then the following files should exist:
+ | custom/dir/users.rb |
+ And the following files should not exist:
+ | test/factories/users.rb |
View
11 features/step_definitions/rails_steps.rb
@@ -5,3 +5,14 @@
When /^I add "([^"]+)" as a dependency$/ do |gem_name|
append_to_file('Gemfile', %{gem "#{gem_name}"\n})
end
+
+When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir|
+ append_to_file File.join('config', 'application.rb'), <<-END
+class Testapp::Application
+ config.generators do |g|
+ g.test_framework :rspec, :fixture => true, :views => false
+ g.fixture_replacement :factory_girl, :dir => "#{factory_dir}"
+ end
+end
+ END
+end

0 comments on commit f2cf240

Please sign in to comment.