cucumber-rails 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,15 @@
1
- default: --tags ~@broken
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
@@ -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.0'
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.1.8')
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.add_development_dependency('rails', '>= 3.2.1')
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.22')
20
+ s.add_development_dependency('bundler', '>= 1.1.0')
19
21
  s.add_development_dependency('aruba', '>= 0.4.11')
20
- s.add_development_dependency('sqlite3', '>= 1.3.5')
21
- s.add_development_dependency('rspec', '~> 2.7.0') # Bump when cucumber bumps it
22
- s.add_development_dependency('rspec-rails', '~> 2.7.0')
23
- s.add_development_dependency('ammeter', '>= 0.2.2')
24
- s.add_development_dependency('factory_girl', '>= 2.6.0')
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.7.5')
38
- s.add_development_dependency('rdoc', '~> 3.12')
39
- s.add_development_dependency('rdiscount', '~> 1.6.8')
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"
@@ -1,17 +1,35 @@
1
1
  require 'yard'
2
2
  require 'yard/rake/yardoc_task'
3
3
 
4
- YARD::Templates::Engine.register_template_path(File.expand_path(File.join(File.dirname(__FILE__), 'yard')))
5
- YARD::Rake::YardocTask.new(:yard) do |t|
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
- desc "Push yardoc to http://cukes.info/cucumber-rails/api/#{CUCUMBER_RAILS_VERSION}"
11
- task :push_yard => :yard do
12
- sh("tar czf tmp/api-#{CUCUMBER_RAILS_VERSION}.tgz -C doc .")
13
- sh("scp tmp/api-#{CUCUMBER_RAILS_VERSION}.tgz cukes.info:/var/www/cucumber-rails/api")
14
- sh("ssh cukes.info 'cd /var/www/cucumber-rails/api && rm -rf #{CUCUMBER_RAILS_VERSION} && mkdir #{CUCUMBER_RAILS_VERSION} && tar xzf api-#{CUCUMBER_RAILS_VERSION}.tgz -C #{CUCUMBER_RAILS_VERSION} && rm -f latest && ln -s #{CUCUMBER_RAILS_VERSION} latest'")
15
- end
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 => :push_yard
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
@@ -18,7 +18,7 @@ Feature: Allow Cucumber to rescue exceptions
18
18
  """
19
19
 
20
20
  Scenario: Allow rescue
21
- And I write to "features/posts.feature" with:
21
+ Given I write to "features/posts.feature" with:
22
22
  """
23
23
  Feature: posts
24
24
  @allow-rescue
@@ -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 which works for 80% of cucumber-rails users is to use
22
- the shared connection patch, but you can override this by telling cucumber-rails which
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 I should have 2 widgets
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
- 2 scenarios (2 passed)
65
- 5 steps (5 passed)
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
+ """
@@ -20,5 +20,6 @@ Feature: Fixing Bundler Pre
20
20
  1 step (1 passed)
21
21
  """
22
22
  And the output should contain "WARNING:"
23
+ And the output should contain ":require => false"
23
24
 
24
25
 
@@ -1,5 +1,8 @@
1
1
  Feature: Mongoid
2
2
 
3
+ Background:
4
+ Given mongodb is running on my machine
5
+
3
6
  Scenario: Keep Mongoid happy
4
7
  Given I successfully run `rails new cuke-app -O`
5
8
  And I cd to "cuke-app"
@@ -16,6 +16,8 @@ Feature: Multiple Databases
16
16
  """
17
17
  class Bear < ActiveRecord::Base
18
18
  establish_connection "ursidae"
19
+
20
+ attr_accessible :name
19
21
  end
20
22
  """
21
23
  And a directory named "db/migrate"
@@ -1,4 +1,3 @@
1
- @announce
2
1
  Feature: No Database
3
2
  Allow Cucumber to work with a Rails app without a database
4
3
 
@@ -0,0 +1,3 @@
1
+ Given /^mongodb is running on my machine$/ do
2
+ run_simple('echo "exit" | mongo')
3
+ end
@@ -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=>"../"
@@ -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 defered until env.rb is called.
28
- To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile"
29
- end
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