gherkin 2.2.9-universal-dotnet → 2.3.0-universal-dotnet

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
  gemspec
3
3
 
4
- @dependencies.reject!{|dep| dep.name == 'cucumber'}
5
- gem 'cucumber', :path => '../cucumber'
4
+ unless ENV['TM_RUBY']
5
+ @dependencies.reject!{|dep| dep.name == 'cucumber'}
6
+ gem 'cucumber', :path => '../cucumber'
7
+ end
@@ -1,3 +1,12 @@
1
+ == 2.3.0 (2010-11-12)
2
+
3
+ === New Features
4
+ * New aliases for Scenario Outline in Swedish, Norwegian and English. (Peter Krantz, Aslak Hellesøy)
5
+ * Improved build documentation for people who want to contribute. (Aslak Hellesøy)
6
+ * Results can now be outputted/parsed in JSON. (Aslak Hellesøy)
7
+ * JSON output now contains optional "match", "result" and "embeddings" elements underneath each step. (Aslak Hellesøy)
8
+ * Added support for Base64 encoded embeddings in JSON representation. Useful for screenshots etc. (Aslak Hellesøy)
9
+
1
10
  == 2.2.9 (2010-10-15)
2
11
 
3
12
  === New Features
@@ -5,26 +5,115 @@ Fast Gherkin lexer and parser based on Ragel. Gherkin is two things:
5
5
  * The language that has evolved out of the Cucumber project.
6
6
  * This library
7
7
 
8
- == Generating and building the code
8
+ Supported platforms:
9
9
 
10
- You'll need MRI (any version) if you want to build for MRI. To build the Java implementation you'll need JRuby.
11
- You'll also need Ragel installed and on your PATH.
10
+ * Ruby 1.8.6-1.9.2 (MRI, JRuby, REE, Rubinius)
11
+ * Pure Java
12
+ * .NET
13
+ * IronRuby (experimental)
14
+ * Javascript (coming soon)
12
15
 
13
- === MRI
16
+ == Installing the toolchain
14
17
 
15
- rake clean compile
18
+ Due to the cross-platform nature of this library, you have to install a lot of tools to build gherkin yourself.
19
+ In order to make it easier for occasional contributors to get the development environment up and running, you don't
20
+ have to install everything up front. The build scripts should tell you if you are missing something. For example,
21
+ you shouldn't have to install MinGW to build windows binaries if you are a Linux user and just want to fix a bug in
22
+ the C code.
16
23
 
17
- === Java
24
+ === Common dependencies
18
25
 
19
- rake clean jar
26
+ These are the minimal tools you need to install, even if you are building non-Ruby packages.
27
+
28
+ * Ragel (brew install ragel or apt-get install ragel)
29
+ * Ruby (any version should do).
30
+ * A clone of the cucumber git repo to a "cucumber" sibling folder of your gherkin folder. (Only needed to run cucumber tests)
31
+ * RVM (you may not need this if you are only building for a single platform)
32
+
33
+ With this minimal toolchain installed, install Ruby gems needed by the build:
34
+
35
+ gem install bundler
36
+ bundle install
20
37
 
21
- == Running RSpec and Cucumber tests
38
+ Running RSpec and Cucumber tests
22
39
 
23
- rake clean spec cucumber
40
+ rake clean spec cucumber
24
41
 
25
42
  If the RL_LANG environment variable is set, only the parsers for the languages specified there will be built.
26
43
  E.g. in Bash, export RL_LANG="en,fr,no". This can be quite helpful when modifying the Ragel grammar.
27
44
 
