Commit 1ff2498ccd25e6b2c2776cc5f864deae4451fe2e

Authored by Vitor Baptista
1 parent 29cb6559

Upgrading cucumber to 1.1.0 and adding cucumber-rails 0.3.2.

These are the last recommended versions for Rails 2
https://github.com/cucumber/cucumber/wiki/ruby-on-rails
@@ -32,16 +32,15 @@ gem 'mysql2', '0.2.18' @@ -32,16 +32,15 @@ gem 'mysql2', '0.2.18'
32 32
33 33
34 group :cucumber do 34 group :cucumber do
35 - gem 'cucumber', '0.8.5' 35 + gem 'cucumber', '1.1.0'
  36 + gem 'cucumber-rails', '0.3.2'
36 gem 'webrat', "0.5.3" 37 gem 'webrat', "0.5.3"
37 gem 'fakeweb', '1.2.5' 38 gem 'fakeweb', '1.2.5'
38 - gem 'factory_girl', '1.2.3'  
39 end 39 end
40 40
41 group :test do 41 group :test do
42 gem "rspec", "~>1.3.1" 42 gem "rspec", "~>1.3.1"
43 gem "rspec-rails", "1.3.4" 43 gem "rspec-rails", "1.3.4"
44 - gem "factory_girl", "1.2.3"  
45 gem "shoulda", "~>2.10.1" 44 gem "shoulda", "~>2.10.1"
46 gem "jtrupiano-timecop", "0.2.1", 45 gem "jtrupiano-timecop", "0.2.1",
47 :require => "timecop" 46 :require => "timecop"
@@ -49,3 +48,7 @@ group :test do @@ -49,3 +48,7 @@ group :test do
49 gem "jferris-mocha", "0.9.5.0.1241126838", 48 gem "jferris-mocha", "0.9.5.0.1241126838",
50 :require => "mocha" 49 :require => "mocha"
51 end 50 end
  51 +
  52 +group :test, :cucumber do
  53 + gem 'factory_girl', '1.2.3'
  54 +end
@@ -13,13 +13,15 @@ GEM @@ -13,13 +13,15 @@ GEM
13 activesupport (= 2.3.14) 13 activesupport (= 2.3.14)
14 activesupport (2.3.14) 14 activesupport (2.3.14)
15 ambethia-smtp-tls (1.1.2) 15 ambethia-smtp-tls (1.1.2)
16 - builder (2.1.2)  
17 - cucumber (0.8.5)  
18 - builder (~> 2.1.2)  
19 - diff-lcs (~> 1.1.2)  
20 - gherkin (~> 2.1.4)  
21 - json_pure (~> 1.4.3)  
22 - term-ansicolor (~> 1.0.4) 16 + builder (3.0.0)
  17 + cucumber (1.1.0)
  18 + builder (>= 2.1.2)
  19 + diff-lcs (>= 1.1.2)
  20 + gherkin (~> 2.5.0)
  21 + json (>= 1.4.6)
  22 + term-ansicolor (>= 1.0.6)
  23 + cucumber-rails (0.3.2)
  24 + cucumber (>= 0.8.0)
23 daemons (1.1.9) 25 daemons (1.1.9)
24 delayed_job (2.0.6) 26 delayed_job (2.0.6)
25 daemons 27 daemons
@@ -28,8 +30,8 @@ GEM @@ -28,8 +30,8 @@ GEM
28 fakeweb (1.2.5) 30 fakeweb (1.2.5)
29 fastercsv (1.5.1) 31 fastercsv (1.5.1)
30 formtastic (0.2.5) 32 formtastic (0.2.5)
31 - gherkin (2.1.5)  
32 - trollop (~> 1.16.2) 33 + gherkin (2.5.4)
  34 + json (>= 1.4.6)
33 has_scope (0.4.2) 35 has_scope (0.4.2)
34 hoptoad_notifier (2.4.9) 36 hoptoad_notifier (2.4.9)
35 activesupport 37 activesupport
@@ -39,6 +41,7 @@ GEM @@ -39,6 +41,7 @@ GEM
39 responders (~> 0.4.3) 41 responders (~> 0.4.3)
40 jferris-mocha (0.9.5.0.1241126838) 42 jferris-mocha (0.9.5.0.1241126838)
41 rake 43 rake
  44 + json (1.7.4)
