cucumber-rails 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/.travis.yml +7 -6
  5. data/Appraisals +48 -40
  6. data/CONTRIBUTING.md +2 -2
  7. data/History.md +50 -7
  8. data/README.md +22 -9
  9. data/cucumber-rails.gemspec +19 -15
  10. data/dev_tasks/yard/default/layout/html/footer.erb +1 -1
  11. data/dev_tasks/yard/default/layout/html/layout.erb +5 -5
  12. data/dev_tasks/yard/default/layout/html/logo.erb +1 -1
  13. data/features/choose_javascript_database_strategy.feature +1 -1
  14. data/features/database_cleaner.feature +1 -1
  15. data/features/disable_automatic_database_cleaning.feature +1 -1
  16. data/features/install_cucumber_rails.feature +2 -1
  17. data/features/raising_errors.feature +1 -1
  18. data/features/rerun_profile.feature +1 -1
  19. data/features/step_definitions/cucumber_rails_steps.rb +17 -17
  20. data/features/support/bundler_pre_support.rb +2 -2
  21. data/features/support/env.rb +4 -4
  22. data/features/support/legacy_web_steps_support.rb +2 -3
  23. data/gemfiles/capybara_1_1.gemfile +2 -3
  24. data/gemfiles/rails_3_0.gemfile +2 -4
  25. data/gemfiles/rails_3_1.gemfile +2 -3
  26. data/gemfiles/rails_3_2.gemfile +2 -3
  27. data/gemfiles/rails_4_0.gemfile +2 -4
  28. data/gemfiles/rails_4_1.gemfile +18 -0
  29. data/lib/cucumber/rails.rb +8 -7
  30. data/lib/cucumber/rails/action_controller.rb +2 -2
  31. data/lib/cucumber/rails/application.rb +1 -1
  32. data/lib/cucumber/rails/capybara/javascript_emulation.rb +4 -4
  33. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +6 -6
  34. data/lib/cucumber/rails/database.rb +9 -12
  35. data/lib/cucumber/rails/hooks/active_record.rb +3 -3
  36. data/lib/cucumber/rails/rspec.rb +2 -2
  37. data/lib/cucumber/rails/world.rb +2 -2
  38. data/lib/generators/cucumber/install/USAGE +2 -2
  39. data/lib/generators/cucumber/install/install_generator.rb +9 -9
  40. data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +2 -2
  41. data/lib/generators/cucumber/install/templates/support/rails_spork.rb.erb +2 -2
  42. data/spec/cucumber/rails/database_spec.rb +3 -3
  43. data/spec/generators/cucumber/install/install_generator_spec.rb +5 -5
  44. data/spec/spec_helper.rb +1 -0
  45. metadata +207 -108
  46. data/features/step_definitions/mongo_steps.rb +0 -3
@@ -141,4 +141,4 @@ Feature: Choose javascript database strategy
141
141
  """
142
142
  2 scenarios (2 passed)
143
143
  3 steps (3 passed)
144
- """
144
+ """
@@ -7,7 +7,7 @@ Feature: DatabaseCleaner
7
7
  Feature: Create widgets
8
8
  Background: some widdgets
9
9
  Given I have 2 widgets
10
-
10
+
11
11
  Scenario: Add 3
12
12
  When I create 3 more widgets
13
13
  Then I should have 5 widgets
@@ -52,4 +52,4 @@ Feature: Disable automatic database cleaning
52
52
  """
53
53
  2 scenarios (2 passed)
54
54
  4 steps (4 passed)
55
- """
55
+ """
@@ -9,5 +9,6 @@ Feature: Rails
9
9
  | config/cucumber.yml |
10
10
  | script/cucumber |
11
11
  | features/support/env.rb |
12
+ | features/step_definitions/.gitkeep |
12
13
  | lib/tasks/cucumber.rake |
