cucumber 0.3.104 → 0.4.0.rc1

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.
Files changed (81) hide show
  1. data/History.txt +50 -3
  2. data/Manifest.txt +20 -2
  3. data/Rakefile +4 -0
  4. data/config/hoe.rb +20 -14
  5. data/examples/i18n/tr/Rakefile +6 -0
  6. data/examples/i18n/tr/features/bo/314/210lme.feature +10 -0
  7. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_ad/304/261mlar/304/261.rb +24 -0
  8. data/examples/i18n/tr/features/toplama.feature +18 -0
  9. data/examples/i18n/tr/lib/hesap_makinesi.rb +15 -0
  10. data/examples/python/features/step_definitions/fib_steps.py +9 -1
  11. data/examples/ruby2python/features/fibonacci.feature +19 -0
  12. data/examples/{python → ruby2python}/features/step_definitions/fib_steps.rb +0 -0
  13. data/examples/ruby2python/features/support/env.rb +21 -0
  14. data/examples/ruby2python/lib/fib.py +7 -0
  15. data/features/bug_475.feature +43 -0
  16. data/features/exception_in_before_block.feature +34 -1
  17. data/features/html_formatter.feature +1 -1
  18. data/features/language_help.feature +68 -0
  19. data/features/rake_task.feature +34 -60
  20. data/features/simplest.feature +11 -0
  21. data/features/step_definitions/simplest_steps.rb +6 -0
  22. data/features/support/env.rb +1 -1
  23. data/features/support/env.rb.simplest +7 -0
  24. data/features/table_diffing.feature +1 -1
  25. data/features/table_mapping.feature +35 -0
  26. data/features/transform.feature +133 -2
  27. data/features/usage_and_stepdefs_formatter.feature +4 -2
  28. data/gem_tasks/contributors.rake +2 -1
  29. data/lib/cucumber/ast/background.rb +17 -5
  30. data/lib/cucumber/ast/outline_table.rb +8 -1
  31. data/lib/cucumber/ast/scenario.rb +2 -1
  32. data/lib/cucumber/ast/step.rb +6 -1
  33. data/lib/cucumber/ast/step_invocation.rb +14 -1
  34. data/lib/cucumber/ast/table.rb +30 -6
  35. data/lib/cucumber/cli/configuration.rb +1 -1
  36. data/lib/cucumber/cli/language_help_formatter.rb +27 -14
  37. data/lib/cucumber/cli/options.rb +2 -1
  38. data/lib/cucumber/cli/profile_loader.rb +12 -4
  39. data/lib/cucumber/core_ext/instance_exec.rb +29 -25
  40. data/lib/cucumber/formatter/junit.rb +50 -45
  41. data/lib/cucumber/formatter/pdf.rb +16 -4
  42. data/lib/cucumber/formatter/usage.rb +2 -14
  43. data/lib/cucumber/language_support/language_methods.rb +23 -3
  44. data/lib/cucumber/languages.yml +14 -0
  45. data/lib/cucumber/parser/natural_language.rb +1 -1
  46. data/lib/cucumber/parser/table.rb +10 -7
  47. data/lib/cucumber/parser/table.tt +1 -1
  48. data/lib/cucumber/platform.rb +1 -0
  49. data/lib/cucumber/py_support/py_dsl.py +10 -8
  50. data/lib/cucumber/py_support/py_language.py +8 -0
  51. data/lib/cucumber/py_support/py_language.rb +24 -11
  52. data/lib/cucumber/rails/action_controller.rb +6 -1
  53. data/lib/cucumber/rails/active_record.rb +5 -4
  54. data/lib/cucumber/rake/task.rb +7 -82
  55. data/lib/cucumber/rb_support/rb_language.rb +0 -4
  56. data/lib/cucumber/rb_support/rb_step_definition.rb +4 -6
  57. data/lib/cucumber/rb_support/rb_transform.rb +9 -7
  58. data/lib/cucumber/step_definition_light.rb +20 -0
  59. data/lib/cucumber/step_match.rb +1 -1
  60. data/lib/cucumber/step_mother.rb +5 -1
  61. data/lib/cucumber/version.rb +3 -3
  62. data/lib/cucumber/webrat/element_locator.rb +2 -0
  63. data/rails_generators/cucumber/cucumber_generator.rb +8 -9
  64. data/rails_generators/cucumber/templates/cucumber +14 -6
  65. data/rails_generators/cucumber/templates/cucumber.rake +9 -1
  66. data/rails_generators/cucumber/templates/cucumber_environment.rb +5 -1
  67. data/rails_generators/cucumber/templates/env.rb +29 -14
  68. data/rails_generators/cucumber/templates/paths.rb +1 -1
  69. data/rails_generators/cucumber/templates/spork_env.rb +39 -17
  70. data/rails_generators/cucumber/templates/version_check.rb +29 -0
  71. data/rails_generators/cucumber/templates/webrat_steps.rb +5 -0
  72. data/spec/cucumber/ast/outline_table_spec.rb +21 -0
  73. data/spec/cucumber/ast/table_spec.rb +18 -0
  74. data/spec/cucumber/formatter/html_spec.rb +33 -69
  75. data/spec/cucumber/formatter/junit_spec.rb +73 -0
  76. data/spec/cucumber/formatter/spec_helper.rb +50 -0
  77. data/spec/cucumber/parser/table_parser_spec.rb +2 -2
  78. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +10 -1
  79. data/spec/cucumber/step_mother_spec.rb +6 -0
  80. metadata +32 -8
  81. data/examples/python/features/support/env.rb +0 -21
