factory_girl_rails 4.4.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +18 -22
  3. data/CONTRIBUTING.md +27 -26
  4. data/Gemfile +18 -1
  5. data/Gemfile.lock +144 -0
  6. data/NEWS +15 -0
  7. data/README.md +51 -38
  8. data/bin/setup +16 -0
  9. data/bin/stubs/a2h +16 -0
  10. data/bin/stubs/appraisal +17 -0
  11. data/bin/stubs/aruba +16 -0
  12. data/bin/stubs/autospec +17 -0
  13. data/bin/stubs/bcat +16 -0
  14. data/bin/stubs/btee +16 -0
  15. data/bin/stubs/bundler +17 -0
  16. data/bin/stubs/cdiff +16 -0
  17. data/bin/stubs/cucumber +17 -0
  18. data/bin/stubs/decolor +16 -0
  19. data/bin/stubs/erubis +17 -0
  20. data/bin/stubs/htmldiff +17 -0
  21. data/bin/stubs/ldiff +17 -0
  22. data/bin/stubs/nokogiri +16 -0
  23. data/bin/stubs/rackup +17 -0
  24. data/bin/stubs/rails +17 -0
  25. data/bin/stubs/rake +17 -0
  26. data/bin/stubs/rake2thor +16 -0
  27. data/bin/stubs/rdiscount +16 -0
  28. data/bin/stubs/rdoc +16 -0
  29. data/bin/stubs/ri +16 -0
  30. data/bin/stubs/rspec +17 -0
  31. data/bin/stubs/setup +16 -0
  32. data/bin/stubs/sprockets +16 -0
  33. data/bin/stubs/thor +17 -0
  34. data/bin/stubs/tilt +16 -0
  35. data/factory_girl_rails.gemspec +6 -13
  36. data/features/fixture_replacement_config.feature +51 -11
  37. data/features/generators.feature +40 -14
  38. data/features/load_definitions.feature +8 -8
  39. data/features/step_definitions/appraisal.rb +1 -1
  40. data/features/step_definitions/rails_steps.rb +5 -23
  41. data/features/support/env.rb +2 -2
  42. data/gemfiles/rails3.2.gemfile +14 -8
  43. data/gemfiles/rails3.2.gemfile.lock +117 -100
  44. data/gemfiles/rails4.1.gemfile +23 -0
  45. data/gemfiles/rails4.1.gemfile.lock +183 -0
  46. data/gemfiles/rails4.2.gemfile +21 -0
  47. data/gemfiles/rails4.2.gemfile.lock +193 -0
  48. data/gemfiles/rails5.0.gemfile +22 -0
  49. data/gemfiles/rails5.0.gemfile.lock +156 -0
  50. data/lib/factory_girl_rails/generators/rspec_generator.rb +1 -1
  51. data/lib/factory_girl_rails/railtie.rb +4 -0
  52. data/lib/generators/factory_girl/model/model_generator.rb +77 -9
  53. data/lib/generators/factory_girl.rb +1 -1
  54. data/pkg/factory_girl_rails-4.5.0.gem +0 -0
  55. data/tmp/aruba/testapp/Gemfile +55 -0
  56. data/tmp/aruba/testapp/Gemfile.lock +195 -0
  57. data/tmp/aruba/testapp/README.md +24 -0
  58. data/tmp/aruba/testapp/Rakefile +6 -0
  59. data/tmp/aruba/testapp/app/assets/config/manifest.js +3 -0
  60. data/tmp/aruba/testapp/app/assets/javascripts/application.js +16 -0
  61. data/tmp/aruba/testapp/app/assets/javascripts/cable.js +13 -0
  62. data/tmp/aruba/testapp/app/assets/stylesheets/application.css +15 -0
  63. data/tmp/aruba/testapp/app/channels/application_cable/channel.rb +4 -0
  64. data/tmp/aruba/testapp/app/channels/application_cable/connection.rb +4 -0
  65. data/tmp/aruba/testapp/app/controllers/application_controller.rb +3 -0
  66. data/tmp/aruba/testapp/app/helpers/application_helper.rb +2 -0
  67. data/tmp/aruba/testapp/app/jobs/application_job.rb +2 -0
  68. data/tmp/aruba/testapp/app/mailers/application_mailer.rb +4 -0
  69. data/tmp/aruba/testapp/app/models/application_record.rb +3 -0
  70. data/tmp/aruba/testapp/app/models/user.rb +2 -0
  71. data/tmp/aruba/testapp/app/views/layouts/application.html.erb +14 -0
  72. data/tmp/aruba/testapp/app/views/layouts/mailer.html.erb +13 -0
  73. data/tmp/aruba/testapp/app/views/layouts/mailer.text.erb +1 -0
  74. data/tmp/aruba/testapp/bin/bundle +3 -0
  75. data/tmp/aruba/testapp/bin/rails +9 -0
  76. data/tmp/aruba/testapp/bin/rake +9 -0
  77. data/tmp/aruba/testapp/bin/setup +34 -0
  78. data/tmp/aruba/testapp/bin/spring +17 -0
  79. data/tmp/aruba/testapp/bin/update +29 -0
  80. data/tmp/aruba/testapp/config/application.rb +16 -0
  81. data/tmp/aruba/testapp/config/boot.rb +3 -0
  82. data/tmp/aruba/testapp/config/cable.yml +9 -0
  83. data/tmp/aruba/testapp/config/database.yml +25 -0
  84. data/tmp/aruba/testapp/config/environment.rb +5 -0
  85. data/tmp/aruba/testapp/config/environments/development.rb +54 -0
  86. data/tmp/aruba/testapp/config/environments/production.rb +86 -0
  87. data/tmp/aruba/testapp/config/environments/test.rb +42 -0
  88. data/tmp/aruba/testapp/config/initializers/application_controller_renderer.rb +8 -0
  89. data/tmp/aruba/testapp/config/initializers/assets.rb +11 -0
  90. data/tmp/aruba/testapp/config/initializers/backtrace_silencers.rb +7 -0
  91. data/tmp/aruba/testapp/config/initializers/cookies_serializer.rb +5 -0
  92. data/tmp/aruba/testapp/config/initializers/filter_parameter_logging.rb +4 -0
  93. data/tmp/aruba/testapp/config/initializers/inflections.rb +16 -0
  94. data/tmp/aruba/testapp/config/initializers/mime_types.rb +4 -0
  95. data/tmp/aruba/testapp/config/initializers/new_framework_defaults.rb +26 -0
  96. data/tmp/aruba/testapp/config/initializers/session_store.rb +3 -0
  97. data/tmp/aruba/testapp/config/initializers/wrap_parameters.rb +14 -0
  98. data/tmp/aruba/testapp/config/locales/en.yml +23 -0
  99. data/tmp/aruba/testapp/config/puma.rb +47 -0
  100. data/tmp/aruba/testapp/config/routes.rb +3 -0
  101. data/tmp/aruba/testapp/config/secrets.yml +22 -0
  102. data/tmp/aruba/testapp/config/spring.rb +6 -0
  103. data/tmp/aruba/testapp/config.ru +5 -0
  104. data/tmp/aruba/testapp/db/development.sqlite3 +0 -0
  105. data/tmp/aruba/testapp/db/migrate/1_create_users.rb +7 -0
  106. data/tmp/aruba/testapp/db/schema.rb +19 -0
  107. data/tmp/aruba/testapp/db/seeds.rb +7 -0
  108. data/tmp/aruba/testapp/db/test.sqlite3 +0 -0
  109. data/tmp/aruba/testapp/lib/some_railtie/factories.rb +5 -0
  110. data/tmp/aruba/testapp/lib/some_railtie/railties.rb +8 -0
  111. data/tmp/aruba/testapp/log/development.log +16 -0
  112. data/tmp/aruba/testapp/log/test.log +21 -0
  113. data/tmp/aruba/testapp/public/404.html +67 -0
  114. data/tmp/aruba/testapp/public/422.html +67 -0
  115. data/tmp/aruba/testapp/public/500.html +66 -0
  116. data/tmp/aruba/testapp/public/apple-touch-icon-precomposed.png +0 -0
  117. data/tmp/aruba/testapp/public/apple-touch-icon.png +0 -0
  118. data/tmp/aruba/testapp/public/favicon.ico +0 -0
  119. data/tmp/aruba/testapp/public/robots.txt +5 -0
  120. data/tmp/aruba/testapp/test/test_helper.rb +10 -0
  121. data/tmp/aruba/testapp/test/unit/user_test.rb +8 -0
  122. metadata +116 -100
  123. data/.gitignore +0 -9
  124. data/.travis.yml +0 -16
  125. data/gemfiles/rails3.1.gemfile +0 -16
  126. data/gemfiles/rails3.1.gemfile.lock +0 -171
  127. data/lib/generators/factory_girl/model/templates/fixtures.erb +0 -9