13
- And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
14
+ And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
@@ -13,4 +13,4 @@ Feature: Raise Errors
13
13
  """
14
14
  1 scenario (1 failed)
15
15
  1 step (1 failed)
16
- """
16
+ """
@@ -34,4 +34,4 @@ Feature: Rerun profile
34
34
  1 scenario (1 passed)
35
35
  1 step (1 passed)
36
36
  """
37
- And the file "rerun.txt" should not contain "features/rerun_test.feature:2"
37
+ And the file "rerun.txt" should not contain "features/rerun_test.feature:2"
@@ -1,37 +1,37 @@
1
1
  module CucumberRailsHelper
2
- def rails_new(options={})
2
+ def rails_new(options = {})
3
3
  options[:name] ||= 'test_app'
4
- run_simple "bundle exec rails new #{options[:name]} --skip-test-unit #{options[:args]}"
4
+ run_simple "bundle exec rails new #{options[:name]} --skip-test-unit --skip-spring #{options[:args]}"
5
5
  assert_passing_with('README')
6
6
  cd options[:name]
7
7
  end
8
8
 
9
9
  def install_cucumber_rails(*options)
10
10
  if options.include?(:not_in_test_group)
11
- gem "cucumber-rails", :path => "#{File.expand_path('.')}"
11
+ gem 'cucumber-rails', path: "#{File.expand_path('.')}"
12
12
  else
13
- gem "cucumber-rails", :group => :test, :require => false, :path => "#{File.expand_path('.')}"
13
+ gem 'cucumber-rails' , group: :test, require: false, path: "#{File.expand_path('.')}"
14
14
  end
15
- gem "capybara", :group => :test
16
- gem "rspec-rails", :group => :test
17
- gem "database_cleaner", :group => :test unless options.include?(:no_database_cleaner)
18
- gem 'factory_girl', :group => :test unless options.include?(:no_factory_girl)
19
- gem "selenium-webdriver", :group => :test
20
- run_simple "bundle exec rails generate cucumber:install"
15
+ gem 'capybara', group: :test
16
+ gem 'rspec-rails', group: :test
17
+ gem 'database_cleaner', group: :test unless options.include?(:no_database_cleaner)
18
+ gem 'factory_girl', group: :test unless options.include?(:no_factory_girl)
19
+ gem 'selenium-webdriver', group: :test
20
+ run_simple 'bundle exec rails generate cucumber:install'
21
21
  end
22
-
22
+
23
23
  def gem(name, options)
24
24
  line = %{gem "#{name}", #{options.inspect}\n}
25
25
  append_to_file('Gemfile', line)
26
26
  end
27
-
27
+
28
28
  def prepare_aruba_report
29
29
  if(ENV['ARUBA_REPORT_DIR'])
30
30
  @aruba_report_start = Time.new
31
31
  sleep(1)
32
32
  end
33
33
  end
34
-
34
+
35
35
  def fixture(path)
36
36
  File.expand_path(File.dirname(__FILE__) + "./../support/fixtures/#{path}")
37
37
  end
@@ -46,7 +46,7 @@ Given /^I have created a new Rails app and installed cucumber\-rails, accidental
46
46
  end
47
47
 
48
48
  Given /^I have created a new Rails app "([^"]*)" and installed cucumber\-rails$/ do |app_name|
49
- rails_new :name => app_name
49
+ rails_new name: app_name
50
50
  install_cucumber_rails
51
51
  create_web_steps
52
52
  prepare_aruba_report
@@ -60,14 +60,14 @@ Given /^I have created a new Rails app and installed cucumber\-rails$/ do
60
60
  end
61
61
 
62
62
  Given /^I have created a new Rails app with no database and installed cucumber-rails$/ do
63
- rails_new :args => '--skip-active-record'
63
+ rails_new args: '--skip-active-record'
64
64
  install_cucumber_rails :no_database_cleaner, :no_factory_girl
65
65
  overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
66
66
  create_web_steps