@@ -8,7 +8,7 @@ module NavigationHelpers
8
8
  def path_to(page_name)
9
9
  case page_name
10
10
 
11
- when /the homepage/
11
+ when /the home\s?page/
12
12
  '/'
13
13
 
14
14
  # Add more mappings here.
@@ -1,3 +1,8 @@
1
+ # IMPORTANT: This file was generated by Cucumber <%= Cucumber::VERSION::STRING %>
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 'rubygems'
2
7
  require 'spork'
3
8
 
@@ -5,31 +10,48 @@ Spork.prefork do
5
10
  # Sets up the Rails environment for Cucumber
6
11
  ENV["RAILS_ENV"] = "cucumber"
7
12
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
13
+ require 'cucumber/rails/world'
8
14
 
9
- require 'webrat'
10
- require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
11
-
12
- Webrat.configure do |config|
13
- config.mode = :rails
14
- end
15
-
16
- require 'webrat/core/matchers'
17
15
  require 'cucumber'
18
-
19
16
  # Comment out the next line if you don't want Cucumber Unicode support
20
17
  require 'cucumber/formatter/unicode'
21
- require 'spec/rails'
18
+ require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
19
+ <% if framework == :rspec -%>
22
20
  require 'cucumber/rails/rspec'
21
+ <% end -%>
22
+
23
+ require 'webrat'
24
+ require 'webrat/core/matchers'
25
+ Webrat.configure do |config|
26
+ config.mode = :rails
27
+ config.open_error_files = false # Set to true if you want error pages to pop up in the browser
28
+ end
23
29
  end
24
30
 
25
31
  Spork.each_run do
26
- # This code will be run each time you run your specs.
32
+ # This code will be run each time you start cucumber.
27
33
 
28
- # Comment out the next line if you don't want transactions to
29
- # open/roll back around each scenario
30
- Cucumber::Rails.use_transactional_fixtures
34
+ # If you set this to true, each scenario will run in a database transaction.
35
+ # You can still turn off transactions on a per-scenario basis, simply tagging
36
+ # a feature or scenario with the @no-txn tag.
37
+ #
38
+ # If you set this to false, transactions will be off for all scenarios,
39
+ # regardless of whether you use @no-txn or not.
40
+ #
41
+ # Beware that turning transactions off will leave data in your database
42
+ # after each scenario, which can lead to hard-to-debug failures in
43
+ # subsequent scenarios. If you do this, we recommend you create a Before
44
+ # block that will explicitly put your database in a known state.
45
+ Cucumber::Rails::World.use_transactional_fixtures = true
31
46
 
