Permalink
Browse files

WIP - Drop Rails 2

  • Loading branch information...
1 parent ce7cf97 commit c179947b3ad90271b4d1536cf2b15fafacda0592 @mattyoho committed Oct 11, 2011
View
@@ -1,5 +1,4 @@
tmp
pkg
.bundle
-/Gemfile
*.lock
View
17 Gemfile
@@ -0,0 +1,17 @@
+source "http://rubygems.org"
+
+lib = File.expand_path("../lib", __FILE__)
+$:.unshift lib unless $:.include?(lib)
+
+gemspec
+
+gem "rake", "~> 0.9.2"
+gem "rspec", "~> 2.6.0"
+gem "cucumber", "~> 1.1.0"
+gem "aruba", "~> 0.4.6"
+
+gem "activesupport", "~> 3.0.10"
+gem "actionpack", "~> 3.0.10"
+
+gem "ruby-debug", "~> 0.10.4", :platforms => :mri_18
+gem "ruby-debug19", "~> 0.11.6", :platforms => :mri_19
View
@@ -1,22 +0,0 @@
-source "http://rubygems.org"
-
-lib = File.expand_path('../lib', __FILE__)
-$:.unshift lib unless $:.include?(lib)
-
-gemspec
-
-gem "rake", "0.8.7"
-gem "aruba", "~> 0.2.3"
-gem "capybara", "~> 0.3.9"
-gem "cucumber", "~> 0.9.3"
-gem "cucumber-rails", "~> 0.3.2"
-gem "database_cleaner", "~> 0.5.2"
-gem "rails", "~> 2.3.10"
-gem "rspec", "~> 2.0.1"
-gem "sqlite3-ruby", "~> 1.3.0"
-gem "will_paginate", "~> 2.3.14"
-
-gem "ruby-debug", "~> 0.10.3", :platforms => :mri_18
-gem "ruby-debug19", "~> 0.11.6", :platforms => :mri_19
-
-gem "test-unit", "1.2.3", :platforms => :ruby_19
View
@@ -1,22 +0,0 @@
-source "http://rubygems.org"
-
-lib = File.expand_path('../lib', __FILE__)
-$:.unshift lib unless $:.include?(lib)
-
-gemspec
-
-gem "rake", "0.8.7"
-gem "aruba", "~> 0.2.3"
-gem "capybara", "~> 0.4.0"
-gem "cucumber", "~> 0.9.3"
-gem "cucumber-rails", "~> 0.3.2"
-gem "database_cleaner", "~> 0.6.0"
-gem "rails", "~> 3.0.1"
-gem "rspec-rails", "~> 2.0.1"
-gem "sqlite3-ruby", "~> 1.3.0"
-gem "will_paginate", "~> 3.0.2"
-
-gem "ruby-debug", "~> 0.10.3", :platforms => :mri_18
-gem "ruby-debug19", "~> 0.11.6", :platforms => :mri_19
-
-gem "test-unit", "1.2.3", :platforms => :ruby_19
View
141 Rakefile
@@ -1,3 +1,6 @@
+require 'bundler'
+Bundler.setup
+
begin
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
@@ -7,87 +10,67 @@ begin
t.rspec_opts = %w(--format=progress --color)
end
- Cucumber::Rake::Task.new(:cucumber) do |t|
+ Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format progress}
end
-
- Cucumber::Rake::Task.new('cucumber:rails2') do |t|
- t.cucumber_opts = %w{--format progress --tags ~@rails3}
- end
-
- Cucumber::Rake::Task.new('cucumber:rails3') do |t|
- t.cucumber_opts = %w{--format progress --tags ~@rails2}
- end
rescue LoadError
puts "Warning: RSpec or Cucumber is not installed"
end
task :default => [:spec, :cucumber]
-task :rails2 => [:spec, 'cucumber:rails2']
-task :rails3 => [:spec, 'cucumber:rails3']
-
-namespace :generate do
- namespace :rails3 do
- desc 'Generate Rails 3 app for integration testing'
- task :app do
- unless File.directory? './tmp/example_app'
- template_dir = '../../templates/rails3/'
- system 'rails new ./tmp/example_app --skip-gemfile'
+directory "tmp/example_app"
- Dir.chdir("./tmp/example_app/") do
- system 'rails generate cucumber:install --capybara'
-
- ['Gemfile',
- 'features/step_definitions/custom_steps.rb'].each do |file|
- system "cp #{template_dir + file} ./#{file}"
- end
+module BasicAssumptionRakeUtils
+ TEMPLATE_DIR = 'templates/rails/'
+end
- system "bundle install"
- end
- end
+file "tmp/example_app/Gemfile" => "tmp/example_app" do
+ open("tmp/example_app/Gemfile", "w") do |gemfile|
+ open("#{BasicAssumptionRakeUtils::TEMPLATE_DIR}Gemfile") do |template|
+ gemfile << template.read
end
+ end
+end
- desc 'Generate scaffolds, etc'
- task :custom => ['generate:rails3:app'] do
- Dir.chdir("./tmp/example_app/") do
- system "rake rails:template LOCATION='../../templates/generate_custom.rb'"
- end
+namespace :example_app do
+ task :bundle => "tmp/example_app/Gemfile" do
+ Bundler.with_clean_env do
+ system 'cd ./tmp/example_app/ && bundle'
end
end
- namespace :rails2 do
- desc 'Generate Rails 2.3 app for integration testing'
- task :app do
- unless File.directory? './tmp/example_app'
- template_dir = '../../templates/rails2/'
-
- system 'rails ./tmp/example_app'
-
- Dir.chdir("./tmp/example_app/") do
- system 'script/generate cucumber'
-
- ['Gemfile',
- 'config/boot.rb',
- 'config/preinitializer.rb',
- 'features/step_definitions/custom_steps.rb'].each do |file|
- system "cp #{template_dir + file} ./#{file}"
- end
-
- system "bundle install"
- end
+ task :generate => "example_app:bundle" do
+ Bundler.with_clean_env do
+ Dir.chdir("./tmp/example_app/") do
+ system 'bundle exec rails new ./ -JSGT --skip-gemfile --skip-bundle'
+ system 'bundle exec rails generate cucumber:install --capybara'
+ system 'bundle exec rails generate cucumber_rails_training_wheels:install'
end
end
+ end
- desc 'Generate scaffolds, etc'
- task :custom => ['generate:rails2:app'] do
+ task :customize => 'example_app:generate' do
+ Bundler.with_clean_env do
Dir.chdir("./tmp/example_app/") do
- system "rake rails:template LOCATION='../../templates/generate_custom.rb'"
+ system "bundle exec rake rails:template LOCATION='../../templates/generate_custom.rb'"
end
+
+ custom_steps = 'features/step_definitions/custom_steps.rb'
+ system "cp #{BasicAssumptionRakeUtils::TEMPLATE_DIR}#{custom_steps} tmp/example_app/#{custom_steps}"
end
end
end
+desc 'Generate customized Rails 3 app for integration testing'
+task :init => [:clobber, 'example_app:customize']
+
+desc 'Remove all generated test files'
+task :clobber do
+ rm_rf './tmp'
+ rm_rf './pkg'
+end
+
namespace :gem do
desc 'Builds the gem from the current gemspec'
task :build do
@@ -97,23 +80,9 @@ namespace :gem do
end
end
-namespace :bundle do
- namespace :install do
- desc "Installs the dependencies listed in Gemfile.rails2"
- task :rails2 do
- system 'cp Gemfile.rails2 Gemfile && bundle install'
- end
-
- desc "Installs the dependencies listed in Gemfile.rails3"
- task :rails3 do
- system 'cp Gemfile.rails3 Gemfile && bundle install'
- end
- end
-end
-
namespace :rvm do
desc "Creates a gemset and outputs the command to use it"
- task :gemset do
+ task :gemset => "tmp/example_app" do
if `which rvm` =~ /\w+/
system "rvm gemset create basic_assumption"
@@ -128,31 +97,3 @@ namespace :rvm do
end
end
-namespace :setup do
- desc 'Sets up the test environment for Rails 2.3'
- task :rails2 => ['bundle:install:rails2', 'generate:rails2:custom']
-
- desc 'Sets up the test environment for Rails 3'
- task :rails3 => ['bundle:install:rails3', 'generate:rails3:custom']
-end
-
-namespace :init do
- desc 'Sets up and runs the spec and cuke suites using Rails 2.3'
- task :rails2 => [:clobber, 'setup:rails2']
-
- desc 'Sets up and runs the spec and cuke suites using Rails 3'
- task :rails3 => [:clobber, 'setup:rails3']
-end
-
-namespace :clobber do
- desc 'Remove generated Rails app'
- task :app do
- rm_rf './tmp/example_app'
- end
-end
-
-desc 'Remove generated code'
-task :clobber do
- rm_rf './tmp'
- rm_rf './pkg'
-end
@@ -19,7 +19,7 @@ Feature: Rails Controllers Assume Find By Default
When I view the widget
Then I should see "foobar"
"""
- When I run "cucumber features/widget_is_viewed_by_visitor.feature"
+ When I run `bundle exec cucumber features/widget_is_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -19,7 +19,7 @@ Feature: Rails Controllers Can Make Assumptions
When I view the widget
Then I should see "foobar"
"""
- When I run "cucumber features/widget_is_viewed_by_visitor.feature"
+ When I run `cucumber features/widget_is_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -25,7 +25,7 @@ Feature: Rails Controllers Inherit Assumptions
When I view the derived widget
Then I should see "foobar"
"""
- When I run "cucumber features/derived_widget_is_viewed_by_visitor.feature"
+ When I run `cucumber features/derived_widget_is_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -36,7 +36,7 @@ Feature: Restful Rails Create Action Is Correct
And I press "Create"
Then I should see "created"
"""
- When I run "cucumber features/widget_is_created_by_visitor.feature"
+ When I run `cucumber features/widget_is_created_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -41,7 +41,7 @@ Feature: Restful Rails Destroy Action Is Correct
Then I should not see "sprocket"
And I should see "spacely"
"""
- When I run "cucumber features/widget_is_deleted_by_visitor.feature"
+ When I run `cucumber features/widget_is_deleted_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -20,7 +20,7 @@ Feature: Restful Rails Edit Action Is Correct
When I edit the widget
Then I should see "Editing sprocket"
"""
- When I run "cucumber features/widget_is_edited_by_visitor.feature"
+ When I run `cucumber features/widget_is_edited_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -35,7 +35,7 @@ Feature: Restful Rails Index Action Is Correct
And I should see "George"
And I should see "Ringo"
"""
- When I run "cucumber features/all_widgets_are_viewed_by_visitor.feature"
+ When I run `cucumber features/all_widgets_are_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -70,7 +70,7 @@ Feature: Restful Rails Index Action Is Correct
And I should see "Theodore"
And I should see "New widget"
"""
- When I run "cucumber features/all_widgets_and_a_new_widget_are_viewed_by_visitor.feature"
+ When I run `cucumber features/all_widgets_and_a_new_widget_are_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -104,7 +104,7 @@ Feature: Restful Rails Index Action Is Correct
And I should see "Theodore"
And I should see "sprocket"
"""
- When I run "cucumber features/all_widgets_and_a_singular_widget_are_viewed_by_visitor.feature"
+ When I run `cucumber features/all_widgets_and_a_singular_widget_are_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -43,7 +43,7 @@ Feature: Restful Rails Index Action With Pagination Is Correct
And I should not see "Jason"
And I should not see "Damian"
"""
- When I run "cucumber features/first_half_of_widgets_are_viewed_by_visitor.feature"
+ When I run `cucumber features/first_half_of_widgets_are_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -75,7 +75,7 @@ Feature: Restful Rails Index Action With Pagination Is Correct
And I should not see "Jason"
And I should not see "Damian"
"""
- When I run "cucumber features/second_half_of_widgets_are_viewed_by_visitor.feature"
+ When I run `cucumber features/second_half_of_widgets_are_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -21,7 +21,7 @@ Feature: Restful Rails New Action Is Correct
When I go to the new widget page
Then I should see "Widget is new"
"""
- When I run "cucumber features/widget_is_newed_by_visitor.feature"
+ When I run `cucumber features/widget_is_newed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -20,7 +20,7 @@ Feature: Restful Rails Show Action Is Correct
When I view the widget
Then I should see "sprocket"
"""
- When I run "cucumber features/widget_is_viewed_by_visitor.feature"
+ When I run `cucumber features/widget_is_viewed_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -35,7 +35,7 @@ Feature: Restful Rails Update Action Is Correct
And I press "Update"
Then I should see "after"
"""
- When I run "cucumber features/widget_is_updated_by_visitor.feature"
+ When I run `cucumber features/widget_is_updated_by_visitor.feature` with a clean Bundler environment
Then the output should contain:
"""
1 scenario (1 passed)
@@ -21,7 +21,7 @@ Feature: RSpec Matcher For Assume
it { should_not assume(:sprocket) }
end
"""
- When I run "bundle exec rspec spec/controllers/widgets_controller_spec.rb"
+ When I run `bundle exec rspec spec/controllers/widgets_controller_spec.rb` with a clean Bundler environment
Then the output should contain:
"""
2 examples, 0 failures
Oops, something went wrong.

0 comments on commit c179947

Please sign in to comment.