45
+ See subsections for building for a specific platform.
46
+
47
+ === MRI, REE or Rubinius
48
+
49
+ You'll need GCC installed.
50
+
51
+ Build the gem with:
52
+
53
+ rake build
54
+
55
+ === Pure Java and JRuby
56
+
57
+ You must install JRuby to build the pure Java jar or the JRuby gem:
58
+
59
+ rvm install jruby
60
+ rvm use jruby
61
+ rvm gemset create cucumber
62
+ rvm use @cucumber
63
+ gem install bundler
64
+ bundle install
65
+
66
+ Now you can build the jar with:
67
+
68
+ rake clean jar
69
+
70
+ === .NET and IronRuby
71
+
72
+ You must install Mono and IKVM to build the pure .NET dll and the IronRuby gem:
73
+
74
+ * Install Mono from http://www.mono-project.com/ and make sure it's on your $PATH
75
+ * Download IKVM from http://www.ikvm.net/ and extract it to /usr/local/ikvm so that you have a /usr/local/ikvm/bin/ikvmc.exe
76
+
77
+ Now you can build the .NET dll with:
78
+
79
+ rake ikvm
80
+
81
+ === MinGW Rubies (for Windows gems)
82
+
83
+ You must install MinGW rubies to build gems fow Windows.
84
+ First you need to download and install MinGW:
85
+
86
+ OS X users can get it from http://crossgcc.rts-software.org/doku.php
87
+ Once you have installed it, add this to your .bashrc:
88
+
89
+ export PATH=$PATH:/usr/local/i386-mingw32-4.3.0/bin
90
+
91
+ Now, let's install some rubies.
92
+ Make sure you have openssl installed first.
93
+
94
+ brew install openssl
95
+
96
+ # 1.8.6
97
+ # Don't worry about inconsistent patchlevels here. It works.
98
+ rvm install 1.8.6-p399
99
+ rvm use 1.8.6-p399
100
+ rvm gemset create cucumber
101
+ rvm use @cucumber
102
+ gem install bundler
103
+ bundle install
104
+ rake-compiler cross-ruby VERSION=1.8.6-p287
105
+
106
+ # 1.9.1
107
+ # Later 1.9.1 patch levels or 1.9.2 don't compile on mingw.
108
+ # The compiled binaries should still work on 1.9.2
109
+ rvm install 1.9.1-p243
110
+ rvm use 1.9.1-p243
111
+ rvm gemset create cucumber
112
+ rvm use @cucumber
113
+ gem install bundler
114
+ bundle install
115
+ rake-compiler cross-ruby VERSION=1.9.1-p243
116
+
28
117
  == Release process
29
118
 
30
119
  * Bump version in the VERSION file and:
data/Rakefile CHANGED
@@ -3,6 +3,7 @@ require 'rubygems'
3
3
  require 'bundler'
4
4
  Bundler.setup
5
5
  Bundler::GemHelper.install_tasks
6
+ ENV['RUBYOPT'] = nil # Necessary to prevent Bundler from *&^%$#ing up rake-compiler.
6
7
 
7
8
  require 'rake/clean'
8
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.9
1
+ 2.3.0
@@ -10,7 +10,6 @@ require 'gherkin'
10
10
  require 'gherkin/sexp_recorder'
11
11
  require 'gherkin/output_stream_string_io'
12
12
  require 'gherkin/java_libs'
13
- require 'gherkin/json'
14
13
 
15
14
  module TransformHelpers
16
15
  def tr_line_number(step_arg)
@@ -53,6 +53,6 @@ Gem::Specification.new do |s|
53
53
 
54
54
  s.add_development_dependency('rake', '~> 0.8.7')
55
55
  s.add_development_dependency('awesome_print', '~> 0.2.1')
56
- s.add_development_dependency('rspec', '~> 2.0.0.beta.22')
57
- s.add_development_dependency('cucumber', '~> 0.9.1')
56
+ s.add_development_dependency('rspec', '~> 2.0.1')
57
+ s.add_development_dependency('cucumber', '~> 0.9.4')
58
58
  end
@@ -1,8 +1,9 @@
1
1
  require 'gherkin/native'
2
+ require 'gherkin/formatter/hashable'
2
3
 
3
4
  module Gherkin
4
5
  module Formatter
5
- class Argument
6
+ class Argument < Hashable
6
7
  native_impl('gherkin')
7
8
  attr_reader :offset, :val
8
9
 
@@ -10,19 +10,21 @@ 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>failed</tt> - defaults to <tt>red</tt>
17
- # * <tt>failed_param</tt> - defaults to <tt>red,bold</tt>
18
- # * <tt>passed</tt> - defaults to <tt>green</tt>
19
- # * <tt>passed_param</tt> - defaults to <tt>green,bold</tt>
20
- # * <tt>outline</tt> - defaults to <tt>cyan</tt>
21
- # * <tt>outline_param</tt> - defaults to <tt>cyan,bold</tt>
22
- # * <tt>skipped</tt> - defaults to <tt>cyan</tt>
23
- # * <tt>skipped_param</tt> - defaults to <tt>cyan,bold</tt>
24
- # * <tt>comment</tt> - defaults to <tt>grey</tt>
25
- # * <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_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>
26
28
  #
27
29
  # For instance, if your shell has a black background and a green font (like the
28
30
  # "Homebrew" settings for OS X' Terminal.app), you may want to override passed