42 json_pure (1.4.6) 45 json_pure (1.4.6)
43 jtrupiano-timecop (0.2.1) 46 jtrupiano-timecop (0.2.1)
44 mime-types (1.16) 47 mime-types (1.16)
@@ -70,7 +73,6 @@ GEM @@ -70,7 +73,6 @@ GEM
70 shoulda (2.10.3) 73 shoulda (2.10.3)
71 term-ansicolor (1.0.7) 74 term-ansicolor (1.0.7)
72 thoughtbot-clearance (0.8.2) 75 thoughtbot-clearance (0.8.2)
73 - trollop (1.16.2)  
74 webrat (0.5.3) 76 webrat (0.5.3)
75 nokogiri (>= 1.2.0) 77 nokogiri (>= 1.2.0)
76 rack (>= 1.0) 78 rack (>= 1.0)
@@ -84,7 +86,8 @@ PLATFORMS @@ -84,7 +86,8 @@ PLATFORMS
84 DEPENDENCIES 86 DEPENDENCIES
85 ambethia-smtp-tls (= 1.1.2) 87 ambethia-smtp-tls (= 1.1.2)
86 bundler (~> 1.1.5) 88 bundler (~> 1.1.5)
87 - cucumber (= 0.8.5) 89 + cucumber (= 1.1.0)
  90 + cucumber-rails (= 0.3.2)
88 delayed_job (= 2.0.6) 91 delayed_job (= 2.0.6)
89 factory_girl (= 1.2.3) 92 factory_girl (= 1.2.3)
90 fakeweb (= 1.2.5) 93 fakeweb (= 1.2.5)
config/cucumber.yml 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +<%
  2 +rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
  3 +rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
  4 +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
  5 +%>
  6 +default: <%= std_opts %> features
  7 +wip: --tags @wip:3 --wip features
  8 +rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
config/environments/cucumber.rb
1 -# IMPORTANT: This file was generated by Cucumber 0.4.2  
2 # Edit at your own peril - it's recommended to regenerate this file 1 # Edit at your own peril - it's recommended to regenerate this file
3 # in the future when you upgrade to a newer version of Cucumber. 2 # in the future when you upgrade to a newer version of Cucumber.
4 3
5 -config.cache_classes = true # This must be true for Cucumber to operate correctly! 4 +# IMPORTANT: Setting config.cache_classes to false is known to
  5 +# break Cucumber's use_transactional_fixtures method.
  6 +# For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
  7 +config.cache_classes = true