32
- # Comment out the next line if you want Rails' own error handling
33
- # (e.g. rescue_action_in_public / rescue_responses / rescue_from)
34
- Cucumber::Rails.bypass_rescue
47
+ # If you set this to false, any error raised from within your app will bubble
48
+ # up to your step definition and out to cucumber unless you catch it somewhere
49
+ # on the way. You can make Rails rescue errors and render error pages on a
50
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
51
+ #
52
+ # If you set this to true, Rails will rescue all errors and render error
53
+ # pages, more or less in the same way your application would behave in the
54
+ # default production environment. It's not recommended to do this for all
55
+ # of your scenarions, as this makes it hard to discover errors in your application.
56
+ ActionController::Base.allow_rescue = false
35
57
  end
@@ -0,0 +1,29 @@
1
+ if Cucumber::VERSION::STRING != '<%= Cucumber::VERSION::STRING %>'
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 <%= Cucumber::VERSION::STRING %>,
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
@@ -1,3 +1,8 @@
1
+ # IMPORTANT: This file was generated by Cucumber <%= Cucumber::VERSION::STRING %>
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
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber::Ast
4
+ describe OutlineTable do
5
+ describe OutlineTable::ExampleRow do
6
+ describe "a header row" do
7
+ before(:each) do
8
+ @row = OutlineTable::ExampleRow.new(
9
+ mock('table', :index => 0),
10
+ [mock('cell', :status= => nil)]
11
+ )
12
+ end
13
+
14
+ it "should raise an error if you try to call #failed?" do
15
+ @row.accept_plain mock('visitor', :visit_table_cell => nil)
16
+ lambda{ @row.failed? }.should raise_error(NoMethodError, /cannot pass or fail/)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -62,6 +62,24 @@ module Cucumber
62
62
  }.should raise_error('The column named "two" does not exist')
63
63
  end
64
64
 
65
+ describe "#match" do
66
+ before(:each) do
67
+ @table = Table.new([
68
+ %w{one four seven},
69
+ %w{4444 55555 666666}
70
+ ])
71
+ end
72
+
73
+ it "returns nil if headers do not match" do
74
+ @table.match('does,not,match').should be_nil
75
+ end
76
+ it "requires a table: prefix on match" do
77
+ @table.match('table:one,four,seven').should_not be_nil
78
+ end
79
+ it "does not match if no table: prefix on match" do
80
+ @table.match('one,four,seven').should be_nil
81
+ end
82
+ end
65
83
  describe "#transpose" do
66
84
  before(:each) do