@@ -47,6 +49,7 @@ module Gherkin
47
49
  end.merge({
48
50
  'undefined' => 'yellow',
49
51
  'pending' => 'yellow',
52
+ 'executing' => 'magenta',
50
53
  'failed' => 'red',
51
54
  'passed' => 'green',
52
55
  'outline' => 'cyan',
@@ -0,0 +1,19 @@
1
+ module Gherkin
2
+ module Formatter
3
+ class Hashable
4
+ def to_hash
5
+ instance_variables.inject({}) do |hash, ivar|
6
+ value = instance_variable_get(ivar)
7
+ value = value.to_hash if value.respond_to?(:to_hash)
8
+ if Array === value
9
+ value = value.map do |e|
10
+ e.respond_to?(:to_hash) ? e.to_hash : e
11
+ end
12
+ end
13
+ hash[ivar[1..-1]] = value unless [[], nil].index(value)
14
+ hash
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,12 +1,14 @@
1
1
  require 'json'
2
2
  require 'gherkin/formatter/model'
3
3
  require 'gherkin/native'
4
+ require 'base64'
4
5
 
5
6
  module Gherkin
6
7
  module Formatter
7
8
  class JSONFormatter
8
9
  native_impl('gherkin')
9
10
 
11
+ include Base64
10
12
  attr_reader :gherkin_object
11
13
 
12
14
  # Creates a new instance that writes the resulting JSON to +io+.
@@ -45,6 +47,18 @@ module Gherkin
45
47
  steps << step.to_hash
46
48
  end
47
49
 
50
+ def match(match)
51
+ last_step['match'] = match.to_hash
52
+ end
53
+
54
+ def result(result)
55
+ last_step['result'] = result.to_hash
56
+ end
57
+
58
+ def embedding(mime_type, data)
59
+ embeddings << {'mime_type' => mime_type, 'data' => encode64s(data)}
60
+ end
61
+
48
62
  def eof
49
63
  @io.write(@gherkin_object.to_json) if @io
50
64
  end
@@ -66,6 +80,19 @@ module Gherkin
66
80
  def steps
67
81
  feature_element['steps'] ||= []
68
82
  end
83
+
84
+ def last_step
85
+ steps[-1]
86
+ end
87
+
88
+ def embeddings
89
+ last_step['embeddings'] ||= []
90
+ end
91
+
92
+ def encode64s(data)
93
+ # Strip newlines
94
+ encode64(data).gsub(/\n/, '')
95
+ end
69
96
  end
70
97
  end
71
98
  end
@@ -1,24 +1,9 @@
1
1
  require 'gherkin/native'
2
+ require 'gherkin/formatter/hashable'
2
3
 
3
4
  module Gherkin
4
5
  module Formatter
5
6
  module Model
6
- class Hashable
7
- def to_hash
8
- instance_variables.inject({}) do |hash, ivar|
9
- value = instance_variable_get(ivar)
10
- value = value.to_hash if value.respond_to?(:to_hash)
11
- if Array === value
12
- value = value.map do |e|
13
- e.respond_to?(:to_hash) ? e.to_hash : e
14
- end
15
- end
16
- hash[ivar[1..-1]] = value unless [[], nil].index(value)
17
- hash
18
- end
19
- end
20
- end
21
-
22
7
  class BasicStatement < Hashable
23
8
  attr_reader :comments, :keyword, :name, :line
24
9
 
@@ -127,13 +112,7 @@ module Gherkin
127
112
  class Step < BasicStatement
128
113
  native_impl('gherkin')
129
114
 
130
- attr_accessor :multiline_arg, :result
131
-
132
- def initialize(comments, keyword, name, line, multiline_arg=nil, result=nil)
133
- super(comments, keyword, name, line)
134
- @multiline_arg = multiline_arg
135
- @result = result
136
- end
115
+ attr_accessor :multiline_arg
137
116
 
138
117
  def line_range
139
118
  range = super
@@ -225,13 +204,31 @@ module Gherkin
225
204
  end
226
205
  end
227
206
 
228
- class Result
207
+ class Match < Hashable
229
208
  native_impl('gherkin')
230
209
 
231
- attr_reader :status, :error_message, :arguments, :stepdef_location
210
+ attr_reader :arguments, :location
232
211
 
233
- def initialize(status, error_message, arguments, stepdef_location)
234
- @status, @error_message, @arguments, @stepdef_location = status, error_message, arguments, stepdef_location
212
+ def initialize(arguments, location)
213
+ @arguments, @location = arguments, location
214
+ end
215
+
216
+ def replay(formatter)
217
+ formatter.match(self)
218
+ end
219
+ end
220
+
221
+ class Result < Hashable
222
+ native_impl('gherkin')
223
+
224
+ attr_reader :status, :error_message
225
+
226
+ def initialize(status, error_message)
227
+ @status, @error_message = status, error_message
228
+ end
229
+
230
+ def replay(formatter)
231
+ formatter.result(self)
235
232
  end
236
233
  end
237
234
  end
@@ -60,23 +60,32 @@ module Gherkin
60
60
  end
61
61
 
62
62
  def step(step)
63
- print_step(step)
64
- case step.multiline_arg
65
- when Model::PyString
66
- py_string(step.multiline_arg)
67
- when Array
68
- table(step.multiline_arg)
69
- end
63
+ @step = step
64
+ match(Model::Match.new([], nil)) if @monochrome
70
65
  end
71
66
 
72
- def print_step(step)
73
- print_comments(step.comments, ' ')
74
- @io.write(' ')
75
- text_format(step).write_text(@io, step.keyword)
76
- @step_printer.write_step(@io, text_format(step), arg_format(step), step.name, step.arguments)
77
- print_indented_stepdef_location!(step.result.stepdef_location) if step.result
67
+ def match(match)
68
+ print_step(format('executing'), format('executing_param'), match.arguments, match.location)
69
+ end
70
+
71
+ def result(result)
78
72
  # TODO: Print error message
73
+ end
74
+
75
+ def print_step(text_format, arg_format, arguments, location)
76
+ print_comments(@step.comments, ' ')
77
+ @io.write(' ')
78
+ text_format.write_text(@io, @step.keyword)
79
+ @step_printer.write_step(@io, text_format, arg_format, @step.name, arguments)
80
+ print_indented_stepdef_location!(location) if location
81
+
79
82
  @io.puts
83
+ case @step.multiline_arg
84
+ when Model::PyString
85
+ py_string(@step.multiline_arg)
86
+ when Array
87
+ table(@step.multiline_arg)
88
+ end
80
89
  end
81
90
 
82
91
  class MonochromeFormat
@@ -17,7 +17,7 @@
17
17
  feature: Feature
18
18
  background: Background
19
19
  scenario: Scenario
20
- scenario_outline: Scenario Outline
20
+ scenario_outline: Scenario Outline|Scenario Template
21
21
  examples: Examples|Scenarios
22
22
  given: "*|Given"
23
23
  when: "*|When"
@@ -397,7 +397,7 @@
397
397
  feature: Egenskap
398
398
  background: Bakgrunn
399
399
  scenario: Scenario
400
- scenario_outline: Abstrakt Scenario
400
+ scenario_outline: Scenariomal|Abstrakt Scenario
401
401
  examples: Eksempler
402
402
  given: "*|Gitt"
403
403
  when: "*|Når"
@@ -475,7 +475,7 @@
475
475
  feature: Egenskap
476
476
  background: Bakgrund
477
477
  scenario: Scenario
478
- scenario_outline: Abstrakt Scenario
478
+ scenario_outline: Abstrakt Scenario|Scenariomall
479
479
  examples: Exempel
480
480
  given: "*|Givet"
481
481
  when: "*|När"
@@ -1,11 +1,15 @@
1
1
  require 'json'
2
2
  require 'gherkin/formatter/model'
3
+ require 'gherkin/formatter/argument'
3
4
  require 'gherkin/native'
5
+ require 'base64'
4
6
 
5
7
  module Gherkin
6
8
  class JSONParser
7
9
  native_impl('gherkin')
8
10
 
11
+ include Base64
12
+
9
13
  def initialize(formatter)
10
14
  @formatter = formatter
11
15
  end
@@ -21,6 +25,9 @@ module Gherkin
21
25
  feature_element(feature_element).replay(@formatter)
22
26
  (feature_element["steps"] || []).each do |step|
23
27
  step(step).replay(@formatter)
28
+ match(step)
29
+ result(step)
30
+ embeddings(step)
24
31
  end
25
32
  (feature_element["examples"] || []).each do |eo|
26
33
  Formatter::Model::Examples.new(comments(eo), tags(eo), keyword(eo), name(eo), description(eo), line(eo), rows(eo['rows'])).replay(@formatter)
@@ -30,6 +37,8 @@ module Gherkin
30
37
  @formatter.eof
31
38
  end
32
39
 
40
+ private
41
+
33
42
  def feature_element(o)
34
43
  case o['type']
35
44
  when 'background'
@@ -42,15 +51,35 @@ module Gherkin
42
51
  end
43
52
 
44
53
  def step(o)
45
- multiline_arg = nil
54
+ step = Formatter::Model::Step.new(comments(o), keyword(o), name(o), line(o))
55
+
46
56
  if(ma = o['multiline_arg'])
47
57
  if(ma['type'] == 'table')
48
- multiline_arg = rows(ma['value'])
58
+ step.multiline_arg = rows(ma['value'])
49
59
  else
50
- multiline_arg = Formatter::Model::PyString.new(ma['value'], ma['line'])
60
+ step.multiline_arg = Formatter::Model::PyString.new(ma['value'], ma['line'])
51
61
  end
52
62
  end
53
- Formatter::Model::Step.new(comments(o), keyword(o), name(o), line(o), multiline_arg)
63
+
64
+ step
65
+ end
66
+
67
+ def match(o)
68
+ if(m = o['match'])
69
+ Formatter::Model::Match.new(arguments(m), location(m)).replay(@formatter)
70
+ end
71
+ end
72
+
73
+ def result(o)
74
+ if(r = o['result'])
75
+ Formatter::Model::Result.new(status(r), error_message(r)).replay(@formatter)
76
+ end
77
+ end
78
+
79
+ def embeddings(o)
80
+ (o['embeddings'] || []).each do |embedding|
81
+ @formatter.embedding(embedding['mime_type'], decode64(embedding['data']))
82
+ end
54
83
  end
55
84
 
56
85
  def rows(o)
@@ -84,5 +113,21 @@ module Gherkin
84
113
  def line(o)
85
114
  o['line']
86
115
  end
116
+
117
+ def arguments(m)
118
+ m['arguments'].map{|a| Formatter::Argument.new(a['offset'], a['val'])}
119
+ end
120
+
121
+ def location(m)
122
+ m['location']
123
+ end
124
+
125
+ def status(r)
126
+ r['status']
127
+ end
128
+
129
+ def error_message(r)
130
+ r['error_message']
131
+ end
87
132
  end
88
133
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
- require 'spec_helper'
3
2
  require 'gherkin/formatter/pretty_formatter'
4
3
  require 'gherkin/formatter/argument'
5
4
  require 'gherkin/formatter/model'
6
5
  require 'gherkin/listener/formatter_listener'
6
+ require 'gherkin/parser/parser'
7
7
  require 'stringio'
8
8
 
9
9
  module Gherkin
@@ -28,10 +28,6 @@ module Gherkin
28
28
  end
29
29
  end
30
30
 
31
- def result(status, error_message, arguments, stepdef_location)
32
- Model::Result.new(status, error_message, arguments, stepdef_location)
33
- end
34
-
35
31
  before do
36
32
  @io = StringIO.new
37
33
  @colf = Gherkin::Formatter::PrettyFormatter.new(@io, false)
@@ -40,47 +36,71 @@ module Gherkin
40
36
  it "should print comments when scenario is longer" do
41
37
  @colf.uri("features/foo.feature")
42
38
  @colf.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
43
- step1 = Model::Step.new([], "Given ", "some stuff", 5, nil, result('passed', nil, [], "features/step_definitions/bar.rb:56"))
44
- step2 = Model::Step.new([], "When ", "foo", 6, nil, result('passed', nil, [], "features/step_definitions/bar.rb:96"))
39
+
40
+ step1 = Model::Step.new([], "Given ", "some stuff", 5)
41
+ match1 = Model::Match.new([], "features/step_definitions/bar.rb:56")
42
+ result1 = Model::Result.new('passed', nil)
43
+
44
+ step2 = Model::Step.new([], "When ", "foo", 6)
45
+ match2 = Model::Match.new([], "features/step_definitions/bar.rb:96")
46
+ result2 = Model::Result.new('passed', nil)
47
+
45
48
  @colf.steps([step1, step2])
46
49
  @colf.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
50
+
47
51
  @colf.step(step1)
52
+ @colf.match(match1)
53
+ @colf.result(result1)
54
+
48
55
  @colf.step(step2)
56
+ @colf.match(match2)
57
+ @colf.result(result2)
49
58
 
50
59
  assert_io(%{Feature: Hello
51
60
  World
52
61
 
53
62
  Scenario: The scenario #{grey('# features/foo.feature:4')}
54
- #{green('Given ')}#{green('some stuff')} #{grey('# features/step_definitions/bar.rb:56')}
55
- #{green('When ')}#{green('foo')} #{grey('# features/step_definitions/bar.rb:96')}
63
+ #{magenta('Given ')}#{magenta('some stuff')} #{grey('# features/step_definitions/bar.rb:56')}
64
+ #{magenta('When ')}#{magenta('foo')} #{grey('# features/step_definitions/bar.rb:96')}
56
65
  })
57
66
  end
58
67
 
59
68
  it "should print comments when step is longer" do
60
69
  @colf.uri("features/foo.feature")
61
70
  @colf.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
62
- step = Model::Step.new([], "Given ", "some stuff that is longer", 5, nil, result('passed', nil, [], "features/step_definitions/bar.rb:56"))
71
+ step = Model::Step.new([], "Given ", "some stuff that is longer", 5)
72
+ match = Model::Match.new([], "features/step_definitions/bar.rb:56")
73
+ result = Model::Result.new('passed', nil)
74
+
63
75
  @colf.steps([step])
64
76
  @colf.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
65
77
  @colf.step(step)
78
+ @colf.match(match)
79
+ @colf.result(result)
66
80
 
67
81
  assert_io(%{Feature: Hello
68
82
  World
69
83
 
70
84
  Scenario: The scenario #{grey('# features/foo.feature:4')}
71
- #{green('Given ')}#{green('some stuff that is longer')} #{grey('# features/step_definitions/bar.rb:56')}
85
+ #{magenta('Given ')}#{magenta('some stuff that is longer')} #{grey('# features/step_definitions/bar.rb:56')}
72
86
  })
73
87
  end
74
88
 
75
89
  it "should highlight arguments for regular steps" do
76
- step = Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3, nil, result('passed', nil, [Gherkin::Formatter::Argument.new(7, '999')], nil))
90
+ step = Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3)
91
+ match = Model::Match.new([Gherkin::Formatter::Argument.new(7, '999')], nil)
92
+ result = Model::Result.new('passed', nil)
93
+
77
94
  @colf.steps([step])