6 8
7 # Log error messages when you accidentally call methods on nil. 9 # Log error messages when you accidentally call methods on nil.
8 config.whiny_nils = true 10 config.whiny_nils = true
@@ -19,9 +21,7 @@ config.action_controller.allow_forgery_protection = false @@ -19,9 +21,7 @@ config.action_controller.allow_forgery_protection = false
19 # ActionMailer::Base.deliveries array. 21 # ActionMailer::Base.deliveries array.
20 config.action_mailer.delivery_method = :test 22 config.action_mailer.delivery_method = :test
21 23
22 -  
23 HOST = "localhost" 24 HOST = "localhost"
24 AUTHORIZE_NET_API_LOGIN_ID = '' 25 AUTHORIZE_NET_API_LOGIN_ID = ''
25 AUTHORIZE_NET_TRANSACTION_KEY = '' 26 AUTHORIZE_NET_TRANSACTION_KEY = ''
26 -ActiveMerchant::Billing::Base.gateway_mode = :test  
27 27
features/step_definitions/factory_girl_steps.rb
@@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
1 -Given /^the following (.*) exists?:$/ do |factory, table|  
2 - factory = factory.singularize.gsub(' ','_')  
3 - table.hashes.each do |attributes|  
4 - Factory(factory, attributes)  
5 - end  
6 -end  
7 -  
8 -Factory.factories.each do |name, factory|  
9 - if factory.build_class.respond_to?(:columns)  
10 - factory.build_class.columns.each do |column|  
11 - Given %{^an? #{name.to_s.humanize.downcase} exists with an? #{column.name.humanize.downcase} of "([^"]*)"$} do |value|  
12 - Factory(name, column.name => value)  
13 - end  
14 -  
15 - Given %{^an? #{name.to_s.humanize.downcase} exists with an? #{column.name.humanize.downcase} of "([^"]*)" and a "([^"]*)" of "([^"]*)"$} do |first_value, second_column, second_value|  
16 - Factory(name, column.name => value, second_column.downcase.to_sym => second_value)  
17 - end  
18 - end  
19 - end  
20 -  
21 - Given /^an? #{name} exists$/ do  
22 - Factory(name)  
23 - end  
24 -  
25 - Given /^(\d+) #{name.to_s.humanize.downcase.pluralize} exist with an? ([^"]*) of "([^"]*)"$/ do |count, attr, value|  
26 - count.to_i.times { Factory(name, attr.gsub(' ', '_') => value) }  
27 - end  
28 -  
29 - Given %r{^(\d+) #{name.to_s.humanize.downcase.pluralize} exist$} do |count|  
30 - count.to_i.times { Factory(name) }  
31 - end  
32 -end  
33 -  
features/support/env.rb
1 -# IMPORTANT: This file was generated by Cucumber 0.4.2  
2 -# Edit at your own peril - it's recommended to regenerate this file  
3 -# in the future when you upgrade to a newer version of Cucumber.  
4 -# Consider adding your own code to a new file instead of editing this one. 1 +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
  2 +# It is recommended to regenerate this file in the future when you upgrade to a
  3 +# newer version of cucumber-rails. Consider adding your own code to a new file
  4 +# instead of editing this one. Cucumber will automatically load all features/**/*.rb
  5 +# files.
5 6
6 -# Sets up the Rails environment for Cucumber  
7 ENV["RAILS_ENV"] ||= "cucumber" 7 ENV["RAILS_ENV"] ||= "cucumber"
8 require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') 8 require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
  9 +
  10 +require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
  11 +require 'cucumber/rails/rspec'
9 require 'cucumber/rails/world' 12 require 'cucumber/rails/world'
  13 +require 'cucumber/rails/active_record'
  14 +require 'cucumber/web/tableish'
  15 +
  16 +require 'webrat'
  17 +require 'webrat/core/matchers'
  18 +
  19 +Webrat.configure do |config|
  20 + config.mode = :rails
  21 + config.open_error_files = false # Set to true if you want error pages to pop up in the browser
  22 +end
10 23
11 -# If you set this to true, each scenario will run in a database transaction.  
12 -# You can still turn off transactions on a per-scenario basis, simply tagging  
13 -# a feature or scenario with the @no-txn tag.  
14 -#  
15 -# If you set this to false, transactions will be off for all scenarios,  
16 -# regardless of whether you use @no-txn or not.  
17 -#  
18 -# Beware that turning transactions off will leave data in your database  
19 -# after each scenario, which can lead to hard-to-debug failures in  
20 -# subsequent scenarios. If you do this, we recommend you create a Before  
21 -# block that will explicitly put your database in a known state.  
22 -Cucumber::Rails::World.use_transactional_fixtures = true  
23 24
24 # If you set this to false, any error raised from within your app will bubble 25 # If you set this to false, any error raised from within your app will bubble
25 # up to your step definition and out to cucumber unless you catch it somewhere 26 # up to your step definition and out to cucumber unless you catch it somewhere
@@ -32,20 +33,25 @@ Cucumber::Rails::World.use_transactional_fixtures = true @@ -32,20 +33,25 @@ Cucumber::Rails::World.use_transactional_fixtures = true
32 # of your scenarios, as this makes it hard to discover errors in your application. 33 # of your scenarios, as this makes it hard to discover errors in your application.
33 ActionController::Base.allow_rescue = false 34 ActionController::Base.allow_rescue = false
34 35
35 -require 'cucumber'  
36 -# Comment out the next line if you don't want Cucumber Unicode support  
37 -require 'cucumber/formatter/unicode'  
38 -require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)  
39 -  
40 -require 'webrat'  
41 -require 'webrat/core/matchers'  
42 -Webrat.configure do |config|  
43 - config.mode = :rails  
44 - config.open_error_files = false # Set to true if you want error pages to pop up in the browser 36 +# If you set this to true, each scenario will run in a database transaction.
  37 +# You can still turn off transactions on a per-scenario basis, simply tagging
  38 +# a feature or scenario with the @no-txn tag. If you are using Capybara,
  39 +# tagging with @culerity or @javascript will also turn transactions off.
  40 +#
  41 +# If you set this to false, transactions will be off for all scenarios,
  42 +# regardless of whether you use @no-txn or not.
  43 +#
  44 +# Beware that turning transactions off will leave data in your database
  45 +# after each scenario, which can lead to hard-to-debug failures in
  46 +# subsequent scenarios. If you do this, we recommend you create a Before
  47 +# block that will explicitly put your database in a known state.
  48 +Cucumber::Rails::World.use_transactional_fixtures = true
  49 +# How to clean your database when transactions are turned off. See
  50 +# http://github.com/bmabey/database_cleaner for more info.
  51 +if defined?(ActiveRecord::Base)
  52 + begin
  53 + require 'database_cleaner'
  54 + DatabaseCleaner.strategy = :truncation
  55 + rescue LoadError => ignore_if_database_cleaner_not_present
  56 + end
45 end 57 end
46 -  
47 -require 'factory_girl/step_definitions'  
48 -FakeWeb.allow_net_connect = false  
49 -  
50 -Dir[File.join(Rails.root, "test", "support", "**", "*.rb")].each { |file| require(file) }  
51 -  
lib/tasks/cucumber.rake
1 -$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') 1 +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
  2 +# It is recommended to regenerate this file in the future when you upgrade to a
  3 +# newer version of cucumber-rails. Consider adding your own code to a new file
  4 +# instead of editing this one. Cucumber will automatically load all features/**/*.rb
  5 +# files.
  6 +
  7 +
  8 +unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
  9 +
  10 +vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
  11 +$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
2 12
3 begin 13 begin
4 require 'cucumber/rake/task' 14 require 'cucumber/rake/task'
5 15
6 - Cucumber::Rake::Task.new(:features) do |t|  
7 - t.fork = true  
8 - t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')] 16 + namespace :cucumber do
  17 + Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
  18 + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
  19 + t.fork = true # You may get faster startup if you set this to false
  20 + t.profile = 'default'
  21 + end
  22 +
  23 + Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
  24 + t.binary = vendored_cucumber_bin
  25 + t.fork = true # You may get faster startup if you set this to false
  26 + t.profile = 'wip'
  27 + end
  28 +
  29 + Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
  30 + t.binary = vendored_cucumber_bin
  31 + t.fork = true # You may get faster startup if you set this to false
  32 + t.profile = 'rerun'
  33 + end
  34 +
  35 + desc 'Run all features'
  36 + task :all => [:ok, :wip]
  37 + end
  38 + desc 'Alias for cucumber:ok'
  39 + task :cucumber => 'cucumber:ok'
  40 +
  41 + task :default => :cucumber
  42 +
  43 + task :features => :cucumber do
  44 + STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
9 end 45 end
10 - task :features => 'db:test:prepare'  
11 rescue LoadError 46 rescue LoadError
12 - desc 'Cucumber rake task not available'  
13 - task :features do 47 + desc 'cucumber rake task not available (cucumber not installed)'
  48 + task :cucumber do
14 abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' 49 abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
15 end 50 end
16 end 51 end
  52 +
  53 +end
spec/factories.rb
1 -Factory.define(:item) do |f|  
2 - f.sequence(:data) { |i| "Item #{i}" }  
3 -end  
4 -  
5 -  
6 Factory.define(:question) do |f| 1 Factory.define(:question) do |f|
7 f.sequence(:name) { |i| "Name #{i}" } 2 f.sequence(:name) { |i| "Name #{i}" }
8 f.site {|s| s.association(:user)} 3 f.site {|s| s.association(:user)}
@@ -99,16 +94,3 @@ Factory.define(:appearance_new_user, :parent =&gt; :appearance) do |f| @@ -99,16 +94,3 @@ Factory.define(:appearance_new_user, :parent =&gt; :appearance) do |f|
99 f.voter {|a| Factory.build(:visitor, :site => a.question.site)} 94 f.voter {|a| Factory.build(:visitor, :site => a.question.site)}
100 end 95 end
101 96
102 -Factory.sequence :email do |n|  
103 - "user#{n}@example.com"  
104 -end  
105 -  
106 -Factory.define :user do |user|  
107 - user.email { Factory.next :email }  
108 - user.password { "password" }  
109 - user.password_confirmation { "password" }  
110 -end  
111 -  
112 -Factory.define :email_confirmed_user, :parent => :user do |user|  
113 - user.email_confirmed { true }  
114 -end  
vendor/cache/builder-2.1.2.gem
No preview for this file type
vendor/cache/builder-3.0.0.gem 0 → 100644
No preview for this file type
vendor/cache/cucumber-0.8.5.gem
No preview for this file type
vendor/cache/cucumber-1.1.0.gem 0 → 100644
No preview for this file type
vendor/cache/cucumber-rails-0.3.2.gem 0 → 100644
No preview for this file type
vendor/cache/gherkin-2.1.5.gem
No preview for this file type
vendor/cache/gherkin-2.5.4.gem 0 → 100644
No preview for this file type
vendor/cache/json-1.7.4.gem 0 → 100644
No preview for this file type
vendor/cache/trollop-1.16.2.gem
No preview for this file type