67
67
  end
68
68
 
69
69
  Given /^I have created a new Rails app "(.*?)" with no database and installed cucumber\-rails$/ do |app_name|
70
- rails_new :name => app_name, :args => '--skip-active-record'
70
+ rails_new name: app_name, args: '--skip-active-record'
71
71
  install_cucumber_rails :no_database_cleaner, :no_factory_girl
72
72
  overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
73
73
  create_web_steps
@@ -75,7 +75,7 @@ end
75
75
 
76
76
  Given /^I have a "([^"]*)" ActiveRecord model object$/ do |name|
77
77
  run_simple("bundle exec rails g model #{name}")
78
- run_simple("bundle exec rake db:migrate RAILS_ENV=test")
78
+ run_simple('bundle exec rake db:migrate RAILS_ENV=test')
79
79
  end
80
80
 
81
81
  When /^I run the cukes$/ do
@@ -2,11 +2,11 @@ module BundlerPreHelper
2
2
  def bundler
3
3
  fixture 'bundler-1.0.21.gem'
4
4
  end
5
-
5
+
6
6
  def bundler_pre
7
7
  fixture 'bundler-1.1.rc.gem'
8
8
  end
9
-
9
+
10
10
  def gem_install(path)
11
11
  run_simple("gem install #{path} --no-ri --no-rdoc")
12
12
  end
@@ -17,16 +17,16 @@ if(ENV['ARUBA_REPORT_DIR'])
17
17
  module Reporting
18
18
  def children(dir)
19
19
  children = Dir["#{dir}/*"].sort
20
-
20
+
21
21
  # include
22
22
  children = children.select do |child|
23
- File.directory?(child) ||
23
+ File.directory?(child) ||
24
24
  (@aruba_report_start && File.stat(child).mtime > @aruba_report_start)
25
25
  end
26
-
26
+
27
27
  # exclude
28
28
  children = children.reject do |child|
29
- child =~ /Gemfile/ ||
29
+ child =~ /Gemfile/ ||
30
30
  child =~ /\.log$/
31
31
  end
32
32
 
@@ -235,7 +235,7 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
235
235
  query = URI.parse(current_url).query
236
236
  actual_params = query ? CGI.parse(query) : {}
237
237
  expected_params = {}
238
- expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
238
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
239
239
 
240
240
  if actual_params.respond_to? :should
241
241
  actual_params.should == expected_params
@@ -248,7 +248,7 @@ Then /^show me the page$/ do
248
248
  save_and_open_page
249
249
  end
250
250
  EOF
251
-
251
+
252
252
  write_file('features/support/paths.rb', <<-EOF)
253
253
  module NavigationHelpers
254
254
  # Maps a name to a path. Used by the
@@ -287,4 +287,3 @@ EOF
287
287
  end
288
288
  end
289
289
  World(WebSteps)
290
-
@@ -5,13 +5,12 @@ source "https://rubygems.org"
5
5
  gem "capybara", "~> 1.1.2"
6
6
  gem "rails", "~> 3.2.12"
7
7
  gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
8
+ gem "rspec-rails", "~> 2.14.2"
9
9
  gem "sass-rails", "~> 3.2.6"
10
10
  gem "coffee-rails", "~> 3.2.2"
11
11
  gem "jquery-rails", "~> 2.2.1"
12
12
  gem "uglifier", "~> 2.1.0"
13
13
  gem "sqlite3", "~> 1.3.7"
14
- gem "bson_ext", "~> 1.8.5"
15
14
  gem "database_cleaner", "~> 1.0.1"
16
15
 
17
- gemspec :path=>"../"
16
+ gemspec :path => "../"
@@ -5,12 +5,10 @@ source "https://rubygems.org"
5
5
  gem "rails", "~> 3.0.20"
6
6
  gem "capybara", "~> 2.0.2"
7
7
  gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
