aslakhellesoy-cucumber 0.1.100.1 → 0.1.100.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,6 +92,7 @@ pure Ruby users have been enjoying for a while.
92
92
  * Pending steps in > steps called from steps (#65 Aslak Hellesøy)
93
93
 
94
94
  === New features
95
+ * Added World#announce(announcment) which lets you output text to the formatted output (#222 Rob Kaufmann)
95
96
  * Added Table#transpose to to allow use of vertically aligned table keys (Torbjørn Vatn, Aslak Hellesøy)
96
97
  * Added Table#map_headers to to allow use of more readable headers (Rob Holland)
97
98
  * New -S/--step-definitions option. Useful (among other things) for tools that implement automcompletion. (#208 Aslak Hellesøy).
@@ -321,4 +321,3 @@ spec/cucumber/treetop_parser/with_tags.feature
321
321
  spec/cucumber/world/pending_spec.rb
322
322
  spec/spec.opts
323
323
  spec/spec_helper.rb
324
- target/maven-archiver/pom.properties
@@ -158,7 +158,7 @@ module Cucumber
158
158
  row.map do |cell|
159
159
  cell_with_replaced_args = cell
160
160
  arguments.each do |name, value|
161
- cell_with_replaced_args = value && !cell.nil? ? cell_with_replaced_args.gsub(name, value) : nil
161
+ cell_with_replaced_args = value && cell_with_replaced_args ? cell_with_replaced_args.gsub(name, value) : nil
162
162
  end
163
163
  cell_with_replaced_args
164
164
  end
@@ -116,6 +116,10 @@ module Cucumber
116
116
 
117
117
  def visit_exception(exception, status)
118
118
  end
119
+
120
+ def announce(announcement)
121
+ end
122
+
119
123
  end
120
124
  end
121
125
  end
@@ -1,6 +1,5 @@
1
1
  module Cucumber
2
2
  class Broadcaster
3
-
4
3
  def initialize(receivers = [])
5
4
  @receivers = receivers
6
5
  end
@@ -10,6 +9,5 @@ module Cucumber
10
9
  receiver.__send__(method_name, *args)
11
10
  end
12
11
  end
13
-
14
12
  end
15
13
  end
@@ -44,6 +44,7 @@ module Cucumber
44
44
  features = load_plain_text_features
45
45
 
46
46
  visitor = configuration.build_formatter_broadcaster(step_mother)
47
+ step_mother.visitor = visitor # Needed to support World#announce
47
48
  visitor.visit_features(features)
48
49
 
49
50
  failure = step_mother.steps(:failed).any? ||
@@ -86,6 +86,12 @@ module Cucumber
86
86
  @io.flush
87
87
  end
88
88
 
89
+ def announce(announcement)
90
+ @io.puts
91
+ @io.puts(format_string(announcement, :tag))
92
+ @io.flush
93
+ end
94
+
89
95
  private
90
96
 
91
97
  def dump_count(count, what, state=nil)
@@ -116,6 +116,10 @@ module Cucumber
116
116
  @builder.td(value, :class => status)
117
117
  end
118
118
 
119
+ def announce(announcement)
120
+ @builder.pre(announcement, :class => 'announcement')
121
+ end
122
+
119
123
  private
120
124
 
121
125
  def inline_css
@@ -126,4 +130,4 @@ module Cucumber
126
130
 
127
131
  end
128
132
  end
129
- end
133
+ end
@@ -31,7 +31,7 @@ module Cucumber
31
31
  def visit_table_cell_value(value, width, status)
32
32
  progress(status) if (status != :thead) && !@multiline_arg
33
33
  end
34
-
34
+
35
35
  private
36
36
 
37
37
  def print_summary
@@ -57,4 +57,4 @@ module Cucumber
57
57
 
58
58
  end
59
59
  end
60
- end
60
+ end
@@ -32,4 +32,4 @@ module Cucumber
32
32
  end
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -55,7 +55,7 @@ module Cucumber
55
55
  end
56
56
  end
57
57
 
58
- attr_writer :snippet_generator, :options
58
+ attr_writer :snippet_generator, :options, :visitor
59
59
 
60
60
  def step_visited(step)
61
61
  steps << step unless steps.index(step)
@@ -180,6 +180,7 @@ module Cucumber
180
180
 
181
181
  @current_world.extend(World)
182
182
  @current_world.__cucumber_step_mother = self
183
+ @current_world.__cucumber_visitor = @visitor
183
184
 
184
185
  @current_world.extend(::Spec::Matchers) if defined?(::Spec::Matchers)
185
186
  @current_world
@@ -3,7 +3,7 @@ module Cucumber #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
5
  TINY = 100
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
@@ -7,7 +7,7 @@ module Cucumber
7
7
  end
8
8
  end
9
9
 
10
- attr_writer :__cucumber_step_mother, :__cucumber_current_step
10
+ attr_writer :__cucumber_step_mother, :__cucumber_visitor, :__cucumber_current_step
11
11
 
12
12
  # Call a step from within a step definition
13
13
  def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
@@ -26,6 +26,17 @@ module Cucumber
26
26
  @table_parser.parse_or_fail(text.strip, file, line_offset)
27
27
  end
28
28
 
29
+ # Output +announcement+ alongside the formatted output.
30
+ # This is an alternative to using Kernel#puts - it will display
31
+ # nicer, and in all outputs (in case you use several formatters)
32
+ #
33
+ # Beware that the output will be printed *before* the corresponding
34
+ # step. This is because the step itself will not be printed until
35
+ # after it has run, so it can be coloured according to its status.
36
+ def announce(announcement)
37
+ @__cucumber_visitor.announce(announcement)
38
+ end
39
+
29
40
  def pending(message = "TODO")
30
41
  if block_given?
31
42
  begin
@@ -111,11 +111,11 @@ module Cucumber
111
111
 
112
112
  it "should not raise an error when there are nil values in the table" do
113
113
  table = Table.new([
114
- ['book'],
115
- [nil]
114
+ ['book', 'qty'],
115
+ ['<book>', nil],
116
116
  ])
117
117
  lambda{
118
- table.arguments_replaced({'<book>' => 'The great sheep chase'})
118
+ table.arguments_replaced({'<book>' => nil, '<qty>' => '5'})
119
119
  }.should_not raise_error
120
120
  end
121
121
 
@@ -2,13 +2,14 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  module Cucumber
4
4
  describe Broadcaster do
5
+ before do
6
+ @receiver = mock('receiver')
7
+ @broadcaster = Broadcaster.new([@receiver])
8
+ end
5
9
 
6
10
  it "should broadcast methods to registered objects" do
7
- receiver = mock('receiver')
8
- broadcaster = Broadcaster.new([receiver])
9
-
10
- receiver.should_receive(:konbanwa).with('good evening')
11
- broadcaster.konbanwa('good evening')
11
+ @receiver.should_receive(:konbanwa).with('good evening')
12
+ @broadcaster.konbanwa('good evening')
12
13
  end
13
14
  end
14
15
  end
@@ -66,5 +66,16 @@ module Cucumber
66
66
  stepdef.to_s.should == '/Hello (.*)/ # spec/cucumber/step_definition_spec.rb:63'
67
67
  stepdef.to_s(2).should == '/Hello (.*)/ # spec/cucumber/step_definition_spec.rb:63'
68
68
  end
69
+
70
+ it "should allow announce" do
71
+ v = mock('visitor')
72
+ v.should_receive(:announce).with('wasup')
73
+ self.visitor = v
74
+ world = new_world!
75
+ Given /Loud/ do
76
+ announce 'wasup'
77
+ end
78
+ step_match("Loud").invoke(world, nil)
79
+ end
69
80
  end
70
81
  end
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.1.100.1
4
+ version: 0.1.100.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"