data/bin/stubs/ldiff ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'ldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "ldiff")
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'nokogiri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("nokogiri", "nokogiri")
data/bin/stubs/rackup ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rackup' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rack", "rackup")
data/bin/stubs/rails ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rails' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("railties", "rails")
data/bin/stubs/rake ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake2thor' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('thor', 'rake2thor')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rdiscount' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rdiscount', 'rdiscount')
data/bin/stubs/rdoc ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rdoc' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rdoc', 'rdoc')
data/bin/stubs/ri ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rdoc', 'ri')
data/bin/stubs/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/stubs/setup ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'setup' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('factory_girl_rails', 'setup')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'sprockets' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('sprockets', 'sprockets')
data/bin/stubs/thor ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'thor' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("thor", "thor")
data/bin/stubs/tilt ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'tilt' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('tilt', 'tilt')
@@ -1,27 +1,20 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{factory_girl_rails}
3
- s.version = '4.4.0'
3
+ s.version = '4.9.0'
4
4
  s.authors = ["Joe Ferris"]
5
5
  s.email = %q{jferris@thoughtbot.com}
6
6
  s.homepage = "http://github.com/thoughtbot/factory_girl_rails"
7
7
  s.summary = %q{factory_girl_rails provides integration between
8
- factory_girl and rails 3}
8
+ factory_girl and rails 3 or newer}
9
9
  s.description = %q{factory_girl_rails provides integration between
10
- factory_girl and rails 3 (currently just automatic factory definition
10
+ factory_girl and rails 3 or newer (currently just automatic factory definition
11
11
  loading)}
12
12
 
13
- s.files = `git ls-files`.split("\n")
14
- s.test_files = `git ls-files -- Appraisals {spec,features,gemfiles}/*`.split("\n")
15
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ s.files = Dir['**/*'].keep_if { |file| File.file?(file) }
16
14
  s.require_paths = ["lib"]
15
+ s.executables = []
17
16
  s.license = "MIT"
18
17
 
19
18
  s.add_runtime_dependency('railties', '>= 3.0.0')
20
- s.add_runtime_dependency('factory_girl', '~> 4.4.0')
21
-
22
- s.add_development_dependency('appraisal', '~> 0.5.0')
23
- s.add_development_dependency('rake')
24
- s.add_development_dependency('rspec', '~> 2.11.0')
25
- s.add_development_dependency('cucumber', '~> 1.2.1')
26
- s.add_development_dependency('aruba', '~> 0.5.1')
19
+ s.add_runtime_dependency('factory_girl', '~> 4.9.0')
27
20
  end
@@ -1,5 +1,5 @@
1
1
  Feature:
2
- 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
2
+ In order to not have to manually configure Factory Girl as the Rails testing fixture replacement by using the --fixture-replacement=factory_girl option
3
3
  I would like the Factory Girl Rails gem to configure Factory Girl as the fixture replacement.
4
4
 
5
5
  Background:
@@ -32,6 +32,23 @@ Feature:
32
32
  And the following files should not exist:
33
33
  | spec/fixtures/users.yml |
34
34
 
35
+ Scenario: Using Factory Girl and Factory Girl Rails with RSpec and suffix configuration should generate a factory file with suffix
36
+ When I add "rspec-rails" as a dependency
37
+ And I configure the factories as:
38
+ """
39
+ config.generators do |g|
40
+ g.test_framework :rspec, fixture: true
41
+ g.fixture_replacement :factory_girl, suffix: 'factory'
42
+ end
43
+ """
44
+ And I run `bundle install` with a clean environment
45
+ Then the output should contain "rspec-rails"
46
+ And I run `bundle exec rails generate model User name:string` with a clean environment
47
+ Then the following files should exist:
48
+ | spec/factories/users_factory.rb |
49
+ And the following files should not exist:
50
+ | spec/fixtures/users.yml |
51
+
35
52
  Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using RSpec
36
53
  When I add "rspec-rails" as a dependency
37
54
  And I configure the factories directory as "custom/dir"
@@ -54,29 +71,22 @@ Feature:
54
71
  But the following files should exist:
55
72
  | custom/dir/users.rb |
56
73
 
57
- Scenario: Using Factory Girl and Factory Girl Rails with MiniTest should generate a factory file
58
- When I add "minitest" as a dependency
59
- And I configure the testing framework to use MiniTest
60
- And I run `bundle install` with a clean environment
61
- Then the output should contain "minitest"
74
+ Scenario: Using Factory Girl Rails with MiniTest should generate a factory file
75
+ When I run `bundle install` with a clean environment
62
76
  And I run `bundle exec rails generate model User name:string` with a clean environment
63
77
  Then the following files should exist:
64
78
  | test/factories/users.rb |
65
79
  But the following files should not exist:
66
80
  | spec/fixtures/users.yml |
67
81
 
68
- Scenario: Using Factory Girl and Factory Girl Rails with MiniTest and a custom directory should generate a factory file
82
+ Scenario: Using Factory Girl Rails with MiniTest and a custom directory should generate a factory file
69
83
  When I configure the factories directory as "custom/dir"
70
- And I add "minitest" as a dependency
71
- And I configure the testing framework to use MiniTest
72
84
  And I run `bundle install` with a clean environment
73
- Then the output should contain "minitest"
74
85
  And I run `bundle exec rails generate model User name:string` with a clean environment
75
86
  Then the following files should exist:
76
87
  | custom/dir/users.rb |
77
88
  But the following files should not exist:
78
89
  | spec/fixtures/users.yml |
79
- And the file "test/models/user_test.rb" should contain "MiniTest::Rails::ActiveSupport::TestCase"
80
90
 
81
91
  Scenario: Disable Factory Girl generator
82
92
  When I configure the factories as:
@@ -90,3 +100,33 @@ Feature:
90
100
  Then the following files should not exist:
91
101
  | test/factories/users.rb |
92
102
  | spec/factories/users.rb |
103
+
104
+ Scenario: Use a suffix with the Factory Girl generator
105
+ When I add "rspec-rails" as a dependency
106
+ When I configure the factories as:
107
+ """
108
+ config.generators do |g|
109
+ g.factory_girl suffix: 'suffix'
110
+ end
111
+ """
112
+ And I run `bundle install` with a clean environment
113
+ And I run `bundle exec rails generate model User name:string` with a clean environment
114
+ Then the following files should exist:
115
+ | spec/factories/users_suffix.rb |
116
+ Then the following files should not exist:
117
+ | spec/factories/users.rb |
118
+
119
+ Scenario: Use a filename_proc with the Factory Girl generator
120
+ When I add "rspec-rails" as a dependency
121
+ When I configure the factories as:
122
+ """
123
+ config.generators do |g|
124
+ g.factory_girl filename_proc: Proc.new { |tb| "prefix_#{tb.singularize}_suffix" }
125
+ end
126
+ """
127
+ And I run `bundle install` with a clean environment
128
+ And I run `bundle exec rails generate model User name:string` with a clean environment
129
+ Then the following files should exist:
130
+ | spec/factories/prefix_user_suffix.rb |
131
+ Then the following files should not exist:
132
+ | spec/factories/users.rb |
@@ -1,6 +1,6 @@
1
1
  Feature:
2
2
  In order to easily generate factory files instead of fixture files when generating models
3
- As a user of Rails3 and factory_girl
3
+ As a user of Rails and Factory Girl
4
4
  I would like to use factory_girl_rails generators.
5
5
 
6
6
  Background:
@@ -8,21 +8,47 @@ Feature:
8
8
  And I cd to "testapp"
9
9
  And I add "factory_girl_rails" from this project as a dependency
10
10
 
11
- Scenario: The factory_girl_rails generators create a factory file for each model that I generate
11
+ Scenario: The factory_girl_rails generators create a factory file for each model if there is not a factories.rb file
12
12
  When I run `bundle install` with a clean environment
13
- And I run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` with a clean environment
14
- And I run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl` with a clean environment
13
+ And I run `bundle exec rails generate model User name:string age:integer` with a clean environment
14
+ And I run `bundle exec rails generate model Namespaced::User name:string` with a clean environment
15
15
  Then the output should contain "test/factories/users.rb"
16
16
  And the output should contain "test/factories/namespaced_users.rb"
17
- And the file "test/factories/users.rb" should contain "factory :user do"
18
- And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"
17
+ And the file "test/factories/users.rb" should contain exactly:
18
+ """
19
+ FactoryGirl.define do
20
+ factory :user do
21
+ name "MyString"
22
+ age 1
23
+ end
24
+ end
19
25
 
20
- Scenario: The factory_girl_rails generators create a factory file with a custom name for each model that I generate
26
+ """
27
+ And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, class: 'Namespaced::User' do"
28
+
29
+ Scenario: The factory_girl_rails generators add a factory in the correct spot
30
+ When I run `bundle install` with a clean environment
31
+ And I write to "test/factories.rb" with:
32
+ """
33
+ FactoryGirl.define do
34
+ end
35
+ """
36
+ And I run `bundle exec rails generate model User name:string` with a clean environment
37
+ Then the file "test/factories.rb" should contain exactly:
38
+ """
39
+ FactoryGirl.define do
40
+ factory :user do
41
+ name "MyString"
42
+ end
43
+ end
44
+ """
45
+
46
+ Scenario: The factory_girl_rails generators does not create a factory file for each model if there is a factories.rb file in the test directory
21
47
  When I run `bundle install` with a clean environment
22
- And I set the FactoryGirl :suffix option to "factory"
23
- And I run `bundle exec rails generate model User name:string --fixture-replacement=factory_girl` with a clean environment
24
- And I run `bundle exec rails generate model Namespaced::User name:string --fixture-replacement=factory_girl` with a clean environment
25
- Then the output should contain "test/factories/users_factory.rb"
26
- And the output should contain "test/factories/namespaced_users_factory.rb"
27
- And the file "test/factories/users_factory.rb" should contain "factory :user do"
28
- And the file "test/factories/namespaced_users_factory.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"
48
+ And I write to "test/factories.rb" with:
49
+ """
50
+ FactoryGirl.define do
51
+ end
52
+ """
53
+ And I run `bundle exec rails generate model User name:string` with a clean environment
54
+ Then the file "test/factories.rb" should contain "factory :user do"
@@ -4,7 +4,7 @@ Feature: automatically load step definitions
4
4
  When I successfully run `bundle exec rails new testapp`
5
5
  And I cd to "testapp"
6
6
  And I add "factory_girl_rails" from this project as a dependency
7
- And I comment out gem "turn" from my Gemfile
7
+ And I add "test-unit" as a dependency
8
8
  And I run `bundle install` with a clean environment
9
9
  And I write to "db/migrate/1_create_users.rb" with:
10
10
  """
@@ -16,14 +16,14 @@ Feature: automatically load step definitions
16
16
  end
17
17
  end
18
18
  """
19
- When I run `bundle exec rake db:migrate --trace` with a clean environment
19
+ When I run `bundle exec rake db:migrate` with a clean environment
20
20
  And I write to "app/models/user.rb" with:
21
21
  """
22
22
  class User < ActiveRecord::Base
23
23
  end
24
24
  """
25
25
 
26
- Scenario: generate a rails 3 application and use factory definitions
26
+ Scenario: generate a Rails application and use factory definitions
27
27
  When I write to "test/factories.rb" with:
28
28
  """
29
29
  FactoryGirl.define do
@@ -43,8 +43,8 @@ Feature: automatically load step definitions
43
43
  end
44
44
  end
45
45
  """
46
- When I run `bundle exec rake test --trace` with a clean environment
47
- Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
46
+ When I run `bundle exec rake test` with a clean environment
47
+ Then the output should contain "1 assertions, 0 failures, 0 errors"
48
48
 
49
49
  Scenario: use factories advertised by railties/engines/3rd-party gems
50
50
  When I append to "config/application.rb" with:
@@ -65,7 +65,7 @@ Feature: automatically load step definitions
65
65
  When I write to "lib/some_railtie/factories.rb" with:
66
66
  """
67
67
  FactoryGirl.define do
68
- factory :factory_from_some_railtie, :class => 'User' do
68
+ factory :factory_from_some_railtie, class: 'User' do
69
69
  name 'Artem'
70
70
  end
71
71
  end
@@ -81,5 +81,5 @@ Feature: automatically load step definitions
81
81
  end
82
82
  end
83
83
  """
84
- When I run `bundle exec rake test --trace` with a clean environment
85
- Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
84
+ When I run `bundle exec rake test` with a clean environment
85
+ Then the output should contain "1 assertions, 0 failures, 0 errors"
@@ -1,5 +1,5 @@
1
1
  When /^I run `([^"]+)` with a clean environment$/ do |command|
2
- step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'`}
2
+ step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`}
3
3
  end
4
4
 
5
5
  # system({'BUNDLE_GEMFILE' => nil}, "cd tmp/aruba/testapp && #{command} && cd -")
@@ -6,17 +6,12 @@ When /^I add "([^"]+)" as a dependency$/ do |gem_name|
6
6
  append_to_file('Gemfile', %{gem "#{gem_name}"\n})
7
7
  end
8
8
 
9
- When /^I set the FactoryGirl :suffix option to "([^"]+)"$/ do |suffix|
10
- append_to_file('config/application.rb', <<-RUBY)
11
- module Testapp
12
- class Application < Rails::Application
13
- config.generators do |g|
14
- g.fixture_replacement :factory_girl, :suffix => '#{suffix}'
15
- end
16
- end
9
+ When /^I print out "([^"]*)"$/ do |path|
10
+ in_current_dir do
11
+ File.open(path, 'r') do |f|
12
+ puts f.inspect
17
13
  end
18
- RUBY
19
-
14
+ end
20
15
  end
21
16
 
22
17
  When /^I configure the factories as:$/ do |string|
@@ -37,19 +32,6 @@ end
37
32
  END
38
33
  end
39
34
 
40
- When /^I configure the testing framework to use MiniTest$/ do
41
- append_to_file('Gemfile', %{gem "minitest-rails", :group => [:development, :test]\n})
42
- step %{I run `rails generate mini_test:install` with a clean environment}
43
-
44
- append_to_file File.join('config', 'application.rb'), <<-END
45
- class Testapp::Application
46
- config.generators do |g|
47
- g.test_framework :mini_test, :fixture => false, :fixture_replacement => :factory_girl
48
- end
49
- end
50
- END
51
- end
52
-
53
35
  When /^I comment out gem "([^"]*)" from my Gemfile$/ do |gem_name|
54
36
  in_current_dir do
55
37
  content = File.read('Gemfile')
@@ -2,8 +2,8 @@ require 'aruba/cucumber'
2
2
 
3
3
  PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
4
4
 
5
- Before do
6
- @aruba_timeout_seconds = 3600
5
+ Aruba.configure do |config|
6
+ config.exit_timeout = Integer ENV.fetch("ARUBA_TIMEOUT") { 120 }
7
7
  end
8
8
 
9
9
  Aruba.configure do |config|
@@ -2,15 +2,21 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "3.2.11"
6
- gem "sass-rails"
5
+ gem "appraisal"
6
+ gem "aruba"
7
7
  gem "coffee-rails"
8
- gem "uglifier"
9
- gem "sqlite3", ">= 1.3.4", :platforms=>:mri
10
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.2.5", :platforms=>:jruby
11
- gem "minitest-rails"
12
- gem "therubyrhino"
8
+ gem "cucumber", "1.3.19"
13
9
  gem "jquery-rails"
10
+ gem "rake"
14
11
  gem "rspec-rails"
12
+ gem "uglifier"
13
+ gem "test-unit"
14
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
15
+ gem "jdbc-sqlite3", :platforms => :jruby
16
+ gem "therubyrhino", :platforms => :jruby
17
+ gem "jruby-openssl", :platforms => :jruby
18
+ gem "sqlite3", :platforms => :ruby
19
+ gem "rails", "~> 3.2.21"
20
+ gem "sass-rails"
15
21
 
16
- gemspec :path=>"../"
22
+ gemspec :path => "../"