8
+ gem "rspec-rails", "~> 2.14.2"
9
9
  gem "jquery-rails", "~> 2.2.1"
10
10
  gem "uglifier", "~> 2.1.0"
11
11
  gem "sqlite3", "~> 1.3.7"
12
- gem "bson_ext", "~> 1.8.5"
13
- gem "mongoid", "~> 2.2.6"
14
12
  gem "database_cleaner", "~> 1.0.1"
15
13
 
16
- gemspec :path=>"../"
14
+ gemspec :path => "../"
@@ -5,13 +5,12 @@ source "https://rubygems.org"
5
5
  gem "rails", "~> 3.1.11"
6
6
  gem "capybara", "~> 2.0.2"
7
7
  gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
8
+ gem "rspec-rails", "~> 2.14.2"
9
9
  gem "sass-rails", "~> 3.1.7"
10
10
  gem "coffee-rails", "~> 3.1.1"
11
11
  gem "jquery-rails", "~> 2.2.1"
12
12
  gem "uglifier", "~> 2.1.0"
13
13
  gem "sqlite3", "~> 1.3.7"
14
- gem "bson_ext", "~> 1.8.5"
15
14
  gem "database_cleaner", "~> 1.0.1"
16
15
 
17
- gemspec :path=>"../"
16
+ gemspec :path => "../"
@@ -5,13 +5,12 @@ source "https://rubygems.org"
5
5
  gem "rails", "~> 3.2.12"
6
6
  gem "capybara", "~> 2.0.2"
7
7
  gem "turn", "~> 0.9.6"
8
- gem "rspec-rails", "~> 2.12.2"
8
+ gem "rspec-rails", "~> 2.14.2"
9
9
  gem "sass-rails", "~> 3.2.6"
10
10
  gem "coffee-rails", "~> 3.2.2"
11
11
  gem "jquery-rails", "~> 2.2.1"
12
12
  gem "uglifier", "~> 2.1.0"
13
13
  gem "sqlite3", "~> 1.3.7"
14
- gem "bson_ext", "~> 1.8.5"
15
14
  gem "database_cleaner", "~> 1.0.1"
16
15
 
17
- gemspec :path=>"../"
16
+ gemspec :path => "../"
@@ -7,14 +7,12 @@ gem "rails", "~> 4.0.0"
7
7
  gem "railties", "~> 4.0.0"
8
8
  gem "capybara", "~> 2.0.2"
9
9
  gem "turn", "~> 0.9.6"
10
- gem "rspec-rails", "~> 2.12.2"
10
+ gem "rspec-rails", "~> 2.14.2"
11
11
  gem "sass-rails", "~> 4.0.0"
12
12
  gem "coffee-rails", "~> 4.0.0"
13
13
  gem "jquery-rails", "~> 2.2.1"
14
14
  gem "uglifier", "~> 2.1.0"
15
15
  gem "sqlite3", "~> 1.3.7"
16
- gem "bson_ext", "~> 1.8.5"
17
- gem "mongoid", :git=>"https://github.com/mongoid/mongoid.git"
18
16
  gem "database_cleaner", "~> 1.0.1"
19
17
 
20
- gemspec :path=>"../"
18
+ gemspec :path => "../"
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "protected_attributes", "~> 1.0.3"
6
+ gem "rails", "~> 4.1.0"
7
+ gem "railties", "~> 4.1.0"
8
+ gem "capybara", "~> 2.0.2"
9
+ gem "turn", "~> 0.9.6"
10
+ gem "rspec-rails", "~> 2.14.2"
11
+ gem "sass-rails", "~> 4.0.0"
12
+ gem "coffee-rails", "~> 4.0.0"
13
+ gem "jquery-rails", "~> 2.2.1"
14
+ gem "uglifier", "~> 2.1.0"
15
+ gem "sqlite3", "~> 1.3.7"
16
+ gem "database_cleaner", "~> 1.0.1"
17
+
18
+ gemspec :path => "../"
@@ -1,10 +1,10 @@
1
- env_caller = File.dirname(caller.detect{|f| f =~ /\/env\.rb:/}) if caller.detect{|f| f =~ /\/env\.rb:/}
1
+ env_caller = File.dirname(caller.detect{ |f| f =~ /\/env\.rb:/ }) if caller.detect{ |f| f =~ /\/env\.rb:/ }
2
2
  if env_caller