78
95
  @colf.step(step)
96
+ @colf.match(match)
97
+ @colf.result(result)
98
+
79
99
  if defined?(JRUBY_VERSION)
80
100
  # Not terribly readable. The result on Java is different because JANSI uses semicolons when there are several codes.
81
- assert_io(" \e[32mGiven \e[0m\e[32mI have \e[0m\e[32;1m999\e[0m\e[32m cukes in my belly\e[0m\n")
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")
82
102
  else
83
- assert_io(" #{green('Given ')}#{green('I have ')}#{green(bold('999'))}#{green(' cukes in my belly')}\n")
103
+ assert_io(" #{magenta('Given ')}#{magenta('I have ')}#{magenta(bold('999'))}#{magenta(' cukes in my belly')}\n")
84
104
  end
85
105
  end
86
106
 
@@ -1,4 +1,9 @@
1
- if defined?(JRUBY_VERSION)
1
+ JAVA_LIBS = {}
2
+
3
+ unless RUBY_VERSION == '1.8.6'
4
+ # When we're building native windows gems with 1.8.6 this block of code fails.
5
+ # We'll just disable running it - it's not needed at that stage of the build.
6
+
2
7
  require 'rexml/document'
3
8
  pom = REXML::Document.new(IO.read(File.dirname(__FILE__) + '/../../java/pom.xml'))
