cucumber-rails 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/.travis.yml +24 -3
- data/Appraisals +53 -0
- data/CONTRIBUTING.md +59 -0
- data/Gemfile +16 -1
- data/Gemfile.appraisal +3 -0
- data/History.md +38 -25
- data/README.md +30 -6
- data/Rakefile +34 -13
- data/config/cucumber.yml +15 -1
- data/cucumber-rails.gemspec +14 -22
- data/dev_tasks/yard.rake +30 -12
- data/features/allow_rescue.feature +1 -1
- data/features/choose_javascript_database_strategy.feature +19 -9
- data/features/disable_automatic_database_cleaning.feature +55 -0
- data/features/fixing_bundler_pre.feature +1 -0
- data/features/mongoid.feature +3 -0
- data/features/multiple_databases.feature +2 -0
- data/features/no_database.feature +0 -1
- data/features/step_definitions/mongo_steps.rb +3 -0
- data/gemfiles/capybara_1_1.gemfile +17 -0
- data/gemfiles/rails_3_0.gemfile +15 -0
- data/gemfiles/rails_3_1.gemfile +17 -0
- data/gemfiles/rails_3_2.gemfile +17 -0
- data/lib/cucumber/rails.rb +4 -3
- data/lib/cucumber/rails/database.rb +33 -22
- data/lib/cucumber/rails/hooks/active_record.rb +6 -2
- data/lib/cucumber/rails/hooks/database_cleaner.rb +2 -2
- data/lib/cucumber/rails/world.rb +1 -1
- data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +1 -1
- data/lib/generators/cucumber/install/templates/support/capybara.rb +4 -5
- data/lib/generators/cucumber/install/templates/support/edit_warning.txt +2 -2
- data/lib/generators/cucumber/install/templates/tasks/cucumber.rake.erb +5 -5
- data/spec/spec_helper.rb +0 -1
- metadata +67 -162
data/config/cucumber.yml
CHANGED
@@ -1 +1,15 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
rerun_file = '.cucumber.rerun'
|
3
|
+
failing_scenarios = IO.read(rerun_file) rescue ''
|
4
|
+
path = if failing_scenarios.empty?
|
5
|
+
'features'
|
6
|
+
else
|
7
|
+
puts "Running failed scenarios"
|
8
|
+
failing_scenarios
|
9
|
+
end
|
10
|
+
opts = [
|
11
|
+
"--format #{path == 'features' ? 'progress' : 'pretty'}",
|
12
|
+
"--format rerun -o #{rerun_file}"
|
13
|
+
].join(' ')
|
14
|
+
%>
|
15
|
+
default: <%= path %> <%= opts %> --tags ~@broken
|
data/cucumber-rails.gemspec
CHANGED
@@ -3,40 +3,32 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'cucumber-rails'
|
6
|
-
s.version = '1.3.
|
6
|
+
s.version = '1.3.1'
|
7
7
|
s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland"]
|
8
8
|
s.description = "Cucumber Generator and Runtime for Rails"
|
9
9
|
s.summary = "#{s.name}-#{s.version}"
|
10
10
|
s.email = 'cukes@googlegroups.com'
|
11
11
|
s.homepage = "http://cukes.info"
|
12
12
|
|
13
|
-
s.add_runtime_dependency('cucumber', '>= 1.
|
13
|
+
s.add_runtime_dependency('cucumber', '>= 1.2.0')
|
14
14
|
s.add_runtime_dependency('nokogiri', '>= 1.5.0')
|
15
15
|
s.add_runtime_dependency('capybara', '>= 1.1.2')
|
16
|
-
s.
|
16
|
+
s.add_runtime_dependency('rails', '~> 3.0')
|
17
|
+
|
18
|
+
# Main development dependencies
|
17
19
|
s.add_development_dependency('rake', '>= 0.9.2.2')
|
18
|
-
s.add_development_dependency('bundler', '>= 1.0
|
20
|
+
s.add_development_dependency('bundler', '>= 1.1.0')
|
19
21
|
s.add_development_dependency('aruba', '>= 0.4.11')
|
20
|
-
s.add_development_dependency('
|
21
|
-
s.add_development_dependency('
|
22
|
-
s.add_development_dependency('
|
23
|
-
s.add_development_dependency('
|
24
|
-
s.add_development_dependency('
|
25
|
-
s.add_development_dependency('database_cleaner', '>= 0.7.1')
|
26
|
-
s.add_development_dependency('mongoid', '>= 2.4.4')
|
27
|
-
s.add_development_dependency('bson_ext', '>= 1.5.2')
|
28
|
-
|
29
|
-
# Various Stuff that Rails 3.1 puts inside apps.
|
30
|
-
s.add_development_dependency('turn', '>= 0.9.3')
|
31
|
-
s.add_development_dependency('sass-rails', '>= 3.2.4')
|
32
|
-
s.add_development_dependency('coffee-rails', '>= 3.2.2')
|
33
|
-
s.add_development_dependency('uglifier', '>= 1.2.3')
|
34
|
-
s.add_development_dependency('jquery-rails', '>= 2.0.0')
|
22
|
+
s.add_development_dependency('rspec', '~> 2.10.0')
|
23
|
+
s.add_development_dependency('ammeter', '>= 0.2.5')
|
24
|
+
s.add_development_dependency('factory_girl', '>= 3.2.0')
|
25
|
+
s.add_development_dependency('database_cleaner', '>= 0.7.2')
|
26
|
+
s.add_development_dependency('appraisal', '~> 0.5.1')
|
35
27
|
|
36
28
|
# For Documentation:
|
37
|
-
s.add_development_dependency('yard', '~> 0.
|
38
|
-
s.add_development_dependency('rdoc', '~> 3.12')
|
39
|
-
s.add_development_dependency('rdiscount', '~>
|
29
|
+
s.add_development_dependency('yard', '~> 0.8.5.2')
|
30
|
+
s.add_development_dependency('rdoc', '~> 3.12.2')
|
31
|
+
s.add_development_dependency('rdiscount', '~> 2.0.7')
|
40
32
|
s.add_development_dependency('bcat', '~> 0.6.2')
|
41
33
|
|
42
34
|
s.rubygems_version = ">= 1.6.1"
|
data/dev_tasks/yard.rake
CHANGED
@@ -1,17 +1,35 @@
|
|
1
1
|
require 'yard'
|
2
2
|
require 'yard/rake/yardoc_task'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
t.options = %w{--no-private --title Cucumber-Rails}
|
7
|
-
t.files = %w{lib - README.md History.md LICENSE}
|
8
|
-
end
|
4
|
+
SITE_DIR = File.expand_path(File.dirname(__FILE__) + '/../cucumber.github.com')
|
5
|
+
API_DIR = File.join(SITE_DIR, 'api', 'cucumber-rails', 'ruby', 'yardoc')
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
namespace :api do
|
8
|
+
file :dir do
|
9
|
+
unless File.directory?(SITE_DIR)
|
10
|
+
raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}"
|
11
|
+
end
|
12
|
+
sh('git pull origin master')
|
13
|
+
mkdir_p API_DIR
|
14
|
+
end
|
15
|
+
|
16
|
+
template_path = File.expand_path(File.join(File.dirname(__FILE__), 'yard'))
|
17
|
+
YARD::Templates::Engine.register_template_path(template_path)
|
18
|
+
YARD::Rake::YardocTask.new(:yard) do |yard|
|
19
|
+
dir = API_DIR
|
20
|
+
mkdir_p dir
|
21
|
+
yard.options = ["--out", dir]
|
22
|
+
end
|
23
|
+
task :yard => :dir
|
16
24
|
|
17
|
-
task :release
|
25
|
+
task :release do
|
26
|
+
Dir.chdir(SITE_DIR) do
|
27
|
+
sh('git add .')
|
28
|
+
sh("git commit -m 'Update API docs for cucumber-rails v#{cucumber-rails::VERSION}'")
|
29
|
+
sh('git push origin master')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Generate YARD docs for Cucumber-Rails' API"
|
34
|
+
task :doc => [:yard, :release]
|
35
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
@announce
|
2
1
|
Feature: Choose javascript database strategy
|
3
2
|
|
4
3
|
When running a scenario with the @javascript tag, Capybara will fire up a web server
|
@@ -18,9 +17,8 @@ Feature: Choose javascript database strategy
|
|
18
17
|
your database, but you run the risk of the two threads stomping on one another as they
|
19
18
|
talk to the database.
|
20
19
|
|
21
|
-
Right now, the default behavior
|
22
|
-
|
23
|
-
strategy to use for javascript scenarios.
|
20
|
+
Right now, the default behavior is to use truncation, but you can override this by telling
|
21
|
+
cucumber-rails which strategy to use for javascript scenarios.
|
24
22
|
|
25
23
|
The deletion strategy can be quicker for situations where truncation causes locks which
|
26
24
|
has been reported by some Oracle users.
|
@@ -32,21 +30,29 @@ Feature: Choose javascript database strategy
|
|
32
30
|
Scenario: Set the strategy to truncation and run a javascript scenario.
|
33
31
|
Given I append to "features/env.rb" with:
|
34
32
|
"""
|
33
|
+
DatabaseCleaner.strategy = :transaction
|
35
34
|
Cucumber::Rails::Database.javascript_strategy = :truncation
|
36
35
|
"""
|
37
36
|
And I write to "features/widgets.feature" with:
|
38
37
|
"""
|
39
|
-
@javascript
|
40
38
|
Feature:
|
41
39
|
Background:
|
42
40
|
Given I have created 2 widgets
|
43
41
|
|
42
|
+
@javascript
|
44
43
|
Scenario:
|
44
|
+
Then the DatabaseCleaner strategy should be truncation
|
45
45
|
When I create 3 widgets
|
46
46
|
Then I should have 5 widgets
|
47
47
|
|
48
|
+
@javascript
|
48
49
|
Scenario:
|
49
|
-
Then
|
50
|
+
Then the DatabaseCleaner strategy should be truncation
|
51
|
+
And I should have 2 widgets
|
52
|
+
|
53
|
+
Scenario:
|
54
|
+
Then the DatabaseCleaner strategy should be transaction
|
55
|
+
And I should have 2 widgets
|
50
56
|
"""
|
51
57
|
And I write to "features/step_definitions/widget_steps.rb" with:
|
52
58
|
"""
|
@@ -57,12 +63,16 @@ Feature: Choose javascript database strategy
|
|
57
63
|
Then /should have (\d) widgets/ do |num|
|
58
64
|
Widget.count.should == num.to_i
|
59
65
|
end
|
66
|
+
|
67
|
+
Then /^the DatabaseCleaner strategy should be (\w+)$/ do |strategy_name|
|
68
|
+
DatabaseCleaner.connections.first.strategy.to_s.should =~ /#{strategy_name}/i
|
69
|
+
end
|
60
70
|
"""
|
61
71
|
When I run the cukes
|
62
72
|
Then it should pass with:
|
63
73
|
"""
|
64
|
-
|
65
|
-
|
74
|
+
3 scenarios (3 passed)
|
75
|
+
10 steps (10 passed)
|
66
76
|
"""
|
67
77
|
|
68
78
|
Scenario: Set the strategy to deletion and run a javascript scenario.
|
@@ -103,7 +113,7 @@ Feature: Choose javascript database strategy
|
|
103
113
|
Scenario: Set the strategy to truncation with an except option and run a javascript scenario.
|
104
114
|
Given I append to "features/env.rb" with:
|
105
115
|
"""
|
106
|
-
Cucumber::Rails::Database.javascript_strategy = :truncation, {:except=>%w[widgets]}
|
116
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation, {:except=>%w[widgets]}
|
107
117
|
"""
|
108
118
|
And I write to "features/widgets.feature" with:
|
109
119
|
"""
|
@@ -0,0 +1,55 @@
|
|
1
|
+
Feature: Disable automatic database cleaning
|
2
|
+
|
3
|
+
By default, a set of Before/After hooks are installed to
|
4
|
+
invoke database_cleaner on every scenario except those tagged
|
5
|
+
"@no-database-cleaner". Sometimes when a user is switching between
|
6
|
+
cleaning strategies, this can initiate an undesired database
|
7
|
+
transaction.
|
8
|
+
|
9
|
+
To avoid the need for users making frequent strategy switches to apply
|
10
|
+
this tag, a configuration option is provided so that the user can
|
11
|
+
control the invocation of database_cleaner explicitly.
|
12
|
+
|
13
|
+
Scenario: Disabling automatic cleaning
|
14
|
+
Given I have created a new Rails 3 app and installed cucumber-rails
|
15
|
+
And I append to "features/env.rb" with:
|
16
|
+
"""
|
17
|
+
Cucumber::Rails::Database.autorun_database_cleaner = false
|
18
|
+
"""
|
19
|
+
And I write to "features/widgets.feature" with:
|
20
|
+
"""
|
21
|
+
Feature: Create widgets
|
22
|
+
Scenario: Create 3 widgets
|
23
|
+
When I create 3 widgets
|
24
|
+
Then I should have 3 widgets
|
25
|
+
|
26
|
+
Scenario: Create 5 widgets
|
27
|
+
When I create 5 widgets
|
28
|
+
Then I should have 8 widgets
|
29
|
+
"""
|
30
|
+
And I successfully run `rails generate model widget name:string`
|
31
|
+
And I write to "features/step_definitions/widget_steps.rb" with:
|
32
|
+
"""
|
33
|
+
Given /^I have (\d+) widgets$/ do |n|
|
34
|
+
n.to_i.times do |i|
|
35
|
+
Widget.create! :name => "Widget #{Widget.count + i}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
When /^I create (\d+) widgets$/ do |n|
|
40
|
+
n.to_i.times do |i|
|
41
|
+
Widget.create! :name => "Widget #{Widget.count + i}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Then /^I should have (\d+) widgets$/ do |n|
|
46
|
+
Widget.count.should == n.to_i
|
47
|
+
end
|
48
|
+
"""
|
49
|
+
And I run `bundle exec rake db:migrate`
|
50
|
+
And I run `bundle exec rake cucumber`
|
51
|
+
Then it should pass with:
|
52
|
+
"""
|
53
|
+
2 scenarios (2 passed)
|
54
|
+
4 steps (4 passed)
|
55
|
+
"""
|
data/features/mongoid.feature
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "capybara", "~> 1.1.2"
|
6
|
+
gem "rails", "~> 3.2.12"
|
7
|
+
gem "turn"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "sass-rails"
|
10
|
+
gem "coffee-rails"
|
11
|
+
gem "uglifier"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "sqlite3"
|
14
|
+
gem "bson_ext"
|
15
|
+
gem "mongoid"
|
16
|
+
|
17
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 3.0.20"
|
6
|
+
gem "capybara", "~> 2.0.2"
|
7
|
+
gem "turn"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "jquery-rails"
|
10
|
+
gem "uglifier"
|
11
|
+
gem "sqlite3"
|
12
|
+
gem "bson_ext"
|
13
|
+
gem "mongoid"
|
14
|
+
|
15
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 3.1.11"
|
6
|
+
gem "capybara", "~> 2.0.2"
|
7
|
+
gem "turn"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "sass-rails"
|
10
|
+
gem "coffee-rails"
|
11
|
+
gem "uglifier"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "sqlite3"
|
14
|
+
gem "bson_ext"
|
15
|
+
gem "mongoid"
|
16
|
+
|
17
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 3.2.12"
|
6
|
+
gem "capybara", "~> 2.0.2"
|
7
|
+
gem "turn"
|
8
|
+
gem "rspec-rails"
|
9
|
+
gem "sass-rails"
|
10
|
+
gem "coffee-rails"
|
11
|
+
gem "uglifier"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "sqlite3"
|
14
|
+
gem "bson_ext"
|
15
|
+
gem "mongoid"
|
16
|
+
|
17
|
+
gemspec :path=>"../"
|
data/lib/cucumber/rails.rb
CHANGED
@@ -24,6 +24,7 @@ if env_caller
|
|
24
24
|
require 'cucumber/rails/database'
|
25
25
|
|
26
26
|
else
|
27
|
-
warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being
|
28
|
-
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
|
29
|
-
|
27
|
+
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
|
+
If already in the :test group, be sure you are specifying ':require => false'."
|
30
|
+
end
|
@@ -8,6 +8,8 @@ module Cucumber
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
|
11
|
+
attr_accessor :autorun_database_cleaner
|
12
|
+
|
11
13
|
def javascript_strategy=(args)
|
12
14
|
strategy, *strategy_opts = args
|
13
15
|
strategy_type =
|
@@ -17,7 +19,7 @@ module Cucumber
|
|
17
19
|
when Class
|
18
20
|
strategy
|
19
21
|
end
|
20
|
-
|
22
|
+
|
21
23
|
@strategy = strategy_type.new(*strategy_opts)
|
22
24
|
|
23
25
|
validate_interface!
|
@@ -31,6 +33,10 @@ module Cucumber
|
|
31
33
|
@strategy.before_non_js
|
32
34
|
end
|
33
35
|
|
36
|
+
def after
|
37
|
+
@strategy.after
|
38
|
+
end
|
39
|
+
|
34
40
|
private
|
35
41
|
|
36
42
|
def map
|
@@ -50,37 +56,21 @@ module Cucumber
|
|
50
56
|
|
51
57
|
end
|
52
58
|
|
53
|
-
class SharedConnectionStrategy
|
54
|
-
def before_js
|
55
|
-
# Forces all threads to share a connection on a per-model basis,
|
56
|
-
# as connections may vary per model as per establish_connection. This works
|
57
|
-
# on Capybara because it starts the web server in a thread.
|
58
|
-
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
59
|
-
ActiveRecord::Base.descendants.each do |model|
|
60
|
-
model.shared_connection = model.connection
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def before_non_js
|
65
|
-
# Do not use a shared connection unless we're in a @javascript scenario
|
66
|
-
ActiveRecord::Base.shared_connection = nil
|
67
|
-
ActiveRecord::Base.descendants.each do |model|
|
68
|
-
model.shared_connection = nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
59
|
class Strategy
|
74
60
|
def initialize(options={})
|
75
61
|
@options=options
|
76
62
|
end
|
77
|
-
|
63
|
+
|
78
64
|
def before_js(strategy)
|
79
65
|
@original_strategy = DatabaseCleaner.connections.first.strategy # that feels like a nasty hack
|
80
66
|
DatabaseCleaner.strategy = strategy, @options
|
81
67
|
end
|
82
68
|
|
83
69
|
def before_non_js
|
70
|
+
# no-op
|
71
|
+
end
|
72
|
+
|
73
|
+
def after
|
84
74
|
return unless @original_strategy
|
85
75
|
DatabaseCleaner.strategy = @original_strategy
|
86
76
|
@original_strategy = nil
|
@@ -99,7 +89,28 @@ module Cucumber
|
|
99
89
|
end
|
100
90
|
end
|
101
91
|
|
92
|
+
class SharedConnectionStrategy < Strategy
|
93
|
+
def before_js
|
94
|
+
# Forces all threads to share a connection on a per-model basis,
|
95
|
+
# as connections may vary per model as per establish_connection. This works
|
96
|
+
# on Capybara because it starts the web server in a thread.
|
97
|
+
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
98
|
+
ActiveRecord::Base.descendants.each do |model|
|
99
|
+
model.shared_connection = model.connection
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def before_non_js
|
104
|
+
# Do not use a shared connection unless we're in a @javascript scenario
|
105
|
+
ActiveRecord::Base.shared_connection = nil
|
106
|
+
ActiveRecord::Base.descendants.each do |model|
|
107
|
+
model.shared_connection = nil
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
102
112
|
Database.javascript_strategy = :truncation
|
113
|
+
Database.autorun_database_cleaner = true
|
103
114
|
end
|
104
115
|
end
|
105
116
|
end
|