3
3
  require 'rails'
4
4
  require 'cucumber/rails/application'
5
- ENV["RAILS_ENV"] ||= "test"
6
- ENV["RAILS_ROOT"] ||= File.expand_path(env_caller + "/../..")
7
- require File.expand_path(ENV["RAILS_ROOT"] + '/config/environment')
5
+ ENV['RAILS_ENV'] ||= 'test'
6
+ ENV['RAILS_ROOT'] ||= File.expand_path(env_caller + '/../..')
7
+ require File.expand_path(ENV['RAILS_ROOT'] + '/config/environment')
8
8
  require 'cucumber/rails/action_controller'
9
9
 
10
10
  if defined?(ActiveRecord::Base)
@@ -14,8 +14,8 @@ if env_caller
14
14
  require 'action_dispatch/testing/integration'
15
15
  end
16
16
 
17
- if !Rails.application.config.cache_classes
18
- warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
17
+ unless Rails.application.config.cache_classes
18
+ warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions."
19
19
  end
20
20
 
21
21
  require 'cucumber/rails/world'
@@ -23,8 +23,9 @@ if env_caller
23
23
  require 'cucumber/rails/capybara'
24
24
  require 'cucumber/rails/database'
25
25
 
26
+ MultiTest.disable_autorun
26
27
  else
27
28
  warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being deferred until env.rb is called.
28
- To avoid this warning, move 'gem \'cucumber-rails\', :require => false' under only group :test in your Gemfile.
29
+ To avoid this warning, move 'gem \'cucumber-rails\', :require => false' under only group :test in your Gemfile.
29
30
  If already in the :test group, be sure you are specifying ':require => false'."
30
31
  end
@@ -4,9 +4,9 @@ end
4
4
 
5
5
  class ActionDispatch::ShowExceptions
6
6
  alias __cucumber_orig_call__ call
7
-
7
+
8
8
  def call(env)
9
9
  env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue
10
10
  __cucumber_orig_call__(env)
11
11
  end
12
- end
12
+ end
@@ -6,7 +6,7 @@ require 'rails/application'
6
6
  # toggle whether or not exceptions are raised.
7
7
  class Rails::Application
8
8
  alias __cucumber_orig_initialize__ initialize!
9
-
9
+
10
10
  def initialize!
11
11
  ad = config.action_dispatch
12
12
  def ad.show_exceptions
@@ -8,7 +8,7 @@ module Cucumber
8
8
  alias_method :click, :click_with_javascript_emulation
9
9
  end
10
10
  end
11
-
11
+
12
12
  def click_with_javascript_emulation
13
13
  if link_with_non_get_http_method?
14
14
  ::Capybara::RackTest::Form.new(driver, js_form(element_node.document, self[:href], emulated_method)).submit(self)
@@ -54,14 +54,14 @@ module Cucumber
54
54
 
55
55
  # rails will wipe the session if the CSRF token is not sent
56
56
  # with non-GET requests
57
- if csrf? && emulated_method.downcase != "get"
57
+ if csrf? && emulated_method.downcase != 'get'
58
58
  input = document.create_element('input')
59
59
  input['type'] = 'hidden'
60
60
  input['name'] = csrf_param
61
61
  input['value'] = csrf_token
62
62
  js_form.add_child(input)
63
63
  end
64
-
64
+
65
65
  js_form
66
66
  end
67
67
 
@@ -85,7 +85,7 @@ module Cucumber
85
85
  if self.respond_to? :native