4
9
  pom_version = REXML::XPath.first(pom, '//xmlns:project/xmlns:version/text()').to_s
@@ -6,8 +11,10 @@ if defined?(JRUBY_VERSION)
6
11
  groupId = dep.get_elements('groupId')[0].text()
7
12
  artifactId = dep.get_elements('artifactId')[0].text()
8
13
  version = dep.get_elements('version')[0].text()
14
+ scope = dep.get_elements('scope')[0].text() rescue nil
9
15
 
10
16
  jar = "~/.m2/repository/#{groupId.gsub(/\./, '/')}/#{artifactId}/#{version}/#{artifactId}-#{version}.jar"
11
- require jar
17
+ JAVA_LIBS["#{groupId}-#{artifactId}"] = jar if scope != 'test'
18
+ require jar if defined?(JRUBY_VERSION)
12
19
  end
13
20
  end
@@ -14,7 +14,6 @@ module Gherkin
14
14
  p.parse(json, 'unknown.json', 0)
15
15
  expected = JSON.parse(json)
16
16
  actual = JSON.parse(io.string)
17
-
18
17
  actual.should == expected
19
18
  end
20
19
 
@@ -60,6 +59,52 @@ module Gherkin
60
59
  }})
61
60
  end
62
61
 
62
+ it "should parse feature with match, result and embedding" do
63
+ check_json(%{{
64
+ "tags": [
65
+ {
66
+ "name": "@foo",
67
+ "line": 22
68
+ }
69
+ ],
70
+ "keyword": "Feature",
71
+ "name": "One",
72
+ "description": "",
73
+ "line": 3,
74
+ "elements": [
75
+ {
76
+ "type": "scenario",
77
+ "steps": [
78
+ {
79
+ "keyword": "Given ",
80
+ "name": "a passing step",
81
+ "line": 6,
82
+ "match": {
83
+ "arguments": [
84
+ {
85
+ "offset": 22,
86
+ "val": "cukes"
87
+ }
88
+ ],
89
+ "location": "features/step_definitions/steps.rb:1"
90
+ },
91
+ "result": {
92
+ "status": "failed",
93
+ "error_message": "You suck"
94
+ },
95
+ "embeddings": [
96
+ {
97
+ "mime_type": "text/plain",
98
+ "data": "Tm8sIEknbSBub3QgaW50ZXJlc3RlZCBpbiBkZXZlbG9waW5nIGEgcG93ZXJmdWwgYnJhaW4uIEFsbCBJJ20gYWZ0ZXIgaXMganVzdCBhIG1lZGlvY3JlIGJyYWluLCBzb21ldGhpbmcgbGlrZSB0aGUgUHJlc2lkZW50IG9mIHRoZSBBbWVyaWNhbiBUZWxlcGhvbmUgYW5kIFRlbGVncmFwaCBDb21wYW55Lg=="
99
+ }
100
+ ]
101
+ }
102
+ ]
103
+ }
104
+ ]
105
+ }})
106
+ end
107
+
63
108
  it "shoud parse a complex feature" do
