Commit a7c0a5e1f0e9d69be72ea74018379534d2ee5c1d
1 parent
82a9151e
Exists in
master
and in
29 other branches
Upgrading to cucumber 0.4.x
ActionItem1279
Showing
7 changed files
with
207 additions
and
35 deletions
Show diff stats
config/environments/cucumber.rb
| 1 | +# IMPORTANT: This file was generated by Cucumber 0.4.0 | |
| 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 | + | |
| 1 | 5 | config.cache_classes = true # This must be true for Cucumber to operate correctly! |
| 2 | 6 | |
| 3 | 7 | # Log error messages when you accidentally call methods on nil. |
| ... | ... | @@ -15,7 +19,8 @@ config.action_controller.allow_forgery_protection = false |
| 15 | 19 | # ActionMailer::Base.deliveries array. |
| 16 | 20 | config.action_mailer.delivery_method = :test |
| 17 | 21 | |
| 18 | -config.gem "cucumber", :lib => false, :version => ">=0.3.11" unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber')) | |
| 19 | -config.gem "webrat", :lib => false, :version => ">=0.4.4" unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat')) | |
| 20 | -config.gem "rspec", :lib => 'spec', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec')) | |
| 21 | -config.gem "rspec-rails", :lib => 'spec/rails', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails')) | |
| 22 | +config.gem 'cucumber', :lib => false, :version => '>=0.4.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber')) | |
| 23 | +config.gem 'webrat', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat')) | |
| 24 | +config.gem 'rspec', :lib => 'spec', :version => '>=1.2.8' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec')) | |
| 25 | +config.gem 'rspec-rails', :lib => 'spec/rails', :version => '>=1.2.7.1' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails')) | |
| 26 | + | ... | ... |
features/step_definitions/webrat_steps.rb
| 1 | +# IMPORTANT: This file was generated by Cucumber 0.4.0 | |
| 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. | |
| 5 | + | |
| 1 | 6 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) |
| 2 | 7 | |
| 3 | 8 | # Commonly used webrat steps |
| ... | ... | @@ -19,21 +24,46 @@ When /^I follow "([^\"]*)"$/ do |link| |
| 19 | 24 | click_link(link) |
| 20 | 25 | end |
| 21 | 26 | |
| 27 | +When /^I follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent| | |
| 28 | + click_link_within(parent, link) | |
| 29 | +end | |
| 30 | + | |
| 22 | 31 | When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| |
| 23 | - fill_in(field, :with => value) | |
| 32 | + fill_in(field, :with => value) | |
| 33 | +end | |
| 34 | + | |
| 35 | +When /^I fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field| | |
| 36 | + fill_in(field, :with => value) | |
| 37 | +end | |
| 38 | + | |
| 39 | +# Use this to fill in an entire form with data from a table. Example: | |
| 40 | +# | |
| 41 | +# When I fill in the following: | |
| 42 | +# | Account Number | 5002 | | |
| 43 | +# | Expiry date | 2009-11-01 | | |
| 44 | +# | Note | Nice guy | | |
| 45 | +# | Wants Email? | | | |
| 46 | +# | |
| 47 | +# TODO: Add support for checkbox, select og option | |
| 48 | +# based on naming conventions. | |
| 49 | +# | |
| 50 | +When /^I fill in the following:$/ do |fields| | |
| 51 | + fields.rows_hash.each do |name, value| | |
| 52 | + When %{I fill in "#{name}" with "#{value}"} | |
| 53 | + end | |
| 24 | 54 | end |
| 25 | 55 | |
| 26 | 56 | When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field| |
| 27 | - select(value, :from => field) | |
| 57 | + select(value, :from => field) | |
| 28 | 58 | end |
| 29 | 59 | |
| 30 | 60 | # Use this step in conjunction with Rail's datetime_select helper. For example: |
| 31 | -# When I select "December 25, 2008 10:00" as the date and time | |
| 61 | +# When I select "December 25, 2008 10:00" as the date and time | |
| 32 | 62 | When /^I select "([^\"]*)" as the date and time$/ do |time| |
| 33 | 63 | select_datetime(time) |
| 34 | 64 | end |
| 35 | 65 | |
| 36 | -# Use this step when using multiple datetime_select helpers on a page or | |
| 66 | +# Use this step when using multiple datetime_select helpers on a page or | |
| 37 | 67 | # you want to specify which datetime to select. Given the following view: |
| 38 | 68 | # <%= f.label :preferred %><br /> |
| 39 | 69 | # <%= f.datetime_select :preferred %> |
| ... | ... | @@ -49,7 +79,7 @@ end |
| 49 | 79 | # Use this step in conjunction with Rail's time_select helper. For example: |
| 50 | 80 | # When I select "2:20PM" as the time |
| 51 | 81 | # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat |
| 52 | -# will convert the 2:20PM to 14:20 and then select it. | |
| 82 | +# will convert the 2:20PM to 14:20 and then select it. | |
| 53 | 83 | When /^I select "([^\"]*)" as the time$/ do |time| |
| 54 | 84 | select_time(time) |
| 55 | 85 | end |
| ... | ... | @@ -75,11 +105,11 @@ When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label| |
| 75 | 105 | end |
| 76 | 106 | |
| 77 | 107 | When /^I check "([^\"]*)"$/ do |field| |
| 78 | - check(field) | |
| 108 | + check(field) | |
| 79 | 109 | end |
| 80 | 110 | |
| 81 | 111 | When /^I uncheck "([^\"]*)"$/ do |field| |
| 82 | - uncheck(field) | |
| 112 | + uncheck(field) | |
| 83 | 113 | end |
| 84 | 114 | |
| 85 | 115 | When /^I choose "([^\"]*)"$/ do |field| |
| ... | ... | @@ -94,10 +124,46 @@ Then /^I should see "([^\"]*)"$/ do |text| |
| 94 | 124 | response.should contain(text) |
| 95 | 125 | end |
| 96 | 126 | |
| 127 | +Then /^I should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector| | |
| 128 | + within(selector) do |content| | |
| 129 | + content.should contain(text) | |
| 130 | + end | |
| 131 | +end | |
| 132 | + | |
| 133 | +Then /^I should see \/([^\/]*)\/$/ do |regexp| | |
| 134 | + regexp = Regexp.new(regexp) | |
| 135 | + response.should contain(regexp) | |
| 136 | +end | |
| 137 | + | |
| 138 | +Then /^I should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector| | |
| 139 | + within(selector) do |content| | |
| 140 | + regexp = Regexp.new(regexp) | |
| 141 | + content.should contain(regexp) | |
| 142 | + end | |
| 143 | +end | |
| 144 | + | |
| 97 | 145 | Then /^I should not see "([^\"]*)"$/ do |text| |
| 98 | 146 | response.should_not contain(text) |
| 99 | 147 | end |
| 100 | 148 | |
| 149 | +Then /^I should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector| | |
| 150 | + within(selector) do |content| | |
| 151 | + content.should_not contain(text) | |
| 152 | + end | |
| 153 | +end | |
| 154 | + | |
| 155 | +Then /^I should not see \/([^\/]*)\/$/ do |regexp| | |
| 156 | + regexp = Regexp.new(regexp) | |
| 157 | + response.should_not contain(regexp) | |
| 158 | +end | |
| 159 | + | |
| 160 | +Then /^I should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector| | |
| 161 | + within(selector) do |content| | |
| 162 | + regexp = Regexp.new(regexp) | |
| 163 | + content.should_not contain(regexp) | |
| 164 | + end | |
| 165 | +end | |
| 166 | + | |
| 101 | 167 | Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value| |
| 102 | 168 | field_labeled(field).value.should =~ /#{value}/ |
| 103 | 169 | end |
| ... | ... | @@ -105,7 +171,7 @@ end |
| 105 | 171 | Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value| |
| 106 | 172 | field_labeled(field).value.should_not =~ /#{value}/ |
| 107 | 173 | end |
| 108 | - | |
| 174 | + | |
| 109 | 175 | Then /^the "([^\"]*)" checkbox should be checked$/ do |label| |
| 110 | 176 | field_labeled(label).should be_checked |
| 111 | 177 | end |
| ... | ... | @@ -117,3 +183,7 @@ end |
| 117 | 183 | Then /^I should be on (.+)$/ do |page_name| |
| 118 | 184 | URI.parse(current_url).path.should == path_to(page_name) |
| 119 | 185 | end |
| 186 | + | |
| 187 | +Then /^show me the page$/ do | |
| 188 | + save_and_open_page | |
| 189 | +end | |
| 120 | 190 | \ No newline at end of file | ... | ... |
features/support/env.rb
| 1 | +# IMPORTANT: This file was generated by Cucumber 0.4.0 | |
| 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. | |
| 5 | + | |
| 1 | 6 | # Sets up the Rails environment for Cucumber |
| 2 | 7 | ENV["RAILS_ENV"] ||= "cucumber" |
| 3 | 8 | require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') |
| 4 | 9 | require 'cucumber/rails/world' |
| 5 | 10 | |
| 6 | -# Comment out the next line if you don't want Cucumber Unicode support | |
| 7 | -require 'cucumber/formatter/unicode' | |
| 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 | |
| 8 | 23 | |
| 9 | -# Comment out the next line if you don't want transactions to | |
| 10 | -# open/roll back around each scenario | |
| 11 | -Cucumber::Rails.use_transactional_fixtures | |
| 24 | +# 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 | +# on the way. You can make Rails rescue errors and render error pages on a | |
| 27 | +# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag. | |
| 28 | +# | |
| 29 | +# If you set this to true, Rails will rescue all errors and render error | |
| 30 | +# pages, more or less in the same way your application would behave in the | |
| 31 | +# default production environment. It's not recommended to do this for all | |
| 32 | +# of your scenarios, as this makes it hard to discover errors in your application. | |
| 33 | +ActionController::Base.allow_rescue = false | |
| 12 | 34 | |
| 13 | -# Comment out the next line if you want Rails' own error handling | |
| 14 | -# (e.g. rescue_action_in_public / rescue_responses / rescue_from) | |
| 15 | -Cucumber::Rails.bypass_rescue | |
| 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 | +require 'cucumber/rails/rspec' | |
| 16 | 40 | |
| 17 | 41 | require 'webrat' |
| 18 | - | |
| 42 | +require 'webrat/core/matchers' | |
| 19 | 43 | Webrat.configure do |config| |
| 20 | 44 | config.mode = :rails |
| 45 | + config.open_error_files = false # Set to true if you want error pages to pop up in the browser | |
| 21 | 46 | end |
| 22 | 47 | |
| 23 | -require 'cucumber/rails/rspec' | |
| 24 | -require 'webrat/core/matchers' | |
| 25 | - | |
| 26 | -# set the very basic fixtures for Noosfero | |
| 27 | -Fixtures.reset_cache | |
| 28 | -fixtures_folder = File.join(RAILS_ROOT, 'test', 'fixtures') | |
| 29 | -fixtures = ['environments', 'roles'] | |
| 30 | -Fixtures.create_fixtures(fixtures_folder, fixtures) | ... | ... |
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +if Cucumber::VERSION::STRING != '0.4.0' | |
| 2 | +warning = <<-WARNING | |
| 3 | +(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) | |
| 4 | + | |
| 5 | + (::) R O T T E N C U C U M B E R A L E R T (::) | |
| 6 | + | |
| 7 | +Your #{__FILE__.gsub(/version_check.rb$/, 'env.rb')} file was generated with Cucumber 0.4.0, | |
| 8 | +but you seem to be running Cucumber #{Cucumber::VERSION::STRING}. If you're running an older | |
| 9 | +version than #{Cucumber::VERSION::STRING}, just upgrade your gem. If you're running a newer | |
| 10 | +version than #{Cucumber::VERSION::STRING} you should: | |
| 11 | + | |
| 12 | + 1) Read http://wiki.github.com/aslakhellesoy/cucumber/upgrading | |
| 13 | + | |
| 14 | + 2) Regenerate your cucumber environment with the following command: | |
| 15 | + | |
| 16 | + ruby script/generate cucumber | |
| 17 | + | |
| 18 | +If you get prompted to replace a file, hit 'd' to see the difference. | |
| 19 | +When you're sure you have captured any personal edits, confirm that you | |
| 20 | +want to overwrite #{__FILE__.gsub(/version_check.rb$/, 'env.rb')} by pressing 'y'. Then reapply any | |
| 21 | +personal changes that may have been overwritten. | |
| 22 | + | |
| 23 | +This message will then self destruct. | |
| 24 | + | |
| 25 | +(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) | |
| 26 | +WARNING | |
| 27 | +warn(warning) | |
| 28 | +at_exit {warn(warning)} | |
| 29 | +end | |
| 0 | 30 | \ No newline at end of file | ... | ... |
lib/tasks/cucumber.rake
| 1 | +# This file was generated by | |
| 1 | 2 | $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') |
| 2 | 3 | |
| 4 | +unless ARGV.any? {|a| a =~ /^gems/} | |
| 5 | + | |
| 3 | 6 | begin |
| 4 | 7 | require 'cucumber/rake/task' |
| 5 | 8 | |
| 6 | - Cucumber::Rake::Task.new(:features) do |t| | |
| 7 | - t.fork = true | |
| 8 | - t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')] | |
| 9 | + # Use vendored cucumber binary if possible. If it's not vendored, | |
| 10 | + # Cucumber::Rake::Task will automatically use installed gem's cucumber binary | |
| 11 | + vendored_cucumber_binary = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first | |
| 12 | + | |
| 13 | + namespace :cucumber do | |
| 14 | + Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| | |
| 15 | + t.binary = vendored_cucumber_binary | |
| 16 | + t.fork = true # You may get faster startup if you set this to false | |
| 17 | + t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" | |
| 18 | + end | |
| 19 | + | |
| 20 | + Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| | |
| 21 | + t.binary = vendored_cucumber_binary | |
| 22 | + t.fork = true # You may get faster startup if you set this to false | |
| 23 | + t.cucumber_opts = "--color --tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" | |
| 24 | + end | |
| 25 | + | |
| 26 | + desc 'Run all features' | |
| 27 | + task :all => [:ok, :wip] | |
| 28 | + end | |
| 29 | + desc 'Alias for cucumber:ok' | |
| 30 | + task :cucumber => 'cucumber:ok' | |
| 31 | + | |
| 32 | + task :default => :cucumber | |
| 33 | + | |
| 34 | + task :features => :cucumber do | |
| 35 | + STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" | |
| 9 | 36 | end |
| 10 | - task :features => 'db:test:prepare' | |
| 11 | 37 | rescue LoadError |
| 12 | - desc 'Cucumber rake task not available' | |
| 13 | - task :features do | |
| 38 | + desc 'cucumber rake task not available (cucumber not installed)' | |
| 39 | + task :cucumber do | |
| 14 | 40 | abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' |
| 15 | 41 | end |
| 16 | 42 | end |
| 43 | + | |
| 44 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | + | |
| 3 | +vendored_cucumber_binary = Dir[File.join(File.dirname(__FILE__), | |
| 4 | + '..', | |
| 5 | + 'vendor', | |
| 6 | + '{gems,plugins}', | |
| 7 | + 'cucumber*', | |
| 8 | + 'bin', | |
| 9 | + 'cucumber')].first | |
| 10 | + | |
| 11 | +if vendored_cucumber_binary | |
| 12 | + load File.expand_path(vendored_cucumber_binary) | |
| 13 | +else | |
| 14 | + require 'rubygems' unless ENV['NO_RUBYGEMS'] | |
| 15 | + require 'cucumber' | |
| 16 | + load Cucumber::BINARY | |
| 17 | +end | ... | ... |