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
Gemfile
... ... @@ -32,16 +32,15 @@ gem 'mysql2', '0.2.18'
32 32  
33 33  
34 34 group :cucumber do
35   - gem 'cucumber', '0.8.5'
  35 + gem 'cucumber', '1.1.0'
  36 + gem 'cucumber-rails', '0.3.2'
36 37 gem 'webrat', "0.5.3"
37 38 gem 'fakeweb', '1.2.5'
38   - gem 'factory_girl', '1.2.3'
39 39 end
40 40  
41 41 group :test do
42 42 gem "rspec", "~>1.3.1"
43 43 gem "rspec-rails", "1.3.4"
44   - gem "factory_girl", "1.2.3"
45 44 gem "shoulda", "~>2.10.1"
46 45 gem "jtrupiano-timecop", "0.2.1",
47 46 :require => "timecop"
... ... @@ -49,3 +48,7 @@ group :test do
49 48 gem "jferris-mocha", "0.9.5.0.1241126838",
50 49 :require => "mocha"
51 50 end
  51 +
  52 +group :test, :cucumber do
  53 + gem 'factory_girl', '1.2.3'
  54 +end
... ...
Gemfile.lock
... ... @@ -13,13 +13,15 @@ GEM
13 13 activesupport (= 2.3.14)
14 14 activesupport (2.3.14)
15 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 25 daemons (1.1.9)
24 26 delayed_job (2.0.6)
25 27 daemons
... ... @@ -28,8 +30,8 @@ GEM
28 30 fakeweb (1.2.5)
29 31 fastercsv (1.5.1)
30 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 35 has_scope (0.4.2)
34 36 hoptoad_notifier (2.4.9)
35 37 activesupport
... ... @@ -39,6 +41,7 @@ GEM
39 41 responders (~> 0.4.3)
40 42 jferris-mocha (0.9.5.0.1241126838)
41 43 rake
  44 + json (1.7.4)
42 45 json_pure (1.4.6)
43 46 jtrupiano-timecop (0.2.1)
44 47 mime-types (1.16)
... ... @@ -70,7 +73,6 @@ GEM
70 73 shoulda (2.10.3)
71 74 term-ansicolor (1.0.7)
72 75 thoughtbot-clearance (0.8.2)
73   - trollop (1.16.2)
74 76 webrat (0.5.3)
75 77 nokogiri (>= 1.2.0)
76 78 rack (>= 1.0)
... ... @@ -84,7 +86,8 @@ PLATFORMS
84 86 DEPENDENCIES
85 87 ambethia-smtp-tls (= 1.1.2)
86 88 bundler (~> 1.1.5)
87   - cucumber (= 0.8.5)
  89 + cucumber (= 1.1.0)
  90 + cucumber-rails (= 0.3.2)
88 91 delayed_job (= 2.0.6)
89 92 factory_girl (= 1.2.3)
90 93 fakeweb (= 1.2.5)
... ...
config/cucumber.yml 0 → 100644
... ... @@ -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 1 # Edit at your own peril - it's recommended to regenerate this file
3 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 9 # Log error messages when you accidentally call methods on nil.
8 10 config.whiny_nils = true
... ... @@ -19,9 +21,7 @@ config.action_controller.allow_forgery_protection = false
19 21 # ActionMailer::Base.deliveries array.
20 22 config.action_mailer.delivery_method = :test
21 23  
22   -
23 24 HOST = "localhost"
24 25 AUTHORIZE_NET_API_LOGIN_ID = ''
25 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   -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 7 ENV["RAILS_ENV"] ||= "cucumber"
8 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 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 25 # If you set this to false, any error raised from within your app will bubble
25 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 33 # of your scenarios, as this makes it hard to discover errors in your application.
33 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 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 13 begin
4 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 45 end
10   - task :features => 'db:test:prepare'
11 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 49 abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
15 50 end
16 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 1 Factory.define(:question) do |f|
7 2 f.sequence(:name) { |i| "Name #{i}" }
8 3 f.site {|s| s.association(:user)}
... ... @@ -99,16 +94,3 @@ Factory.define(:appearance_new_user, :parent =&gt; :appearance) do |f|
99 94 f.voter {|a| Factory.build(:visitor, :site => a.question.site)}
100 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