64
109
  check_json(fixture("complex.json"))
65
110
  end
@@ -2,12 +2,12 @@ require 'rubygems'
2
2
  require 'bundler'
3
3
  Bundler.setup
4
4
 
5
+ require 'rspec'
5
6
  require 'gherkin'
6
7
  require 'stringio'
7
8
  require 'gherkin/sexp_recorder'
8
9
  require 'gherkin/output_stream_string_io'
9
10
  require 'gherkin/java_libs'
10
- require 'gherkin/json'
11
11
  require 'gherkin/shared/lexer_group'
12
12
  require 'gherkin/shared/tags_group'
13
13
  require 'gherkin/shared/py_string_group'
@@ -1,19 +1,12 @@
1
1
  namespace :gems do
2
2
  task :win do
3
3
  unless File.directory?(File.expand_path('~/.rake-compiler'))
4
- STDERR.puts <<-EOM
5
-
6
- You must install Windows rubies to ~/.rake-compiler with:
7
-
8
- rake-compiler cross-ruby VERSION=1.8.6-p287
9
- # (Later 1.9.1 patch levels don't compile on mingw)
10
- rake-compiler cross-ruby VERSION=1.9.1-p243
11
- EOM
4
+ STDERR.puts "[ERROR] You must install MinGW rubies to build gherkin gems for Windows. See README.rdoc"
12
5
  exit(1)