86
86
  self.native
87
87
  else
88
- warn "DEPRECATED: cucumber-rails loves you, just not your version of Capybara. Please update Capybara to >= 0.4.0"
88
+ warn 'DEPRECATED: cucumber-rails loves you, just not your version of Capybara. Please update Capybara to >= 0.4.0'
89
89
  self.node
90
90
  end
91
91
  end
@@ -3,17 +3,17 @@ module Cucumber
3
3
  module Capybara
4
4
  # This module defines methods for selecting dates and times
5
5
  module SelectDatesAndTimes
6
- # Select a Rails date. Options has must include :from => +label+
6
+ # Select a Rails date. Options hash must include :from => +label+
7
7
  def select_date(date, options)
8
8
  date = Date.parse(date)
9
9
  base_dom_id = get_base_dom_id_from_label_tag(options[:from])
10
10
 
11
11
  find(:xpath, ".//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
12
- find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l date, :format => '%B')
12
+ find(:xpath, ".//select[@id='#{base_dom_id}_2i']").select(I18n.l date, format: '%B')
13
13
  find(:xpath, ".//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
14
14
  end
15
-
16
- # Select a Rails time. Options has must include :from => +label+
15
+
16
+ # Select a Rails time. Options hash must include :from => +label+
17
17
  def select_time(time, options)
18
18
  time = Time.zone.parse(time)
19
19
  base_dom_id = get_base_dom_id_from_label_tag(options[:from])
@@ -21,8 +21,8 @@ module Cucumber
21
21
  find(:xpath, ".//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
22
22
  find(:xpath, ".//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
23
23
  end
24
-
25
- # Select a Rails datetime. Options has must include :from => +label+
24
+
25
+ # Select a Rails datetime. Options hash must include :from => +label+
26
26
  def select_datetime(datetime, options)
27
27
  select_date(datetime, options)
28
28
  select_time(datetime, options)
@@ -1,13 +1,11 @@
1
1
  module Cucumber
2
2
  module Rails
3
3
  module Database
4
-
5
4
  CUSTOM_STRATEGY_INTERFACE = %w{ before_js before_non_js }
6
5
 
7
- class InvalidStrategy < ArgumentError;end
6
+ class InvalidStrategy < ArgumentError; end
8
7
 
9
8
  class << self
10
-
11
9
  attr_accessor :autorun_database_cleaner
12
10
 
13
11
  def javascript_strategy=(args)
@@ -41,24 +39,23 @@ module Cucumber
41
39
 
42
40
  def map
43
41
  {
44
- :truncation => TruncationStrategy,
45
- :shared_connection => SharedConnectionStrategy,
46
- :transaction => SharedConnectionStrategy,
47
- :deletion => DeletionStrategy
42
+ truncation: TruncationStrategy,
43
+ shared_connection: SharedConnectionStrategy,
44
+ transaction: SharedConnectionStrategy,
45
+ deletion: DeletionStrategy
48
46
  }
49
47
  end
50
48
 
51
49
  def validate_interface!
52
- unless CUSTOM_STRATEGY_INTERFACE.all? {|m| @strategy.respond_to?(m) }
53
- raise(ArgumentError, "Strategy must respond to all of: #{CUSTOM_STRATEGY_INTERFACE.map{|method| "##{method}" } * ' '} !")
50
+ unless CUSTOM_STRATEGY_INTERFACE.all? { |m| @strategy.respond_to?(m) }
51
+ raise(ArgumentError, "Strategy must respond to all of: #{CUSTOM_STRATEGY_INTERFACE.map{ |method| "##{method}" } * ' ' } !")
54
52
  end
55
53
  end
56
-
57
54
  end
58
55
 
59
56
  class Strategy
60
- def initialize(options={})
61
- @options=options
57
+ def initialize(options = {})
58
+ @options = options
62
59
  end
63
60
 
64
61
  def before_js(strategy)