gherkin 2.3.0-java → 2.3.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.3.1
data/gherkin.gemspec CHANGED
@@ -54,5 +54,5 @@ Gem::Specification.new do |s|
54
54
  s.add_development_dependency('rake', '~> 0.8.7')
55
55
  s.add_development_dependency('awesome_print', '~> 0.2.1')
56
56
  s.add_development_dependency('rspec', '~> 2.0.1')
57
- s.add_development_dependency('cucumber', '~> 0.9.4')
57
+ s.add_development_dependency('cucumber', '~> 0.10.0')
58
58
  end
@@ -10,28 +10,28 @@ module Gherkin
10
10
  #
11
11
  # The colours that you can change are:
12
12
  #
13
- # * <tt>undefined</tt> - defaults to <tt>yellow</tt>
14
- # * <tt>pending</tt> - defaults to <tt>yellow</tt>
15
- # * <tt>pending_param</tt> - defaults to <tt>yellow,bold</tt>
16
- # * <tt>executing</tt> - defaults to <tt>magenta</tt>
17
- # * <tt>executing_param</tt> - defaults to <tt>magenta,bold</tt>
18
- # * <tt>failed</tt> - defaults to <tt>red</tt>
19
- # * <tt>failed_param</tt> - defaults to <tt>red,bold</tt>
20
- # * <tt>passed</tt> - defaults to <tt>green</tt>
21
- # * <tt>passed_param</tt> - defaults to <tt>green,bold</tt>
22
- # * <tt>outline</tt> - defaults to <tt>cyan</tt>
23
- # * <tt>outline_param</tt> - defaults to <tt>cyan,bold</tt>
24
- # * <tt>skipped</tt> - defaults to <tt>cyan</tt>
25
- # * <tt>skipped_param</tt> - defaults to <tt>cyan,bold</tt>
26
- # * <tt>comment</tt> - defaults to <tt>grey</tt>
27
- # * <tt>tag</tt> - defaults to <tt>cyan</tt>
13
+ # <tt>undefined</tt>:: defaults to <tt>yellow</tt>
14
+ # <tt>pending</tt>:: defaults to <tt>yellow</tt>
15
+ # <tt>pending_arg</tt>:: defaults to <tt>yellow,bold</tt>
16
+ # <tt>executing</tt>:: defaults to <tt>magenta</tt>
17
+ # <tt>executing_arg</tt>:: defaults to <tt>magenta,bold</tt>
18
+ # <tt>failed</tt>:: defaults to <tt>red</tt>
19
+ # <tt>failed_arg</tt>:: defaults to <tt>red,bold</tt>
20
+ # <tt>passed</tt>:: defaults to <tt>green</tt>
21
+ # <tt>passed_arg</tt>:: defaults to <tt>green,bold</tt>
22
+ # <tt>outline</tt>:: defaults to <tt>cyan</tt>
23
+ # <tt>outline_arg</tt>:: defaults to <tt>cyan,bold</tt>
24
+ # <tt>skipped</tt>:: defaults to <tt>cyan</tt>
25
+ # <tt>skipped_arg</tt>:: defaults to <tt>cyan,bold</tt>
26
+ # <tt>comment</tt>:: defaults to <tt>grey</tt>
27
+ # <tt>tag</tt>:: defaults to <tt>cyan</tt>
28
28
  #
29
29
  # For instance, if your shell has a black background and a green font (like the
30
30
  # "Homebrew" settings for OS X' Terminal.app), you may want to override passed
31
31
  # steps to be white instead of green. Examples:
32
32
  #
33
33
  # export GHERKIN_COLORS="passed=white"
34
- # export GHERKIN_COLORS="passed=white,bold:passed_param=white,bold,underline"
34
+ # export GHERKIN_COLORS="passed=white,bold:passed_arg=white,bold,underline"
35
35
  #
36
36
  # (If you're on Windows, use SET instead of export).
37
37
  # To see what colours and effects are available, just run this in your shell:
@@ -43,7 +43,7 @@ module Gherkin
43
43
  include Term::ANSIColor
44
44
 
45
45
  ALIASES = Hash.new do |h,k|
46
- if k.to_s =~ /(.*)_param/
46
+ if k.to_s =~ /(.*)_arg/
47
47
  h[$1] + ',bold'
48
48
  end