13
6
  end
14
7
  # rvm and mingw ruby versions have to match to avoid errors
15
- sh "rvm 1.8.6@cucumber rake cross compile RUBY_CC_VERSION=1.8.6"
16
- sh "rvm 1.9.1@cucumber rake cross compile RUBY_CC_VERSION=1.9.1"
8
+ sh "rvm 1.8.6-p399@cucumber rake cross compile RUBY_CC_VERSION=1.8.6"
9
+ sh "rvm 1.9.1-p243@cucumber rake cross compile RUBY_CC_VERSION=1.9.1"
17
10
  # This will copy the .so files to the proper place
18
11
  sh "rake cross compile RUBY_CC_VERSION=1.8.6:1.9.1"
19
12
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec/gherkin/json'
1
+ require File.dirname(__FILE__) + '/../spec/gherkin/java_libs'
2
2
  # To test out the pure Java main program on .NET, execute:
3
3
  #
4
4
  # rake ikvm
@@ -20,20 +20,45 @@ require File.dirname(__FILE__) + '/../spec/gherkin/json'
20
20
  # [mono] mono ikvm/Gherkin/bin/Debug/Gherkin.exe features/steps_parser.feature
21
21
  #
22
22
  namespace :ikvm do
23
+ def mono(args)
24
+ if(`which mono`.strip =~ /mono/)
25
+ sh("mono #{args}")
26
+ else
27
+ raise "[ERROR] You must install Mono and IKVM build gherkin for .NET. See README.rdoc"
28
+ end
29
+ end
30
+
31
+ def ikvmc(args)
32
+ begin
33
+ mono("/usr/local/ikvm/bin/ikvmc.exe #{args}")
34
+ rescue => e
35
+ if e.message =~ /Cannot open assembly/
36
+ e.message << "\n\n[ERROR] You must install Mono and IKVM build gherkin for .NET. See README.rdoc"
37
+ end
38
+ raise e
39
+ end
40
+ end
41
+
42
+ def references
43
+ JAVA_LIBS.keys.map{|name| "-reference:release/#{name}.dll"}.join(' ')
44
+ end
45
+
23
46
  task :dependent_dlls do
24
47
  mkdir_p 'release' unless File.directory?('release')
25
- sh("mono /usr/local/ikvm/bin/ikvmc.exe -target:library #{JSON_SIMPLE_JAR} -out:release/json-simple.dll")
48
+ JAVA_LIBS.each do |name, jar|
49
+ ikvmc("-target:library #{jar} -out:release/#{name}.dll")
50
+ end
26
51
  end
27
52
 
28
53
  desc 'Make a .NET .exe'
29
54
  task :exe => ['lib/gherkin.jar', :dependent_dlls] do
30
- sh("mono /usr/local/ikvm/bin/ikvmc.exe -target:exe lib/gherkin.jar -out:release/gherkin-#{Gherkin::VERSION}.exe -reference:release/json-simple.dll")
55
+ ikvmc("-target:exe lib/gherkin.jar -out:release/gherkin-#{Gherkin::VERSION}.exe #{references}")
31
56
  end
32
57
 
33
58
  desc 'Make a .NET .dll'
