Skip to content

Commit

Permalink
Improve the way we switch between project Gemfile and appraisal gemfiles
Browse files Browse the repository at this point in the history
Previously, the railties required by the project gemspec was in conflict with
the rails versions being pulled in by Appraisal.

There were situations where a newer rails app was generated by `rails new...`
even though the Appraisal gemfiles/ value should have been setting it correctly.

We need to be able to use the versions of things specified in the appraisal gemfiles/
specify the version of rails for the initial generation of the applications,
but subsequently allow those applications to point to the `Gemfile` within
the newly generated rails apps, rather than wherever BUNDLE_GEMFILE was previously
set by Appraisal.
  • Loading branch information
mjankowski committed Dec 19, 2012
1 parent b7f5c5d commit 95eaa4a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 58 deletions.
17 changes: 6 additions & 11 deletions features/fixture_replacement_config.feature
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
@disable-bundler
Feature:
In order to not have to manually configure factory girl as the testing fixture replacement
by using the --fixture-replacement=factory_girl option
as a Rails3 and Factory Girl user
I would like the Factory Girl Rails gem to configure Factory Girl
as the fixture replacement.
In order to not have to manually configure factory girl as the testing fixture replacement by using the --fixture-replacement=factory_girl option as a Rails3 and Factory Girl user
I would like the Factory Girl Rails gem to configure Factory Girl as the fixture replacement.

Background:
Given I successfully run `bundle exec rails new testapp`
And I cd to "testapp"
And I add "factory_girl_rails" from this project as a dependency
And I configure the database connection for the application
And I configure the database connection for the application
And I reset Bundler environment variable

Scenario: Using Factory Girl and Factory Girl Rails with Test Unit generates
a factory file and does not generate a fixture file
Scenario: Using Factory Girl and Factory Girl Rails with Test Unit generates a factory file and does not generate a fixture file
And I successfully run `bundle install`
And I successfully run `bundle exec rails generate model User name:string`
Then the following files should exist:
| test/factories/users.rb |
And the following files should not exist:
| test/fixtures/users.yml |


Scenario: Using Factory Girl and Factory Girl Rails with RSpec should generate a factory file
And I add "rspec-rails" as a dependency
When I add "rspec-rails" as a dependency
And I successfully run `bundle install`
And I successfully run `bundle exec rails generate model User name:string`
Then the following files should exist:
Expand Down
17 changes: 7 additions & 10 deletions features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ Feature:
As a user of Rails3 and factory_girl
I would like to use factory_girl_rails generators.

Scenario: The factory_girl_rails generators create a factory file
for each model that I generate
When I successfully run `bundle exec rails new testapp`
Background:
Given I successfully run `bundle exec rails new testapp`
And I cd to "testapp"
And I add "factory_girl_rails" from this project as a dependency
And I configure the database connection for the application
And I configure the database connection for the application
And I reset Bundler environment variable

Scenario: The factory_girl_rails generators create a factory file for each model that I generate
When I successfully run `bundle install`
And I successfully run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl`
And I successfully run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl`
Expand All @@ -17,12 +19,7 @@ Feature:
And the file "test/factories/users.rb" should contain "factory :user do"
And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"