67
85
  @table = Table.new([
@@ -1,84 +1,48 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.dirname(__FILE__) + '/spec_helper'
2
3
  require 'cucumber/formatter/html'
3
4
  require 'nokogiri'
4
5
  require 'cucumber/rb_support/rb_language'
5
6
 
6
7
  module Cucumber
7
8
  module Formatter
8
- module SpecHelperDsl
9
- attr_reader :feature_content, :step_defs
10
-
11
- def define_feature(string)
12
- @feature_content = string
13
- end
14
-
15
- def define_steps(&block)
16
- @step_defs = block
17
- end
18
- end
19
- module SpecHelper
20
- def load_features(content)
21
- feature_file = FeatureFile.new(nil, content)
22
- features = Ast::Features.new
23
- features.add_feature feature_file.parse(@step_mother, {})
24
- features
25
- end
26
-
27
- def run(features)
28
- # options = { :verbose => true }
29
- options = {}
30
- tree_walker = Cucumber::Ast::TreeWalker.new(@step_mother, [@formatter], options, STDOUT)
31
- tree_walker.visit_features(features)
32
- end
33
-
34
- def define_steps
35
- return unless step_defs = self.class.step_defs
36
- rb = @step_mother.load_programming_language('rb')
37
- dsl = Object.new
38
- dsl.extend RbSupport::RbDsl
39
- dsl.instance_exec &step_defs
40
- end
41
-
9
+
10
+ describe Html do
11
+ extend SpecHelperDsl
12
+ include SpecHelper
13
+
42
14
  Spec::Matchers.define :have_css_node do |css, regexp|
43
15
  match do |doc|
44
16
  nodes = doc.css(css)
45
17
  nodes.detect{ |node| node.text =~ regexp }
46
18
  end
47
19
  end
48
- end
49
20
 
50
- describe Html do
51
21
  before(:each) do
52
22
  @out = StringIO.new
53
- @formatter = Html.new(mock("step mother"), @out, {})
54
- @step_mother = StepMother.new
23
+ @formatter = Html.new(step_mother, @out, {})
55
24
  end
56
-
57
- extend SpecHelperDsl
58
- include SpecHelper
59
-
25
+
60
26
  it "should not raise an error when visiting a blank feature name" do
61
27
  lambda { @formatter.feature_name("") }.should_not raise_error
62
28
  end
63
-
29
+
64
30
  describe "given a single feature" do
65
31
  before(:each) do
66
- features = load_features(self.class.feature_content || raise("No feature content defined!"))
67
- define_steps
68
- run(features)
32
+ run_defined_feature
69
33
  @doc = Nokogiri.HTML(@out.string)
70
34
  end
71
-
35
+
72
36
  describe "with a comment" do
73
37
  define_feature <<-FEATURE
74
38
  # Healthy
75
39
  FEATURE
76
-
40
+
77
41
  it { @out.string.should =~ /^\<!DOCTYPE/ }
78
42
  it { @out.string.should =~ /\<\/html\>$/ }
79
43
  it { @doc.should have_css_node('.feature .comment', /Healthy/) }
80
44
  end
81
-
45
+
82
46
  describe "with a tag" do
83
47
  define_feature <<-FEATURE
84
48
  @foo
@@ -86,7 +50,7 @@ module Cucumber
86
50
 
87
51
  it { @doc.should have_css_node('.feature .tag', /foo/) }
88
52
  end
89
-
53
+
90
54
  describe "with a narrative" do
91
55
  define_feature <<-FEATURE
92
56
  Feature: Bananas
@@ -98,18 +62,18 @@ module Cucumber
98
62
  it { @doc.should have_css_node('.feature h2', /Bananas/) }
99
63
  it { @doc.should have_css_node('.feature .narrative', /must eat bananas/) }
100
64
  end
101
-
65
+
102
66
  describe "with a background" do
103
67
  define_feature <<-FEATURE
104
68
  Feature: Bananas
105
-
69
+
106
70
  Background:
107
71
  Given there are bananas
108
72
  FEATURE
109
73
 
110
74
  it { @doc.should have_css_node('.feature .background', /there are bananas/) }
111
75
  end
112
-
76
+
113
77
  describe "with a scenario" do
114
78
  define_feature <<-FEATURE
115
79
  Scenario: Monkey eats banana
@@ -119,12 +83,12 @@ module Cucumber
119
83
  it { @doc.should have_css_node('.feature h3', /Monkey eats banana/) }
120
84
  it { @doc.should have_css_node('.feature .scenario .step', /there are bananas/) }
121
85
  end
122
-
86
+
123
87
  describe "with a scenario outline" do
124
88
  define_feature <<-FEATURE
125
89
  Scenario Outline: Monkey eats a balanced diet
126
90
  Given there are <Things>
127
-
91
+
128
92
  Examples: Fruit
129
93
  | Things |
130
94
  | apples |
@@ -134,14 +98,14 @@ module Cucumber
134
98
  | broccoli |
135
99
  | carrots |
136
100
  FEATURE
137
-
101
+
138
102
  it { @doc.should have_css_node('.feature .scenario.outline h4', /Fruit/) }
139
103
  it { @doc.should have_css_node('.feature .scenario.outline h4', /Vegetables/) }
140
104
  it { @doc.css('.feature .scenario.outline h4').length.should == 2}
141
105
  it { @doc.should have_css_node('.feature .scenario.outline table', //) }
142
106
  it { @doc.should have_css_node('.feature .scenario.outline table td', /carrots/) }
143
107
  end
144
-
108
+
145
109
  describe "with a step with a py string" do
146
110
  define_feature <<-FEATURE
147
111
  Scenario: Monkey goes to town
@@ -150,7 +114,7 @@ module Cucumber
150
114
  foo
151
115
  """
152
116
  FEATURE
153
-
117
+
154
118
  it { @doc.should have_css_node('.feature .scenario .val', /foo/) }
155
119
  end
156
120
 
@@ -162,10 +126,10 @@ module Cucumber
162
126
  | foo |
163
127
  | bar |
164
128
  FEATURE
165
-
129
+
166
130
  it { @doc.should have_css_node('.feature .scenario table td', /foo/) }
167
131
  end
168
-
132
+
169
133
  describe "with a table in the background and the scenario" do
170
134
  define_feature <<-FEATURE
171
135
  Background:
@@ -177,10 +141,10 @@ module Cucumber
177
141
  | e | f |
178
142
  | g | h |
179
143
  FEATURE
180
-
144
+
181
145
  it { @doc.css('td').length.should == 8 }
182
146
  end
183
-
147
+
184
148
  describe "with a py string in the background and the scenario" do
185
149
  define_feature <<-FEATURE
186
150
  Background:
@@ -198,37 +162,37 @@ module Cucumber
198
162
  it { @doc.css('.feature .background pre.val').length.should == 1 }
199
163
  it { @doc.css('.feature .scenario pre.val').length.should == 1 }
200
164
  end
201
-
165
+
202
166
  describe "with a step that fails in the scenario" do
203
167
  define_steps do
204
168
  Given(/boo/) { raise 'eek' }
205
169
  end
206
-
170
+
207
171
  define_feature(<<-FEATURE)
208
172
  Scenario: Monkey gets a fright
209
173
  Given boo
210
174
  FEATURE
211
-
175
+
212
176
  it { @doc.should have_css_node('.feature .scenario .step.failed', /eek/) }
213
177
  end
214
-
178
+
215
179
  describe "with a step that fails in the backgound" do
216
180
  define_steps do
217
181
  Given(/boo/) { raise 'eek' }
218
182
  end
219
-
183
+
220
184
  define_feature(<<-FEATURE)
221
185
  Background:
222
186
  Given boo
223
187
  Scenario:
224
188
  Given yay
225
189
  FEATURE
226
-
190
+
227
191
  it { @doc.should have_css_node('.feature .background .step.failed', /eek/) }
228
192
  it { @doc.should_not have_css_node('.feature .scenario .step.failed', //) }
229
193
  it { @doc.should have_css_node('.feature .scenario .step.undefined', /yay/) }
230
194
  end
231
-
195
+
232
196
  end
233
197
  end
234
198
  end
@@ -0,0 +1,73 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ require 'cucumber/formatter/junit'
5
+ require 'nokogiri'
6
+
7
+ module Cucumber::Formatter
8
+ describe Junit do
9
+ extend SpecHelperDsl
10
+ include SpecHelper
11
+
12
+ class TestDoubleJunitFormatter < Junit
13
+ attr_reader :written_files
14
+
15
+ def write_file(feature_filename, data)
16
+ @written_files ||= {}
17
+ @written_files[feature_filename] = data
18
+ end
19
+ end
20
+
21
+ before(:each) do
22
+ File.stub!(:directory?).and_return(true)
23
+ @formatter = TestDoubleJunitFormatter.new(step_mother, '', {})
24
+ end
25
+
26
+ describe "given a single feature" do
27
+ before(:each) do
28
+ run_defined_feature
29
+ @doc = Nokogiri.XML(@formatter.written_files.values.first)
30
+ end
31
+
32
+ describe "with a single scenario" do
33
+ define_feature <<-FEATURE
34
+ Feature: One passing scenario, one failing scenario
35
+
36
+ Scenario: Passing
37
+ Given a passing scenario
38
+ FEATURE
39
+
40
+ it { @doc.to_s.should =~ /One passing scenario, one failing scenario/ }
41
+ end
42
+
43
+ describe "with a scenario outline table" do
44
+ define_steps do
45
+ Given(/.*/) { }
46
+ end
47
+
48
+ define_feature <<-FEATURE
49
+ Feature: Eat things when hungry
50
+
51
+ Scenario Outline: Eat things
52
+ Given <Things>
53
+
54
+ Examples: Good
55
+ | Things |
56
+ | Cucumber |
57
+ | Whisky |
58
+ Examples: Evil
59
+ | Things |
60
+ | Big Mac |
61
+ FEATURE
62
+
63
+ it { @doc.to_s.should =~ /Eat things when hungry/ }
64
+ it { @doc.to_s.should =~ /Cucumber/ }
65
+ it { @doc.to_s.should =~ /Whisky/ }
66
+ it { @doc.to_s.should =~ /Big Mac/ }
67
+ it { @doc.to_s.should_not =~ /Things/ }
68
+ it { @doc.to_s.should_not =~ /Good|Evil/ }
69
+ end
70
+ end
71
+
72
+ end
73
+ end