49
49
  end.merge({
@@ -66,13 +66,13 @@ module Gherkin
66
66
  end
67
67
 
68
68
  ALIASES.each do |method, color|
69
- unless method =~ /.*_param/
69
+ unless method =~ /.*_arg$/
70
70
  code = <<-EOF
71
71
  def #{method}(string=nil, &proc)
72
72
  #{ALIASES[method].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method].split(",").length}
73
73
  end
74
- def #{method}_param(string=nil, &proc)
75
- #{ALIASES[method+'_param'].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method+'_param'].split(",").length}
74
+ def #{method}_arg(string=nil, &proc)
75
+ #{ALIASES[method+'_arg'].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method+'_arg'].split(",").length}
76
76
  end
77
77
  EOF
78
78
  eval(code)
@@ -27,6 +27,9 @@ module Gherkin
27
27
  @gherkin_object = feature.to_hash
28
28
  end
29
29
 
30
+ def steps(steps)
31
+ end
32
+
30
33
  def background(background)
31
34
  feature_elements << background.to_hash
32
35
  end
@@ -44,7 +47,7 @@ module Gherkin
44
47
  end
45
48
 
46
49
  def step(step)
47
- steps << step.to_hash
50
+ current_steps << step.to_hash
48
51
  end
49
52
 
50
53
  def match(match)
@@ -77,12 +80,12 @@ module Gherkin
77
80
  feature_element['examples'] ||= []
78
81
  end
79
82
 
80
- def steps
83
+ def current_steps
81
84
  feature_element['steps'] ||= []
82
85
  end
83
86
 
84
87
  def last_step
85
- steps[-1]
88
+ current_steps[-1]
86
89
  end
87
90
 
88
91
  def embeddings
@@ -129,12 +129,12 @@ module Gherkin
129
129
  formatter.step(self)
130
130
  end
131
131
 
132
- def status
133
- result ? result.status : 'undefined'
134
- end
135
-
136
- def arguments
137
- result ? result.arguments : []
132
+ def outline_args
133
+ offset = 0
134
+ name.scan(/<[^<]*>/).map do |val|
135
+ offset = name.index(val, offset)
136
+ Argument.new(offset, val)
137
+ end
138
138
  end
139
139
 
140
140
  def to_hash
@@ -61,23 +61,29 @@ module Gherkin
61
61
 
62
62
  def step(step)
63
63
  @step = step
64
+ @step_index += 1 if @step_index
64
65
  match(Model::Match.new([], nil)) if @monochrome
65
66
  end
66
67
 
67
68
  def match(match)
68
- print_step(format('executing'), format('executing_param'), match.arguments, match.location)
69
+ @match = match
70
+ print_step('executing', @match.arguments, @match.location)
69
71
  end
70
72
 
71
73
  def result(result)
72
- # TODO: Print error message
74
+ @io.write("\033[1A")
75
+ print_step(result.status, @match.arguments, @match.location)
73
76
  end
74
77
 
75
- def print_step(text_format, arg_format, arguments, location)
78
+ def print_step(status, arguments, location)
79
+ text_format = format(status)
80
+ arg_format = arg_format(status)
81
+
76
82
  print_comments(@step.comments, ' ')
77
83
  @io.write(' ')
78
- text_format.write_text(@io, @step.keyword)
84
+ @io.write(text_format.text(@step.keyword))
79
85
  @step_printer.write_step(@io, text_format, arg_format, @step.name, arguments)
80
- print_indented_stepdef_location!(location) if location
86
+ print_indented_step_location(location) if location
81
87
 
82
88
  @io.puts
83
89
  case @step.multiline_arg
@@ -89,8 +95,8 @@ module Gherkin
89
95
  end
90
96
 
91
97
  class MonochromeFormat
92
- def write_text(io, text)
93
- io.write(text)
98
+ def text(text)
99
+ text
94
100
  end
95
101
  end
96
102
 
@@ -101,17 +107,13 @@ module Gherkin
101
107
  @status = status
102
108
  end
103
109
 
104
- def write_text(io, text)
105
- io.write(self.__send__(@status, text))
110
+ def text(text)
111
+ self.__send__(@status, text)
106
112
  end
107
113
  end
108
114
 
109
- def text_format(step)
110
- format(step.status)
111
- end
112
-
113
- def arg_format(step)
114
- format(step.status + '_param')
115
+ def arg_format(key)
116
+ format("#{key}_arg")
115
117
  end
116
118
 
117
119
  def format(key)
@@ -216,8 +218,8 @@ module Gherkin
216
218
  ' ' * indent + ' ' + comments("# #{@uri}:#{line}")
217
219
  end
218
220
 
219
- def print_indented_stepdef_location!(location)
220
- indent = @max_step_length - @step_lengths[@step_index+=1]
221
+ def print_indented_step_location(location)
222
+ indent = @max_step_length - @step_lengths[@step_index]
221
223
  return if location.nil?
222
224
  @io.write(' ' * indent + ' ' + comments("# #{location}"))
223
225
  end
@@ -6,11 +6,11 @@ module Gherkin
6
6
 
7
7
  text_start = 0
8
8
  arguments.each do |arg|
9
- text_format.write_text(io, unpacked_step_name[text_start..arg.offset-1].pack("U*")) unless arg.offset == 0
10
- arg_format.write_text(io, arg.val)
9
+ io.write(text_format.text(unpacked_step_name[text_start..arg.offset-1].pack("U*"))) unless arg.offset == 0
10
+ io.write(arg_format.text(arg.val))
11
11
  text_start = arg.offset + arg.val.unpack("U*").length
12
12
  end
13
- text_format.write_text(io, unpacked_step_name[text_start..-1].pack("U*")) unless text_start == unpacked_step_name.length
13
+ io.write(text_format.text(unpacked_step_name[text_start..-1].pack("U*"))) unless text_start == unpacked_step_name.length
14
14
  end
15
15
  end
16
16
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'gherkin/formatter/model'
3
+ require 'gherkin/formatter/argument'
3
4
 
4
5
  module Gherkin
5
6
  module Formatter
@@ -10,6 +11,18 @@ module Gherkin
10
11
  tags.to_a.uniq.length.should == 2
11
12
  end
12
13
  end
14
+
15
+ describe Step do
16
+ it "should provide arguments for outline tokens" do
17
+ step = Step.new([], 'Given ', "I have <number> cukes in <whose> belly", 10)
18
+ step.outline_args.map{|arg| [arg.offset, arg.val]}.should == [[7, "<number>"], [25, "<whose>"]]
19
+ end
20
+
21
+ it "should provide no arguments when there are no outline tokens" do
22
+ step = Step.new([], 'Given ', "I have 33 cukes in my belly", 10)
23
+ step.outline_args.to_a.should == []
24
+ end
25
+ end
13
26
  end
14
27
  end
15
28
  end
@@ -30,12 +30,12 @@ module Gherkin
30
30
 
31
31
  before do
32
32
  @io = StringIO.new
33
- @colf = Gherkin::Formatter::PrettyFormatter.new(@io, false)
33
+ @f = Gherkin::Formatter::PrettyFormatter.new(@io, false)
34
34
  end
35
35
 
36
36
  it "should print comments when scenario is longer" do
37
- @colf.uri("features/foo.feature")
38
- @colf.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
37
+ @f.uri("features/foo.feature")
38
+ @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
39
39
 
40
40
  step1 = Model::Step.new([], "Given ", "some stuff", 5)
41
41
  match1 = Model::Match.new([], "features/step_definitions/bar.rb:56")
@@ -45,44 +45,47 @@ module Gherkin
45
45
  match2 = Model::Match.new([], "features/step_definitions/bar.rb:96")
46
46
  result2 = Model::Result.new('passed', nil)
47
47
 
48
- @colf.steps([step1, step2])
49
- @colf.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
48
+ @f.steps([step1, step2])
49
+ @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
50
50
 
51
- @colf.step(step1)
52
- @colf.match(match1)
53
- @colf.result(result1)
51
+ @f.step(step1)
52
+ @f.match(match1)
53
+ @f.result(result1)
54
54
 
55
- @colf.step(step2)
56
- @colf.match(match2)
57
- @colf.result(result2)
55
+ @f.step(step2)
56
+ @f.match(match2)
57
+ @f.result(result2)
58
58
 
59
59
  assert_io(%{Feature: Hello
60
60
  World
61
61
 
62
62
  Scenario: The scenario #{grey('# features/foo.feature:4')}
63
63
  #{magenta('Given ')}#{magenta('some stuff')} #{grey('# features/step_definitions/bar.rb:56')}
64
+ \033[1A #{green('Given ')}#{green('some stuff')} #{grey('# features/step_definitions/bar.rb:56')}
64
65
  #{magenta('When ')}#{magenta('foo')} #{grey('# features/step_definitions/bar.rb:96')}
66
+ \033[1A #{green('When ')}#{green('foo')} #{grey('# features/step_definitions/bar.rb:96')}
65
67
  })
66
68
  end
67
69
 
68
70
  it "should print comments when step is longer" do
69
- @colf.uri("features/foo.feature")
70
- @colf.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
71
+ @f.uri("features/foo.feature")
72
+ @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
71
73
  step = Model::Step.new([], "Given ", "some stuff that is longer", 5)
72
74
  match = Model::Match.new([], "features/step_definitions/bar.rb:56")
73
75
  result = Model::Result.new('passed', nil)
74
76
 
75
- @colf.steps([step])
76
- @colf.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
77
- @colf.step(step)
78
- @colf.match(match)
79
- @colf.result(result)
77
+ @f.steps([step])
78
+ @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
79
+ @f.step(step)
80
+ @f.match(match)
81
+ @f.result(result)
80
82
 
81
83
  assert_io(%{Feature: Hello
82
84
  World
83
85
 
84
86
  Scenario: The scenario #{grey('# features/foo.feature:4')}
85
87
  #{magenta('Given ')}#{magenta('some stuff that is longer')} #{grey('# features/step_definitions/bar.rb:56')}
88
+ \033[1A #{green('Given ')}#{green('some stuff that is longer')} #{grey('# features/step_definitions/bar.rb:56')}
86
89
  })
87
90
  end
88
91
 
@@ -91,16 +94,22 @@ module Gherkin
91
94
  match = Model::Match.new([Gherkin::Formatter::Argument.new(7, '999')], nil)
92
95
  result = Model::Result.new('passed', nil)
93
96
 
94
- @colf.steps([step])
95
- @colf.step(step)
96
- @colf.match(match)
97
- @colf.result(result)
97
+ @f.steps([step])
98
+ @f.step(step)
99
+ @f.match(match)
100
+ @f.result(result)
98
101
 
99
102
  if defined?(JRUBY_VERSION)
100
103
  # Not terribly readable. The result on Java is different because JANSI uses semicolons when there are several codes.
101
- assert_io(" \e[35mGiven \e[0m\e[35mI have \e[0m\e[35;1m999\e[0m\e[35m cukes in my belly\e[0m\n")
104
+ assert_io(
105
+ " \e[35mGiven \e[0m\e[35mI have \e[0m\e[35;1m999\e[0m\e[35m cukes in my belly\e[0m\n" +
106
+ "\033[1A \e[32mGiven \e[0m\e[32mI have \e[0m\e[32;1m999\e[0m\e[32m cukes in my belly\e[0m\n"
107
+ )
102
108
  else
103
- assert_io(" #{magenta('Given ')}#{magenta('I have ')}#{magenta(bold('999'))}#{magenta(' cukes in my belly')}\n")
109
+ assert_io(
110
+ " #{magenta('Given ')}#{magenta('I have ')}#{magenta(bold('999'))}#{magenta(' cukes in my belly')}\n" +
111
+ "\033[1A #{green('Given ')}#{green('I have ')}#{green(bold('999'))}#{green(' cukes in my belly')}\n"
112
+ )
104
113
  end
105
114
  end
106
115
 
@@ -7,14 +7,14 @@ require 'stringio'
7
7
  module Gherkin
8
8
  module Formatter
9
9
  class ParenthesisFormat
10
- def write_text(io, text)
11
- io.write("(#{text})")
10
+ def text(text)
11
+ "(#{text})"
12
12
  end
13
13
  end
14
14
 
15
15
  class BracketFormat
16
- def write_text(io, text)
17
- io.write("[#{text}]")
16
+ def text(text)
17
+ "[#{text}]"
18
18
  end
19
19
  end
20
20
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 3
8
- - 0
9
- version: 2.3.0
8
+ - 1
9
+ version: 2.3.1
10
10
  platform: java
11
11
  authors:
12
12
  - Mike Sassak
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-12 00:00:00 +00:00
19
+ date: 2010-11-13 00:00:00 +00:00
20
20
  default_executable: gherkin
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -104,9 +104,9 @@ dependencies:
104
104
  - !ruby/object:Gem::Version
105
105
  segments:
106
106
  - 0
107
- - 9
108
- - 4
109
- version: 0.9.4
107
+ - 10
108
+ - 0
109
+ version: 0.10.0
110
110
  type: :development
111
111
  version_requirements: *id006
112
112
  description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
@@ -278,7 +278,7 @@ rubyforge_project:
278
278
  rubygems_version: 1.3.7
279
279
  signing_key:
280
280
  specification_version: 3
281
- summary: gherkin-2.3.0
281
+ summary: gherkin-2.3.1
282
282
  test_files:
283
283
  - features/escaped_pipes.feature
284
284
  - features/feature_parser.feature