Commit 268643c7de5200a34b7b84b128b344083a3be556
Committed by
Daniela Feitosa
1 parent
82ae16fc
Exists in
master
and in
22 other branches
changing cucumber version and adding capybara to Gemfile
Showing
8 changed files
with
150 additions
and
103 deletions
Show diff stats
Gemfile
1 | 1 | source :rubygems |
2 | -gem 'cucumber', '0.4.0' | |
3 | -gem 'webrat', '0.5.1' | |
4 | -gem 'rspec', '1.2.9' | |
5 | -gem 'rspec-rails', '1.2.9' | |
6 | -gem 'Selenium', '>= 1.1.14' | |
7 | -gem 'selenium-client', '>= 1.2.17' | |
8 | -gem 'database_cleaner' | |
2 | + | |
9 | 3 | gem 'exception_notification', '1.0.20090728' |
10 | 4 | gem 'system_timer' |
11 | 5 | |
6 | +group :test do | |
7 | + gem 'rspec', '1.2.9' | |
8 | + gem 'rspec-rails', '1.2.9' | |
9 | +end | |
10 | + | |
11 | +group :cucumber do | |
12 | + gem 'cucumber-rails', '0.3.2' | |
13 | + gem 'capybara', '1.1.1' | |
14 | + gem 'cucumber', '1.1.0' | |
15 | + gem 'database_cleaner' | |
16 | +end | |
17 | + | |
12 | 18 | def program(name) |
13 | 19 | unless system("which #{name} > /dev/null") |
14 | 20 | puts "W: Program #{name} is needed, but was not found in your PATH" | ... | ... |
Gemfile.lock
1 | 1 | GEM |
2 | 2 | remote: http://rubygems.org/ |
3 | 3 | specs: |
4 | - Selenium (1.1.14) | |
5 | - builder (3.0.0) | |
6 | - cucumber (0.4.0) | |
4 | + builder (3.1.4) | |
5 | + capybara (1.1.1) | |
6 | + mime-types (>= 1.16) | |
7 | + nokogiri (>= 1.3.3) | |
8 | + rack (>= 1.0.0) | |
9 | + rack-test (>= 0.5.4) | |
10 | + selenium-webdriver (~> 2.0) | |
11 | + xpath (~> 0.1.4) | |
12 | + childprocess (0.3.6) | |
13 | + ffi (~> 1.0, >= 1.0.6) | |
14 | + cucumber (1.1.0) | |
7 | 15 | builder (>= 2.1.2) |
8 | 16 | diff-lcs (>= 1.1.2) |
9 | - polyglot (>= 0.2.9) | |
10 | - term-ansicolor (>= 1.0.3) | |
11 | - treetop (>= 1.4.2) | |
12 | - database_cleaner (0.7.0) | |
17 | + gherkin (~> 2.5.0) | |
18 | + json (>= 1.4.6) | |
19 | + term-ansicolor (>= 1.0.6) | |
20 | + cucumber-rails (0.3.2) | |
21 | + cucumber (>= 0.8.0) | |
22 | + database_cleaner (0.9.1) | |
13 | 23 | diff-lcs (1.1.3) |
14 | 24 | exception_notification (1.0.20090728) |
15 | - nokogiri (1.5.0) | |
16 | - polyglot (0.3.3) | |
17 | - rack (1.3.5) | |
25 | + ffi (1.2.0) | |
26 | + gherkin (2.5.4) | |
27 | + json (>= 1.4.6) | |
28 | + json (1.7.5) | |
29 | + libwebsocket (0.1.6.1) | |
30 | + websocket | |
31 | + mime-types (1.19) | |
32 | + multi_json (1.3.7) | |
33 | + nokogiri (1.5.5) | |
34 | + rack (1.1.0) | |
35 | + rack-test (0.6.2) | |
36 | + rack (>= 1.0) | |
18 | 37 | rspec (1.2.9) |
19 | 38 | rspec-rails (1.2.9) |
20 | 39 | rack (>= 1.0.0) |
21 | 40 | rspec (>= 1.2.9) |
22 | - selenium-client (1.2.18) | |
41 | + rubyzip (0.9.9) | |
42 | + selenium-webdriver (2.26.0) | |
43 | + childprocess (>= 0.2.5) | |
44 | + libwebsocket (~> 0.1.3) | |
45 | + multi_json (~> 1.0) | |
46 | + rubyzip | |
23 | 47 | system_timer (1.2.4) |
24 | 48 | term-ansicolor (1.0.7) |
25 | - treetop (1.4.10) | |
26 | - polyglot | |
27 | - polyglot (>= 0.3.1) | |
28 | - webrat (0.5.1) | |
29 | - nokogiri (>= 1.2.0) | |
30 | - rack (>= 1.0) | |
49 | + websocket (1.0.4) | |
50 | + xpath (0.1.4) | |
51 | + nokogiri (~> 1.3) | |
31 | 52 | |
32 | 53 | PLATFORMS |
33 | 54 | ruby |
34 | 55 | |
35 | 56 | DEPENDENCIES |
36 | - Selenium (>= 1.1.14) | |
37 | - cucumber (= 0.4.0) | |
57 | + capybara (= 1.1.1) | |
58 | + cucumber (= 1.1.0) | |
59 | + cucumber-rails (= 0.3.2) | |
38 | 60 | database_cleaner |
39 | 61 | exception_notification (= 1.0.20090728) |
40 | 62 | rspec (= 1.2.9) |
41 | 63 | rspec-rails (= 1.2.9) |
42 | - selenium-client (>= 1.2.17) | |
43 | 64 | system_timer |
44 | - webrat (= 0.5.1) | ... | ... |
config/cucumber.yml
1 | -default: --tags ~@selenium,~@wip --exclude features/support/selenium.rb --exclude features/step_definitions/selenium_steps.rb -r features/support -r features/step_definitions | |
2 | -selenium: --tags @selenium,~@wip -r features/support -r features/step_definitions | |
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.0 | |
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 |
... | ... | @@ -18,3 +20,8 @@ config.action_controller.allow_forgery_protection = false |
18 | 20 | # The :test delivery method accumulates sent emails in the |
19 | 21 | # ActionMailer::Base.deliveries array. |
20 | 22 | config.action_mailer.delivery_method = :test |
23 | + | |
24 | +config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails')) | |
25 | +config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner')) | |
26 | +config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(File.join(Rails.root, 'vendor/plugins/capybara')) | |
27 | + | ... | ... |
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. | |
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 | - | |
9 | -# Start/stop Solr | |
10 | -if not $cucumber_env_loaded | |
11 | - abort unless system 'rake solr:start' | |
12 | - at_exit { system 'rake solr:stop' } | |
13 | - $cucumber_env_loaded = true | |
14 | -end | |
15 | - | |
16 | 8 | require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') |
17 | -require 'cucumber/rails/world' | |
18 | - | |
19 | -# If you set this to true, each scenario will run in a database transaction. | |
20 | -# You can still turn off transactions on a per-scenario basis, simply tagging | |
21 | -# a feature or scenario with the @no-txn tag. | |
22 | -# | |
23 | -# If you set this to false, transactions will be off for all scenarios, | |
24 | -# regardless of whether you use @no-txn or not. | |
25 | -# | |
26 | -# Beware that turning transactions off will leave data in your database | |
27 | -# after each scenario, which can lead to hard-to-debug failures in | |
28 | -# subsequent scenarios. If you do this, we recommend you create a Before | |
29 | -# block that will explicitly put your database in a known state. | |
30 | -Cucumber::Rails::World.use_transactional_fixtures = true | |
31 | 9 | |
32 | -# If you set this to false, any error raised from within your app will bubble | |
10 | +require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support | |
11 | +require 'cucumber/rails/world' | |
12 | +require 'cucumber/rails/active_record' | |
13 | +require 'cucumber/web/tableish' | |
14 | + | |
15 | +require 'capybara/rails' | |
16 | +require 'capybara/cucumber' | |
17 | +require 'capybara/session' | |
18 | +require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript | |
19 | +# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In | |
20 | +# order to ease the transition to Capybara we set the default here. If you'd | |
21 | +# prefer to use XPath just remove this line and adjust any selectors in your | |
22 | +# steps to use the XPath syntax. | |
23 | +Capybara.default_selector = :css | |
24 | + | |
25 | +# If you set this to false, any error raised from within your app will bubble | |
33 | 26 | # up to your step definition and out to cucumber unless you catch it somewhere |
34 | 27 | # on the way. You can make Rails rescue errors and render error pages on a |
35 | 28 | # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag. |
... | ... | @@ -40,16 +33,25 @@ Cucumber::Rails::World.use_transactional_fixtures = true |
40 | 33 | # of your scenarios, as this makes it hard to discover errors in your application. |
41 | 34 | ActionController::Base.allow_rescue = false |
42 | 35 | |
43 | -require 'cucumber' | |
44 | -# Comment out the next line if you don't want Cucumber Unicode support | |
45 | -require 'cucumber/formatter/unicode' | |
46 | -require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table) | |
47 | -require 'cucumber/rails/rspec' | |
48 | - | |
49 | -require 'webrat' | |
50 | -require 'webrat/core/matchers' | |
51 | -Webrat.configure do |config| | |
52 | - config.mode = :rails | |
53 | - 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 | |
54 | 57 | end |
55 | - | ... | ... |
features/support/selenium.rb
1 | -Webrat.configure do |config| | |
2 | - config.mode = :selenium | |
3 | - config.application_environment = :cucumber | |
4 | - config.selenium_browser_startup_timeout = 30000 | |
5 | -end | |
1 | +require 'rbconfig' | |
2 | +require 'cucumber/formatter/unicode' | |
6 | 3 | |
7 | -Cucumber::Rails::World.use_transactional_fixtures = false | |
4 | +require 'capybara' | |
5 | +require 'capybara/dsl' | |
6 | +require "capybara/cucumber" | |
8 | 7 | |
9 | 8 | require 'database_cleaner' |
10 | 9 | require 'database_cleaner/cucumber' |
11 | 10 | |
11 | +Cucumber::Rails::World.use_transactional_fixtures = false | |
12 | + | |
13 | +Capybara.default_driver = :selenium | |
14 | +Capybara.register_driver :selenium do |app| | |
15 | + Capybara::Selenium::Driver.new(app, :browser => :firefox) | |
16 | +end | |
17 | + | |
12 | 18 | DatabaseCleaner.clean_with :truncation |
13 | 19 | DatabaseCleaner.strategy = :truncation |
14 | 20 | |
... | ... | @@ -25,3 +31,5 @@ After do |
25 | 31 | sleep 2 |
26 | 32 | DatabaseCleaner.clean |
27 | 33 | end |
34 | + | |
35 | +World(Capybara) | ... | ... |
lib/tasks/cucumber.rake
1 | -# This file was generated by | |
2 | -$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. | |
3 | 6 | |
4 | -unless ARGV.any? {|a| a =~ /^gems/} | |
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? | |
5 | 12 | |
6 | 13 | begin |
7 | 14 | require 'cucumber/rake/task' |
8 | 15 | |
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 | 16 | namespace :cucumber do |
14 | 17 | Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| |
15 | - t.binary = vendored_cucumber_binary | |
18 | + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. | |
16 | 19 | 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'] || 'progress'}" | |
20 | + t.profile = 'default' | |
18 | 21 | end |
19 | 22 | |
20 | 23 | Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| |
21 | - t.binary = vendored_cucumber_binary | |
24 | + t.binary = vendored_cucumber_bin | |
22 | 25 | 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'] || 'progress'}" | |
26 | + t.profile = 'wip' | |
24 | 27 | end |
25 | 28 | |
26 | - Cucumber::Rake::Task.new({:selenium => 'db:test:prepare'}, 'Run features with selenium') do |t| | |
27 | - t.binary = vendored_cucumber_binary | |
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 | |
28 | 31 | t.fork = true # You may get faster startup if you set this to false |
29 | - t.cucumber_opts = "--color -p selenium --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" | |
32 | + t.profile = 'rerun' | |
30 | 33 | end |
31 | 34 | |
32 | 35 | desc 'Run all features' |
33 | 36 | task :all => [:ok, :wip] |
34 | 37 | end |
35 | 38 | desc 'Alias for cucumber:ok' |
36 | - task :cucumber => ['cucumber:ok'] | |
39 | + task :cucumber => 'cucumber:ok' | |
40 | + | |
41 | + task :default => :cucumber | |
37 | 42 | |
38 | 43 | task :features => :cucumber do |
39 | 44 | STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" | ... | ... |
script/cucumber
1 | 1 | #!/usr/bin/env ruby |
2 | 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) | |
3 | +vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first | |
4 | +if vendored_cucumber_bin | |
5 | + load File.expand_path(vendored_cucumber_bin) | |
13 | 6 | else |
14 | 7 | require 'rubygems' unless ENV['NO_RUBYGEMS'] |
15 | 8 | require 'cucumber' | ... | ... |