34
59
  task :dll => ['lib/gherkin.jar', :dependent_dlls] do
35
60
  mkdir_p 'release' unless File.directory?('release')
36
- sh("mono /usr/local/ikvm/bin/ikvmc.exe -target:library lib/gherkin.jar -out:release/gherkin-#{Gherkin::VERSION}.dll -reference:release/json-simple.dll")
61
+ ikvmc("-target:library lib/gherkin.jar -out:release/gherkin-#{Gherkin::VERSION}.dll #{references}")
37
62
  cp "release/gherkin-#{Gherkin::VERSION}.dll", 'lib/gherkin.dll'
38
63
  end
39
64
 
@@ -48,7 +73,7 @@ end
48
73
 
49
74
  task :ikvm => ['ikvm:copy_ikvm_dlls', 'ikvm:exe', 'ikvm:dll'] do
50
75
  puts "************** Pretty printing some features with .NET. **************"
51
- sh "mono release/gherkin-#{Gherkin::VERSION}.exe features"
76
+ mono "release/gherkin-#{Gherkin::VERSION}.exe features"
52
77
  puts "************** DONE Pretty printing some features with .NET. All OK. **************"
53
78
  end
54
79
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 2
8
- - 9
9
- version: 2.2.9
7
+ - 3
8
+ - 0
9
+ version: 2.3.0
10
10
  platform: universal-dotnet
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-10-15 00:00:00 +02:00
19
+ date: 2010-11-12 00:00:00 +00:00
20
20
  default_executable: gherkin
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -90,10 +90,8 @@ dependencies:
90
90
  segments:
91
91
  - 2
92
92
  - 0
93
- - 0
94
- - beta
95
- - 22
96
- version: 2.0.0.beta.22
93
+ - 1
94
+ version: 2.0.1
97
95
  type: :development
98
96
  version_requirements: *id005
99
97
  - !ruby/object:Gem::Dependency
@@ -107,8 +105,8 @@ dependencies:
107
105
  segments:
108
106
  - 0
109
107
  - 9
110
- - 1
111
- version: 0.9.1
108
+ - 4
109
+ version: 0.9.4
112
110
  type: :development
113
111
  version_requirements: *id006
114
112
  description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
@@ -152,6 +150,7 @@ files:
152
150
  - gherkin.gemspec
153
151
  - ikvm/.gitignore
154
152
  - java/.gitignore
153
+ - java/Gherkin.iml
155
154
  - java/src/main/java/gherkin/lexer/i18n/.gitignore
156
155
  - java/src/main/resources/gherkin/.gitignore
157
156
  - lib/.gitignore
@@ -161,6 +160,7 @@ files:
161
160
  - lib/gherkin/formatter/colors.rb
162
161
  - lib/gherkin/formatter/escaping.rb
163
162
  - lib/gherkin/formatter/filter_formatter.rb
163
+ - lib/gherkin/formatter/hashable.rb
164
164
  - lib/gherkin/formatter/json_formatter.rb
165
165
  - lib/gherkin/formatter/line_filter.rb
166
166
  - lib/gherkin/formatter/model.rb
@@ -222,7 +222,6 @@ files:
222
222
  - spec/gherkin/i18n_spec.rb
223
223
  - spec/gherkin/java_lexer_spec.rb
224
224
  - spec/gherkin/java_libs.rb
225
- - spec/gherkin/json.rb
226
225
  - spec/gherkin/json_parser_spec.rb
227
226
  - spec/gherkin/lexer/i18n_lexer_spec.rb
228
227
  - spec/gherkin/output_stream_string_io.rb
@@ -283,7 +282,7 @@ rubyforge_project:
283
282
  rubygems_version: 1.3.7
284
283
  signing_key:
285
284
  specification_version: 3
286
- summary: gherkin-2.2.9
285
+ summary: gherkin-2.3.0
287
286
  test_files:
288
287
  - features/escaped_pipes.feature
289
288
  - features/feature_parser.feature
@@ -327,7 +326,6 @@ test_files:
327
326
  - spec/gherkin/i18n_spec.rb
328
327
  - spec/gherkin/java_lexer_spec.rb
329
328
  - spec/gherkin/java_libs.rb
330
- - spec/gherkin/json.rb
331
329
  - spec/gherkin/json_parser_spec.rb
332
330
  - spec/gherkin/lexer/i18n_lexer_spec.rb
333
331
  - spec/gherkin/output_stream_string_io.rb
@@ -1,5 +0,0 @@
1
- JSON_SIMPLE_JAR = ENV['HOME'] + '/.m2/repository/com/googlecode/json-simple/json-simple/1.1/json-simple-1.1.jar'
2
-
3
- if defined?(JRUBY_VERSION)
4
- require JSON_SIMPLE_JAR
5
- end