Scenario: The factory_girl_rails generators create a factory file with a
custom name for each model that I generate
When I successfully run `bundle exec rails new testapp`
And I cd to "testapp"
And I add "factory_girl_rails" from this project as a dependency
And I configure the database connection for the application
Scenario: The factory_girl_rails generators create a factory file with a custom name for each model that I generate
When I successfully run `bundle install`
And I set the FactoryGirl :suffix option to "factory"
And I successfully run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl`
Expand Down
8 changes: 4 additions & 4 deletions features/load_definitions.feature
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Feature: automatically load step definitions

Background:
When I successfully run `bundle exec rails new testapp`
And I cd to "testapp"
And I add "factory_girl_rails" from this project as a dependency
And I configure the database connection for the application
And I configure the database connection for the application
And I reset Bundler environment variable
When I successfully run `bundle install`
And I write to "db/migrate/1_create_users.rb" with:
"""
Expand All @@ -22,7 +24,6 @@ Feature: automatically load step definitions
end
"""

@disable-bundler
Scenario: generate a rails 3 application and use factory definitions
When I write to "test/factories.rb" with:
"""
Expand All @@ -46,7 +47,6 @@ Feature: automatically load step definitions
When I successfully run `bundle exec rake test --trace`
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"

@disable-bundler
Scenario: use factories advertised by railties/engines/3rd-party gems
When I append to "config/application.rb" with:
"""
Expand Down Expand Up @@ -83,4 +83,4 @@ Feature: automatically load step definitions
end
"""
When I successfully run `bundle exec rake test --trace`
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
3 changes: 3 additions & 0 deletions features/step_definitions/appraisal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When /^I reset Bundler environment variable$/ do
unset_bundler_env_vars
end
12 changes: 1 addition & 11 deletions gemfiles/rails3.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ GEM
activesupport (= 3.0.17)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activerecord-jdbc-adapter (1.2.2.1)
activerecord-jdbcsqlite3-adapter (1.2.2.1)
activerecord-jdbc-adapter (~> 1.2.2.1)
jdbc-sqlite3 (~> 3.7.2)
activeresource (3.0.17)
activemodel (= 3.0.17)
activesupport (= 3.0.17)
Expand All @@ -61,15 +57,10 @@ GEM
factory_girl (4.1.0)
activesupport (>= 3.0.0)
ffi (1.2.0)
ffi (1.2.0-java)
gherkin (2.11.5)
json (>= 1.4.6)
gherkin (2.11.5-java)
json (>= 1.4.6)
i18n (0.5.0)
jdbc-sqlite3 (3.7.2)
json (1.7.5)
json (1.7.5-java)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
Expand All @@ -96,7 +87,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (10.0.2)
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
Expand All @@ -115,7 +106,6 @@ GEM
tzinfo (0.3.35)

PLATFORMS
java
ruby

DEPENDENCIES
Expand Down
12 changes: 1 addition & 11 deletions gemfiles/rails3.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ GEM
activesupport (= 3.1.8)
arel (~> 2.2.3)
tzinfo (~> 0.3.29)
activerecord-jdbc-adapter (1.2.2.1)
activerecord-jdbcsqlite3-adapter (1.2.2.1)
activerecord-jdbc-adapter (~> 1.2.2.1)
jdbc-sqlite3 (~> 3.7.2)
activeresource (3.1.8)
activemodel (= 3.1.8)
activesupport (= 3.1.8)
Expand All @@ -61,16 +57,11 @@ GEM
factory_girl (4.1.0)
activesupport (>= 3.0.0)
ffi (1.2.0)
ffi (1.2.0-java)
gherkin (2.11.5)
json (>= 1.4.6)
gherkin (2.11.5-java)
json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.1)
jdbc-sqlite3 (3.7.2)
json (1.7.5)
json (1.7.5-java)
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -102,7 +93,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (10.0.2)
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
Expand All @@ -126,7 +117,6 @@ GEM
tzinfo (0.3.35)

PLATFORMS
java
ruby

DEPENDENCIES
Expand Down
12 changes: 1 addition & 11 deletions gemfiles/rails3.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ GEM
activesupport (= 3.2.9)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activerecord-jdbc-adapter (1.2.2.1)
activerecord-jdbcsqlite3-adapter (1.2.2.1)
activerecord-jdbc-adapter (~> 1.2.2.1)
jdbc-sqlite3 (~> 3.7.2)
activeresource (3.2.9)
activemodel (= 3.2.9)
activesupport (= 3.2.9)
Expand Down Expand Up @@ -60,17 +56,12 @@ GEM
factory_girl (4.1.0)
activesupport (>= 3.0.0)
ffi (1.2.0)
ffi (1.2.0-java)
gherkin (2.11.5)
json (>= 1.4.6)
gherkin (2.11.5-java)
json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.1)
jdbc-sqlite3 (3.7.2)
journey (1.0.4)
json (1.7.5)
json (1.7.5-java)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -100,7 +91,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.2)
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
Expand All @@ -125,7 +116,6 @@ GEM
tzinfo (0.3.35)

PLATFORMS
java
ruby

DEPENDENCIES
Expand Down

0 comments on commit 95eaa4a

Please sign in to comment.