aslakhellesoy-cucumber 0.2.0.1 → 0.2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,8 +1,15 @@
1
1
  == 0.2.1 (In Git)
2
2
 
3
3
  == Bugfixes
4
+ * After blocks are run in reverse order of registration. (#113 Aslak Hellesøy)
4
5
  * Snippets are showing 'Ands' (#249 Aslak Hellesøy)
5
6
 
7
+ === New features
8
+ * New usage formatter. This is the foundation for editor autocompletion and navigation between steps and step definitions.
9
+
10
+ === Removed features
11
+ * -S/--step-definitions option introduced in 0.2.0 is removed. Use --format usage [--dry-run] [--no-color].
12
+
6
13
  == 0.2.0 2009-03-18
7
14
 
8
15
  This release sports a bunch of new and exciting features, as well a major rewrite of Cucumber's internals.
data/Manifest.txt CHANGED
@@ -199,6 +199,7 @@ features/report_called_undefined_steps.feature
199
199
  features/step_definitions/cucumber_steps.rb
200
200
  features/step_definitions/extra_steps.rb
201
201
  features/support/env.rb
202
+ features/usage.feature
202
203
  gem_tasks/deployment.rake
203
204
  gem_tasks/environment.rake
204
205
  gem_tasks/features.rake
@@ -252,6 +253,7 @@ lib/cucumber/formatter/profile.rb
252
253
  lib/cucumber/formatter/progress.rb
253
254
  lib/cucumber/formatter/rerun.rb
254
255
  lib/cucumber/formatter/unicode.rb
256
+ lib/cucumber/formatter/usage.rb
255
257
  lib/cucumber/formatters/unicode.rb
256
258
  lib/cucumber/jbehave.rb
257
259
  lib/cucumber/languages.yml
@@ -1,7 +1,11 @@
1
+ # See http://wiki.github.com/aslakhellesoy/cucumber/sinatra
2
+ # for more details about Sinatra with Cucumber
3
+
1
4
  # Sinatra
2
- require File.join(File.dirname(__FILE__), *%w[.. .. app])
5
+ app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
6
+ require app_file
3
7
  # Force the application name because polyglot breaks the auto-detection logic.
4
- Sinatra::Application.app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
8
+ Sinatra::Application.app_file = app_file
5
9
 
6
10
  # RSpec
7
11
  require 'spec/expectations'
@@ -0,0 +1,11 @@
1
+ Feature: pending method causes failure in Scenario Outlines
2
+
3
+ Scenario Outline: blah
4
+ Given this is pending until we fix it
5
+ Given context with <Stuff>
6
+ When action
7
+ Then outcome with <Blah>
8
+
9
+ Examples:
10
+ | Stuff | Blah |
11
+ | Cheese | Pepper Jack |
@@ -0,0 +1,15 @@
1
+ Given /^this is pending until we fix it$/ do
2
+ pending
3
+ end
4
+
5
+ Given /^context with Cheese$/ do
6
+ pending
7
+ end
8
+
9
+ When /^action$/ do
10
+ pending
11
+ end
12
+
13
+ Then /^outcome with Pepper Jack$/ do
14
+ pending
15
+ end
@@ -0,0 +1,59 @@
1
+ Feature: Cucumber command line
2
+ In order to be able to write an editor plugin that can jump between
3
+ steps and step definitions, Cucumber must provide a way to
4
+ display how they are related.
5
+
6
+ Scenario: List usage of step definitions
7
+ When I run cucumber features --format usage --dry-run
8
+ Then it should pass with
9
+ """
10
+ /^passing without a table$/ # features/step_definitions/sample_steps.rb:12
11
+ Given passing without a table # features/background/failing_background_after_success.feature:4
12
+ Given <state> without a table # features/outline_sample.feature:6
13
+ Given <other_state> without a table # features/outline_sample.feature:7
14
+ /^failing without a table$/ # features/step_definitions/sample_steps.rb:15
15
+ Given failing without a table # features/background/failing_background.feature:4
16
+ Given failing without a table # features/background/scenario_outline_failing_background.feature:4
17
+ /^a step definition that calls an undefined step$/ # features/step_definitions/sample_steps.rb:19
18
+ Given a step definition that calls an undefined step # features/call_undefined_step_from_step_def.feature:4
19
+ /^call step "(.*)"$/ # features/step_definitions/sample_steps.rb:23
20
+ Given call step "a step definition that calls an undefined step" # features/call_undefined_step_from_step_def.feature:7
21
+ /^'(.+)' cukes$/ # features/step_definitions/sample_steps.rb:27
22
+ And '10' cukes # features/background/failing_background.feature:5
23
+ Given '10' cukes # features/background/passing_background.feature:4
24
+ Given '10' cukes # features/background/scenario_outline_passing_background.feature:4
25
+ /^I should have '(.+)' cukes$/ # features/step_definitions/sample_steps.rb:31
26
+ Then I should have '10' cukes # features/background/failing_background.feature:8
27
+ Then I should have '10' cukes # features/background/failing_background.feature:11
28
+ Then I should have '10' cukes # features/background/passing_background.feature:7
29
+ Then I should have '10' cukes # features/background/passing_background.feature:10
30
+ Then I should have '10' cukes # features/background/pending_background.feature:7
31
+ Then I should have '10' cukes # features/background/pending_background.feature:10
32
+ Then I should have '<count>' cukes # features/background/scenario_outline_failing_background.feature:7
33
+ Then I should have '<count>' cukes # features/background/scenario_outline_failing_background.feature:13
34
+ Then I should have '<count>' cukes # features/background/scenario_outline_passing_background.feature:7
35
+ Then I should have '<count>' cukes # features/background/scenario_outline_passing_background.feature:13
36
+ /^'(.+)' global cukes$/ # features/step_definitions/sample_steps.rb:35
37
+ And '10' global cukes # features/background/failing_background_after_success.feature:5
38
+ /^I should have '(.+)' global cukes$/ # features/step_definitions/sample_steps.rb:42
39
+ Then I should have '10' global cukes # features/background/failing_background_after_success.feature:8
40
+ Then I should have '10' global cukes # features/background/failing_background_after_success.feature:11
41
+ /^table$/ # features/step_definitions/sample_steps.rb:46
42
+ Given table # features/background/multiline_args_background.feature:4
43
+ /^multiline string$/ # features/step_definitions/sample_steps.rb:50
44
+ And multiline string # features/background/multiline_args_background.feature:7
45
+ /^the table should be$/ # features/step_definitions/sample_steps.rb:54
46
+ Then the table should be # features/background/multiline_args_background.feature:14
47
+ Then the table should be # features/background/multiline_args_background.feature:24
48
+ /^the multiline string should be$/ # features/step_definitions/sample_steps.rb:58
49
+ Then the multiline string should be # features/background/multiline_args_background.feature:17
50
+ Then the multiline string should be # features/background/multiline_args_background.feature:27
51
+ /^passing$/ # features/step_definitions/sample_steps.rb:5
52
+ Given passing # features/sample.feature:10
53
+ /^failing expectation$/ # features/step_definitions/sample_steps.rb:62
54
+ Given failing expectation # features/failing_expectation.feature:4
55
+ /^failing$/ # features/step_definitions/sample_steps.rb:8
56
+ Given failing # features/sample.feature:16
57
+
58
+ """
59
+
@@ -82,7 +82,7 @@ module Cucumber
82
82
  if [Cucumber.keyword_hash['and'], Cucumber.keyword_hash['but']].index(@step.keyword) && previous
83
83
  previous.actual_keyword
84
84
  else
85
- @step.keyword
85
+ keyword
86
86
  end
87
87
  end
88
88
 
@@ -94,6 +94,10 @@ module Cucumber
94
94
  @step.text_length
95
95
  end
96
96
 
97
+ def keyword
98
+ @step.keyword
99
+ end
100
+
97
101
  def file_colon_line
98
102
  @step.file_colon_line
99
103
  end
@@ -137,9 +137,6 @@ module Cucumber
137
137
  opts.on("--no-diff", "Disable diff output on failing expectations.") do
138
138
  @options[:diff_enabled] = false
139
139
  end
140
- opts.on("-S", "--step-definitions", "Print the regexp and line of all step definitions, then exit.") do
141
- @options[:print_step_definitions] = true
142
- end
143
140
  opts.on_tail("--version", "Show version.") do
144
141
  @out_stream.puts VERSION::STRING
145
142
  Kernel.exit
@@ -175,10 +172,6 @@ module Cucumber
175
172
  @options[:diff_enabled]
176
173
  end
177
174
 
178
- def print_step_definitions?
179
- @options[:print_step_definitions]
180
- end
181
-
182
175
  def load_language
183
176
  if Cucumber.language_incomplete?(@options[:lang])
184
177
  list_keywords_and_exit(@options[:lang])
@@ -224,11 +217,12 @@ module Cucumber
224
217
 
225
218
  def formatter_class(format)
226
219
  case format
220
+ when 'html' then Formatter::Html
227
221
  when 'pretty' then Formatter::Pretty
228
- when 'progress' then Formatter::Progress
229
222
  when 'profile' then Formatter::Profile
223
+ when 'progress' then Formatter::Progress
230
224
  when 'rerun' then Formatter::Rerun
231
- when 'html' then Formatter::Html
225
+ when 'usage' then Formatter::Usage
232
226
  else
233
227
  constantize(format)
234
228
  end
@@ -32,13 +32,6 @@ module Cucumber
32
32
  step_mother.options = configuration.options
33
33
 
34
34
  require_files
35
-
36
- if(configuration.print_step_definitions?)
37
- step_mother.print_step_definitions(@out_stream)
38
- Kernel.exit(0)
39
- return # In specs, exit is stubbed
40
- end
41
-
42
35
  enable_diffing
43
36
 
44
37
  features = load_plain_text_features
@@ -1 +1 @@
1
- %w{color_io pretty progress profile rerun html}.each{|n| require "cucumber/formatter/#{n}"}
1
+ %w{color_io pretty progress profile rerun html usage}.each{|n| require "cucumber/formatter/#{n}"}
@@ -1,5 +1,13 @@
1
1
  module Cucumber
2
2
  module Formatter
3
+ # This formatter keeps track of all failing features and print out their location.
4
+ # Example:
5
+ #
6
+ # features/foo.feature:34 features/bar.feature:11:76:81
7
+ #
8
+ # This formatter is used by AutoTest - it will use the output to decide what
9
+ # to run the next time, simply passing the output string on the command line.
10
+ #
3
11
  class Rerun < Ast::Visitor
4
12
  def initialize(step_mother, io, options)
5
13
  super(step_mother)
@@ -0,0 +1,69 @@
1
+ require 'cucumber/formatter/progress'
2
+
3
+ module Cucumber
4
+ module Formatter
5
+ class Usage < Ast::Visitor
6
+ include Console
7
+
8
+ def initialize(step_mother, io, options)
9
+ super(step_mother)
10
+ @io = io
11
+ @options = options
12
+ @step_definitions = Hash.new { |h,step_definition| h[step_definition] = [] }
13
+ @locations = []
14
+ end
15
+
16
+ def visit_features(features)
17
+ super
18
+ print_summary
19
+ end
20
+
21
+ def visit_step(step)
22
+ @step = step
23
+ super
24
+ end
25
+
26
+ def visit_step_name(keyword, step_match, status, source_indent, background)
27
+ if step_match.step_definition
28
+ location = @step.file_colon_line
29
+ return if @locations.index(location)
30
+ @locations << location
31
+
32
+ description = format_step(keyword, step_match, status, nil)
33
+ length = (keyword + step_match.format_args).jlength
34
+ @step_definitions[step_match.step_definition] << [step_match, description, length, location]
35
+ end
36
+ end
37
+
38
+ def print_summary
39
+ sorted_defs = @step_definitions.keys.sort_by{|step_definition| step_definition.backtrace_line}
40
+
41
+ sorted_defs.each do |step_definition|
42
+ step_matches_and_descriptions = @step_definitions[step_definition].sort_by do |step_match_and_description|
43
+ step_match = step_match_and_description[0]
44
+ step_match.step_definition.regexp.inspect
45
+ end
46
+
47
+ step_matches = step_matches_and_descriptions.map{|step_match_and_description| step_match_and_description[0]}
48
+
49
+ lengths = step_matches_and_descriptions.map do |step_match_and_description|
50
+ step_match_and_description[2]
51
+ end
52
+ lengths << step_definition.text_length
53
+ max_length = lengths.max
54
+
55
+ @io.print step_definition.regexp.inspect
56
+ @io.puts format_string(" # #{step_definition.file_colon_line}".indent(max_length - step_definition.text_length), :comment)
57
+ step_matches_and_descriptions.each do |step_match_and_description|
58
+ step_match = step_match_and_description[0]
59
+ description = step_match_and_description[1]
60
+ length = step_match_and_description[2]
61
+ file_colon_line = step_match_and_description[3]
62
+ @io.print " #{description}"
63
+ @io.puts format_string(" # #{file_colon_line}".indent(max_length - length), :comment)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -27,6 +27,7 @@ if defined?(JRUBY_VERSION)
27
27
  end
28
28
 
29
29
  def step_match(name_to_match, name_to_report)
30
+ raise "FIXME"
30
31
  if(match = name_to_match.match(@regexp))
31
32
  StepMatch.new(self, name_to_match, name_to_report, match.captures)
32
33
  else
@@ -24,7 +24,7 @@ end
24
24
  # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
25
25
  Test::Unit.run = true if Test::Unit.respond_to?(:run=)
26
26
 
27
- $cucumber_toplevel = self
27
+ $__cucumber_toplevel = self
28
28
 
29
29
  module Cucumber #:nodoc:
30
30
  module Rails
@@ -44,20 +44,21 @@ module Cucumber #:nodoc:
44
44
  def self.use_transactional_fixtures
45
45
  World.use_transactional_fixtures = true
46
46
  if defined?(ActiveRecord::Base)
47
- $cucumber_toplevel.Before do
48
- if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
49
- ActiveRecord::Base.connection.increment_open_transactions
47
+ $__cucumber_toplevel.Before do
48
+ @__cucumber_ar_connection = ActiveRecord::Base.connection
49
+ if @__cucumber_ar_connection.respond_to?(:increment_open_transactions)
50
+ @__cucumber_ar_connection.increment_open_transactions
50
51
  else
51
52
  ActiveRecord::Base.__send__(:increment_open_transactions)
52
53
  end
53
- ActiveRecord::Base.connection.begin_db_transaction
54
+ @__cucumber_ar_connection.begin_db_transaction
54
55
  ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
55
56
  end
56
57
 
57
- $cucumber_toplevel.After do
58
- ActiveRecord::Base.connection.rollback_db_transaction
59
- if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
60
- ActiveRecord::Base.connection.decrement_open_transactions
58
+ $__cucumber_toplevel.After do
59
+ @__cucumber_ar_connection.rollback_db_transaction
60
+ if @__cucumber_ar_connection.respond_to?(:decrement_open_transactions)
61
+ @__cucumber_ar_connection.decrement_open_transactions
61
62
  else
62
63
  ActiveRecord::Base.__send__(:decrement_open_transactions)
63
64
  end
@@ -95,9 +95,5 @@ module Cucumber
95
95
  def text_length
96
96
  @regexp.inspect.jlength
97
97
  end
98
-
99
- def to_s(indent = 0)
100
- @regexp.inspect + (' # ').indent(indent) + file_colon_line
101
- end
102
98
  end
103
99
  end
@@ -13,7 +13,7 @@ module Cucumber
13
13
  @step_definition.invoke(world, all_args, @step_name)
14
14
  end
15
15
 
16
- def format_args(format)
16
+ def format_args(format = lambda{|a| a})
17
17
  @formatted_step_name || @step_definition.format_args(@step_name, format)
18
18
  end
19
19
 
@@ -24,6 +24,10 @@ module Cucumber
24
24
  def backtrace_line
25
25
  @step_definition.backtrace_line
26
26
  end
27
+
28
+ def text_length
29
+ @step_definition.text_length
30
+ end
27
31
  end
28
32
 
29
33
  class NoStepMatch
@@ -45,5 +49,9 @@ module Cucumber
45
49
  def backtrace_line
46
50
  @step.backtrace_line
47
51
  end
52
+
53
+ def text_length
54
+ @step.text_length
55
+ end
48
56
  end
49
57
  end
@@ -101,7 +101,7 @@ module Cucumber
101
101
  end
102
102
 
103
103
  def After(&proc)
104
- (@after_procs ||= []) << proc
104
+ (@after_procs ||= []).unshift(proc)
105
105
  end
106
106
 
107
107
  # Registers a World proc. You can call this method as many times as you
@@ -141,13 +141,6 @@ module Cucumber
141
141
  def snippet_text(step_keyword, step_name)
142
142
  @snippet_generator.snippet_text(step_keyword, step_name)
143
143
  end
144
-
145
- def print_step_definitions(out)
146
- step_definitions.each do |step_definition|
147
- indent = max_step_definition_length - step_definition.text_length
148
- out.puts(step_definition.to_s(indent))
149
- end
150
- end
151
144
 
152
145
  def before_and_after(scenario, skip=false)
153
146
  unless current_world || skip
@@ -3,7 +3,7 @@ module Cucumber #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
5
  TINY = 0
6
- PATCH = 1 # Set to nil for official release
6
+ PATCH = 2 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
@@ -10,18 +10,6 @@ module Cli
10
10
  Kernel.stub!(:exit).and_return(nil)
11
11
  end
12
12
 
13
- it "should print step definitions" do
14
- step_mother = Object.new.extend(StepMother)
15
- step_mother.Given(/Bonjour/) {}
16
- step_mother.Given(/Monde/) {}
17
- @cli = Main.new(%w{-S}, @out)
18
- @cli.execute!(step_mother)
19
- @out.string.should == %{
20
- /Bonjour/ # spec/cucumber/cli/main_spec.rb:15
21
- /Monde/ # spec/cucumber/cli/main_spec.rb:16
22
- }.lstrip
23
- end
24
-
25
13
  describe "verbose mode" do
26
14
 
27
15
  before(:each) do
@@ -54,7 +42,7 @@ module Cli
54
42
  describe "diffing" do
55
43
 
56
44
  before :each do
57
- @configuration = mock('Configuration', :null_object => true, :print_step_definitions? => nil)
45
+ @configuration = mock('Configuration', :null_object => true)
58
46
  Configuration.should_receive(:new).and_return(@configuration)
59
47
 
60
48
  @step_mother = mock('StepMother', :null_object => true)
@@ -58,15 +58,7 @@ module Cucumber
58
58
  step_match("Outside").invoke(@world, nil)
59
59
  end.should raise_error(Pending, "Do me!")
60
60
  end
61
-
62
- it "should have a #to_s suitable for automcompletion" do
63
- stepdef = Given /Hello (.*)/ do
64
- end
65
-
66
- stepdef.to_s.should == '/Hello (.*)/ # spec/cucumber/step_definition_spec.rb:63'
67
- stepdef.to_s(2).should == '/Hello (.*)/ # spec/cucumber/step_definition_spec.rb:63'
68
- end
69
-
61
+
70
62
  it "should allow announce" do
71
63
  v = mock('visitor')
72
64
  v.should_receive(:announce).with('wasup')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslakhellesoy-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.1
4
+ version: 0.2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-20 00:00:00 -07:00
12
+ date: 2009-03-21 00:00:00 -07:00
13
13
  default_executable: cucumber
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -264,9 +264,11 @@ files:
264
264
  - examples/tickets/features/180.feature
265
265
  - examples/tickets/features/236.feature
266
266
  - examples/tickets/features/241.feature
267
+ - examples/tickets/features/248.feature
267
268
  - examples/tickets/features/lib/eatting_machine.rb
268
269
  - examples/tickets/features/lib/pantry.rb
269
270
  - examples/tickets/features/scenario_outline.feature
271
+ - examples/tickets/features/step_definitons/248_steps.rb
270
272
  - examples/tickets/features/step_definitons/scenario_outline_steps.rb
271
273
  - examples/tickets/features/step_definitons/tickets_steps.rb
272
274
  - examples/tickets/features/tickets.feature
@@ -284,6 +286,7 @@ files:
284
286
  - features/step_definitions/cucumber_steps.rb
285
287
  - features/step_definitions/extra_steps.rb
286
288
  - features/support/env.rb
289
+ - features/usage.feature
287
290
  - gem_tasks/deployment.rake
288
291
  - gem_tasks/environment.rake
289
292
  - gem_tasks/features.rake
@@ -337,6 +340,7 @@ files:
337
340
  - lib/cucumber/formatter/progress.rb
338
341
  - lib/cucumber/formatter/rerun.rb
339
342
  - lib/cucumber/formatter/unicode.rb
343
+ - lib/cucumber/formatter/usage.rb
340
344
  - lib/cucumber/formatters/unicode.rb
341
345
  - lib/cucumber/jbehave.rb
342
346
  - lib/cucumber/languages.yml