gherkin 1.0.30-i386-mswin32 → 2.0.0-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.rspec +1 -0
  2. data/History.txt +19 -0
  3. data/Rakefile +4 -4
  4. data/VERSION.yml +2 -2
  5. data/features/feature_parser.feature +11 -0
  6. data/features/json_formatter.feature +238 -0
  7. data/features/pretty_formatter.feature +9 -0
  8. data/features/step_definitions/gherkin_steps.rb +1 -1
  9. data/features/step_definitions/json_formatter_steps.rb +32 -0
  10. data/features/step_definitions/pretty_formatter_steps.rb +24 -23
  11. data/features/support/env.rb +3 -3
  12. data/lib/gherkin/formatter/json_formatter.rb +82 -0
  13. data/lib/gherkin/formatter/pretty_formatter.rb +73 -78
  14. data/lib/gherkin/i18n.rb +22 -18
  15. data/lib/gherkin/i18n.yml +9 -9
  16. data/lib/gherkin/i18n_lexer.rb +2 -2
  17. data/lib/gherkin/parser/event.rb +6 -6
  18. data/lib/gherkin/parser/filter_listener.rb +5 -1
  19. data/lib/gherkin/parser/formatter_listener.rb +113 -0
  20. data/lib/gherkin/parser/json_parser.rb +102 -0
  21. data/lib/gherkin/parser/parser.rb +10 -2
  22. data/lib/gherkin/parser/row.rb +15 -0
  23. data/lib/gherkin/rubify.rb +2 -0
  24. data/lib/gherkin/tools/files.rb +1 -1
  25. data/lib/gherkin/tools/reformat.rb +1 -2
  26. data/lib/gherkin/tools/stats.rb +1 -1
  27. data/lib/gherkin/tools/stats_listener.rb +5 -5
  28. data/ragel/lexer.c.rl.erb +41 -12
  29. data/ragel/lexer.java.rl.erb +26 -17
  30. data/ragel/lexer.rb.rl.erb +10 -5
  31. data/ragel/lexer_common.rl.erb +6 -6
  32. data/spec/gherkin/c_lexer_spec.rb +2 -2
  33. data/spec/gherkin/fixtures/complex.js +105 -0
  34. data/spec/gherkin/formatter/argument_spec.rb +3 -3
  35. data/spec/gherkin/formatter/colors_spec.rb +3 -4
  36. data/spec/gherkin/formatter/pretty_formatter_spec.rb +21 -50
  37. data/spec/gherkin/i18n_lexer_spec.rb +6 -6
  38. data/spec/gherkin/i18n_spec.rb +16 -9
  39. data/spec/gherkin/java_lexer_spec.rb +1 -2
  40. data/spec/gherkin/output_stream_string_io.rb +24 -0
  41. data/spec/gherkin/parser/filter_listener_spec.rb +16 -9
  42. data/spec/gherkin/parser/formatter_listener_spec.rb +134 -0
  43. data/spec/gherkin/parser/json_parser_spec.rb +129 -0
  44. data/spec/gherkin/parser/parser_spec.rb +9 -9
  45. data/spec/gherkin/parser/tag_expression_spec.rb +8 -8
  46. data/spec/gherkin/rb_lexer_spec.rb +1 -1
  47. data/spec/gherkin/sexp_recorder.rb +21 -1
  48. data/spec/gherkin/shared/{lexer_spec.rb → lexer_group.rb} +172 -102
  49. data/spec/gherkin/shared/{py_string_spec.rb → py_string_group.rb} +21 -17
  50. data/spec/gherkin/shared/{row_spec.rb → row_group.rb} +36 -19
  51. data/spec/gherkin/shared/{tags_spec.rb → tags_group.rb} +13 -9
  52. data/spec/spec_helper.rb +18 -38
  53. data/tasks/bench.rake +3 -3
  54. data/tasks/compile.rake +13 -14
  55. data/tasks/rspec.rake +6 -11
  56. metadata +42 -28
  57. data/features/pretty_printer.feature +0 -14
  58. data/spec/gherkin/csharp_lexer_spec.rb +0 -20
@@ -34,36 +34,36 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
34
34
  }
35
35
 
36
36
  action store_feature_content {
37
- String con = multilineStrip(keywordContent(data, p, eof, nextKeywordStart, contentStart).trim());
38
- listener.feature(keyword, con, currentLine);
37
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
38
+ listener.feature(keyword, nameDescription[0], nameDescription[1], currentLine);
39
39
  if(nextKeywordStart != -1) p = nextKeywordStart - 1;
40
40
  nextKeywordStart = -1;
41
41
  }
42
42
 
43
43
  action store_background_content {
44
- String con = multilineStrip(keywordContent(data, p, eof, nextKeywordStart, contentStart));
45
- listener.background(keyword, con, currentLine);
44
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
45
+ listener.background(keyword, nameDescription[0], nameDescription[1], currentLine);
46
46
  if(nextKeywordStart != -1) p = nextKeywordStart - 1;
47
47
  nextKeywordStart = -1;
48
48
  }
49
49
 
50
50
  action store_scenario_content {
51
- String con = multilineStrip(keywordContent(data, p, eof, nextKeywordStart, contentStart));
52
- listener.scenario(keyword, con, currentLine);
51
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
52
+ listener.scenario(keyword, nameDescription[0], nameDescription[1], currentLine);
53
53
  if(nextKeywordStart != -1) p = nextKeywordStart - 1;
54
54
  nextKeywordStart = -1;
55
55
  }
56
56
 
57
57
  action store_scenario_outline_content {
58
- String con = multilineStrip(keywordContent(data, p, eof, nextKeywordStart, contentStart));
59
- listener.scenarioOutline(keyword, con, currentLine);
58
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
59
+ listener.scenarioOutline(keyword, nameDescription[0], nameDescription[1], currentLine);
60
60
  if(nextKeywordStart != -1) p = nextKeywordStart - 1;
61
61
  nextKeywordStart = -1;
62
62
  }
63
63
 
64
64
  action store_examples_content {
65
- String con = multilineStrip(keywordContent(data, p, eof, nextKeywordStart, contentStart));
66
- listener.examples(keyword, con, currentLine);
65
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
66
+ listener.examples(keyword, nameDescription[0], nameDescription[1], currentLine);
67
67
  if(nextKeywordStart != -1) p = nextKeywordStart - 1;
68
68
  nextKeywordStart = -1;
69
69
  }
@@ -125,7 +125,7 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
125
125
  action end_feature {
126
126
  if(cs < lexer_first_final) {
127
127
  String content = currentLineContent(data, lastNewline);
128
- throw new LexingError("Lexing error on line " + lineNumber + ": '" + content + "'");
128
+ throw new LexingError("Lexing error on line " + lineNumber + ": '" + content + "'. See http://wiki.github.com/aslakhellesoy/gherkin/lexingerror for more information.");
129
129
  } else {
130
130
  listener.eof();
131
131
  }
@@ -142,8 +142,9 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
142
142
 
143
143
  %% write data noerror;
144
144
 
145
- public void scan(String inputSequence) {
146
- String input = inputSequence.toString() + "\n%_FEATURE_END_%";
145
+ public void scan(String inputSequence, String uri, int offset) {
146
+ listener.location(uri, offset);
147
+ String input = inputSequence + "\n%_FEATURE_END_%";
147
148
  byte[] data = null;
148
149
  try {
149
150
  data = input.getBytes("UTF-8");
@@ -178,16 +179,24 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
178
179
  private static final String CRLF = "\r\n";
179
180
  private static final String LF = "\n";
180
181
 
181
- private String multilineStrip(String text) {
182
+ private String[] nameAndDescriptionWithPlatformNewlinesIntact(String text) {
182
183
  int crlfCount = matchCount(CRLF_RE.matcher(text));
183
184
  int lfCount = matchCount(LF_RE.matcher(text));
184
185
  String eol = crlfCount > lfCount ? CRLF : LF;
185
186
 
186
- StringBuffer result = new StringBuffer();
187
+ String name = null;
188
+ StringBuffer description = new StringBuffer();
187
189
  for(String s : text.split("\r?\n")) {
188
- result.append(s.trim()).append(eol);
190
+ if(name == null) {
191
+ name = s.trim();
192
+ } else {
193
+ description.append(s.trim()).append(eol);
194
+ }
195
+ }
196
+ if(name == null) {
197
+ name = "";
189
198
  }
190
- return result.toString().trim();
199
+ return new String[]{name, description.toString().trim()};
191
200
  }
192
201
 
193
202
  private int matchCount(Matcher m) {
@@ -113,7 +113,7 @@ module Gherkin
113
113
  action end_feature {
114
114
  if cs < lexer_first_final
115
115
  content = current_line_content(data, p)
116
- raise LexingError.new("Lexing error on line %d: '%s'." % [@line_number, content])
116
+ raise LexingError.new("Lexing error on line %d: '%s'. See http://wiki.github.com/aslakhellesoy/gherkin/lexingerror for more information." % [@line_number, content])
117
117
  else
118
118
  @listener.eof
119
119
  end
@@ -127,7 +127,8 @@ module Gherkin
127
127
  %% write data;
128
128
  end
129
129
 
130
- def scan(data)
130
+ def scan(data, uri, offset)
131
+ @listener.location(uri, offset)
131
132
  data = (data + "\n%_FEATURE_END_%").unpack("c*") # Explicit EOF simplifies things considerably
132
133
  eof = pe = data.length
133
134
 
@@ -153,11 +154,15 @@ module Gherkin
153
154
  def unindent(startcol, text)
154
155
  text.gsub(/^[\t ]{0,#{startcol}}/, "")
155
156
  end
156
-
157
+
157
158
  def store_keyword_content(event, data, p, eof)
158
159
  end_point = (!@next_keyword_start or (p == eof)) ? p : @next_keyword_start
159
- con = yield utf8_pack(data[@content_start...end_point])
160
- @listener.send(event, @keyword, con, @current_line)
160
+ content = yield utf8_pack(data[@content_start...end_point])
161
+ content_lines = content.split("\n")
162
+ name = content_lines.shift || ""
163
+ name.strip!
164
+ description = content_lines.join("\n")
165
+ @listener.__send__(event, @keyword, name, description, @current_line)
161
166
  end
162
167
 
163
168
  def current_line_content(data, p)
@@ -16,11 +16,11 @@
16
16
  PIPE = '|';
17
17
  ESCAPED_PIPE = '\\|';
18
18
 
19
- FeatureHeadingEnd = EOL+ space* (I18N_Background | I18N_Scenario | I18N_ScenarioOutline | '@' | '#' | EOF) >next_keyword_start;
20
- ScenarioHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
21
- BackgroundHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#'| EOF ) >next_keyword_start;
22
- ScenarioOutlineHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
23
- ExamplesHeadingEnd = EOL+ space* '|' >next_keyword_start;
19
+ FeatureHeadingEnd = EOL+ space* (I18N_Feature | I18N_Background | I18N_Scenario | I18N_ScenarioOutline | I18N_Examples | '@' | '#' | EOF) >next_keyword_start;
20
+ ScenarioHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Background | I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
21
+ BackgroundHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#'| EOF ) >next_keyword_start;
22
+ ScenarioOutlineHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Scenario | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
23
+ ExamplesHeadingEnd = EOL+ space* ( I18N_Feature | '|' ) >next_keyword_start;
24
24
 
25
25
  FeatureHeading = space* I18N_Feature %begin_content ^FeatureHeadingEnd* :>> FeatureHeadingEnd @store_feature_content;
26
26
  BackgroundHeading = space* I18N_Background %begin_content ^BackgroundHeadingEnd* :>> BackgroundHeadingEnd @store_background_content;
@@ -36,7 +36,7 @@
36
36
 
37
37
  StartRow = space* PIPE >start_row;
38
38
  EndRow = EOL space* ^PIPE >next_keyword_start;
39
- Cell = PIPE (ESCAPED_PIPE | (any - PIPE)+ )* >begin_cell_content %store_cell_content;
39
+ Cell = PIPE (ESCAPED_PIPE | (any - (PIPE|EOL))+ )* >begin_cell_content %store_cell_content;
40
40
  RowBody = space* Cell** PIPE :>> (space* EOL+ space*) %store_row;
41
41
  Row = StartRow :>> RowBody <: EndRow?;
42
42
 
@@ -1,6 +1,6 @@
1
1
  #encoding: utf-8
2
- unless defined?(JRUBY_VERSION)
3
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ unless defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby")
3
+ require 'spec_helper'
4
4
  require 'gherkin_lexer_en'
5
5
 
6
6
  module Gherkin
@@ -0,0 +1,105 @@
1
+ { "name" : "Feature Text\nIn order to test multiline forms",
2
+ "tags" : [
3
+ "@tag1",
4
+ "@tag2"
5
+ ],
6
+ "background" : {
7
+ "name" : "",
8
+ "steps" : [
9
+ { "name" : "this is a background step" },
10
+ { "name" : "this is another one",
11
+ "keyword" : "When ",
12
+ "line" : 412 }
13
+ ]
14
+ },
15
+ "elements" : [
16
+ { "type" : "Scenario Outline",
17
+ "name" : "An Scenario Outline",
18
+ "tags" : [ "@foo" ],
19
+ "steps" : [
20
+ { "name" : "A step with a table",
21
+ "table" : [
22
+ {"cells":
23
+ [ { "text":"a" },
24
+ { "text":"row" },
25
+ { "text":"for" },
26
+ { "text":"a" },
27
+ { "text":"step"}
28
+ ]
29
+ }
30
+ ]
31
+ }
32
+ ],
33
+ "examples" : [
34
+ { "name" : "Sweet Example",
35
+ "table" : [
36
+ {"cells" :
37
+ [ { "text":"Fill" },
38
+ { "text":"In" }]},
39
+ {"cells" :
40
+ [ { "text":"The" },
41
+ { "text": "Blanks" }]}
42
+ ],
43
+ "tags" : [ "@exampletag" ]
44
+ }
45
+ ]
46
+ },
47
+ { "type" : "Scenario",
48
+ "name" : "Reading a Scenario",
49
+ "tags" : [
50
+ "@tag3",
51
+ "@tag4"
52
+ ],
53
+ "steps" : [
54
+ { "name" : "there is a step" },
55
+ { "name" : "not another step" }
56
+ ]
57
+ },
58
+ { "type" : "Scenario",
59
+ "name" : "Reading a second scenario\nWith two lines of text",
60
+ "tags" : [ "@tag3" ],
61
+ "steps" : [
62
+ { "name" : "a third step with a table",
63
+ "table" : [
64
+ { "cells" :
65
+ [ { "text":"a" },
66
+ { "text":"b" }]},
67
+ { "cells" :
68
+ [ { "text":"c" },
69
+ { "text":"d" }]},
70
+ { "cells" :
71
+ [ { "text":"e" },
72
+ { "text":"f" }]}
73
+ ]
74
+ },
75
+ { "name" : "I am still testing things",
76
+ "table" : [
77
+ { "cells" :
78
+ [ { "text":"g" },
79
+ { "text":"h" }]},
80
+ { "cells" :
81
+ [ { "text":"e" },
82
+ { "text":"r" }]},
83
+ { "cells" :
84
+ [ { "text":"k" },
85
+ { "text":"i" }]},
86
+ { "cells" :
87
+ [ { "text":"n" },
88
+ { "text":"" }]}
89
+ ]
90
+ },
91
+ { "name" : "I am done testing these tables" },
92
+ { "name" : "I am happy" }
93
+ ]
94
+ },
95
+ { "type" : "Scenario",
96
+ "name" : "Hammerzeit",
97
+ "steps" : [
98
+ { "name" : "All work and no play",
99
+ "py_string" : "Makes Homer something something\nAnd something else" },
100
+ { "name" : "crazy" }
101
+ ]
102
+ }
103
+ ]
104
+ }
105
+
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'spec_helper'
3
3
  require 'gherkin/formatter/argument'
4
4
 
5
5
  module Gherkin
@@ -18,8 +18,8 @@ module Gherkin
18
18
 
19
19
  describe Argument do
20
20
  it "should replace one arg" do
21
- argument_class = defined?(JRUBY_VERSION) ? ::Java::GherkinFormatter::Argument : Argument
22
- argument_class.format("I have 10 cukes", BracketFormat.new, [Argument.new(7, '10')]).should == "I have [10] cukes"
21
+ argument_class = defined?(JRUBY_VERSION) ? ::Java::GherkinFormatter::Argument : Gherkin::Formatter::Argument
22
+ argument_class.format("I have 10 cukes", Gherkin::Formatter::BracketFormat.new, [Gherkin::Formatter::Argument.new(7, '10')]).should == "I have [10] cukes"
23
23
  end
24
24
 
25
25
  # TODO: Add this spec: http://github.com/alg/cucumber/commit/33188e9db51f59ced74c4861524d7b2e69454630
@@ -1,11 +1,10 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
- require 'gherkin/formatter/pretty_formatter'
3
-
1
+ require 'spec_helper'
2
+ require 'gherkin/formatter/colors'
4
3
 
5
4
  module Gherkin
6
5
  module Formatter
7
6
  describe Colors do
8
- include Colors
7
+ include Gherkin::Formatter::Colors
9
8
 
10
9
  it "should colour stuff red" do
11
10
  failed("hello").should == "\e[31mhello\e[0m"
@@ -1,45 +1,46 @@
1
1
  # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'spec_helper'
3
3
  require 'gherkin/formatter/pretty_formatter'
4
4
  require 'gherkin/formatter/argument'
5
+ require 'gherkin/parser/formatter_listener'
6
+ require 'gherkin/parser/row'
5
7
  require 'stringio'
6
8
 
7
9
  module Gherkin
8
10
  module Formatter
9
11
  describe PrettyFormatter do
10
12
  def assert_io(s)
11
- @io.rewind
12
- actual = @io.read
13
+ actual = @io.string
13
14
  actual.should == s
14
15
  end
15
16
 
16
17
  def assert_pretty(input, output=input)
17
18
  [true, false].each do |force_ruby|
18
19
  io = StringIO.new
19
- l = PrettyFormatter.new(io, true)
20
+ pf = Gherkin::Formatter::PrettyFormatter.new(io, true)
21
+ l = Gherkin::Parser::FormatterListener.new(pf)
20
22
  parser = Gherkin::Parser::Parser.new(l, true, "root")
21
23
  lexer = Gherkin::I18nLexer.new(parser, force_ruby)
22
- lexer.scan(input)
23
- io.rewind
24
- actual = io.read
24
+ lexer.scan(input, "test.feature", 0)
25
+ actual = io.string
25
26
  actual.should == output
26
27
  end
27
28
  end
28
29
 
29
30
  before do
30
31
  @io = StringIO.new
31
- @l = PrettyFormatter.new(@io, true)
32
+ @l = Gherkin::Formatter::PrettyFormatter.new(@io, true)
32
33
  end
33
34
 
34
35
  it "should print comments when scenario is longer" do
35
- @l.feature("Feature", "Hello\nWorld", 1)
36
+ @l.feature([], [], "Feature", "Hello", "World", "features/foo.feature")
36
37
  @l.steps([
37
38
  ['Given ', 'some stuff'],
38
39
  ['When ', 'foo']
39
40
  ])
40
- @l.scenario("Scenario", "The scenario", 4, "features/foo.feature:4")
41
- @l.step("Given ", "some stuff", 5, nil, nil, nil, "features/step_definitions/bar.rb:56")
42
- @l.step("When ", "foo", 6, nil, nil, nil, "features/step_definitions/bar.rb:96")
41
+ @l.scenario([], [], "Scenario", "The scenario", "", 4)
42
+ @l.step([], "Given ", "some stuff", 5, nil, nil, nil, nil, "features/step_definitions/bar.rb:56")
43
+ @l.step([], "When ", "foo", 6, nil, nil, nil, nil, "features/step_definitions/bar.rb:96")
43
44
 
44
45
  assert_io(%{Feature: Hello
45
46
  World
@@ -51,12 +52,12 @@ module Gherkin
51
52
  end
52
53
 
53
54
  it "should print comments when step is longer" do
54
- @l.feature("Feature", "Hello\nWorld", 1)
55
+ @l.feature([], [], "Feature", "Hello", "World", "features/foo.feature")
55
56
  @l.steps([
56
57
  ['Given ', 'some stuff that is longer']
57
58
  ])
58
- @l.scenario("Scenario", "The scenario", 4, "features/foo.feature:4")
59
- @l.step("Given ", "some stuff that is longer", 5, nil, nil, nil, "features/step_definitions/bar.rb:56")
59
+ @l.scenario([], [], "Scenario", "The scenario", "", 4)
60
+ @l.step([], "Given ", "some stuff that is longer", 5, nil, nil, nil, nil, "features/step_definitions/bar.rb:56")
60
61
 
61
62
  assert_io(%{Feature: Hello
62
63
  World
@@ -66,38 +67,9 @@ module Gherkin
66
67
  })
67
68
  end
68
69
 
69
- it "should print ANSI coloured steps" do
70
- @l.feature("Feature", "Hello\nWorld", 1)
71
- @l.steps([
72
- ['Given ', 'some stuff that is longer']
73
- ])
74
- @l.scenario("Scenario", "The scenario", 4, "features/foo.feature:4")
75
- @l.step("Given ", "some stuff that is longer", 5, nil, nil, nil, "features/step_definitions/bar.rb:56")
76
-
77
- assert_io(%{Feature: Hello
78
- World
79
-
80
- Scenario: The scenario # features/foo.feature:4
81
- Given some stuff that is longer # features/step_definitions/bar.rb:56
82
- })
83
- end
84
-
85
- it "should prettify a whole table with padding (typically ANSI)" do
86
- @l.row(%w(a bb), 1)
87
- @l.row(%w(ccc d), 2)
88
- @l.row(%w(ee ffff), 3)
89
- @l.flush_table
90
-
91
- assert_io(
92
- " | a | bb |\n" +
93
- " | ccc | d |\n" +
94
- " | ee | ffff |\n"
95
- )
96
- end
97
-
98
70
  it "should highlight arguments for regular steps" do
99
71
  passed = defined?(JRUBY_VERSION) ? 'passed' : :passed
100
- @l.step("Given ", "I have 999 cukes in my belly", 3, passed, nil, [Gherkin::Formatter::Argument.new(7, '999')], nil)
72
+ @l.step([], "Given ", "I have 999 cukes in my belly", 3, nil, passed, nil, [Gherkin::Formatter::Argument.new(7, '999')], nil)
101
73
  assert_io(" Given I have 999 cukes in my belly\n")
102
74
  end
103
75
 
@@ -106,6 +78,7 @@ module Gherkin
106
78
  Some preamble
107
79
 
108
80
  Scenario: Scenario Description
81
+ description has multiple lines
109
82
  Given there is a step
110
83
  """
111
84
  with
@@ -151,11 +124,9 @@ Feature: Feature Description
151
124
 
152
125
  it "should escape backslashes and pipes" do
153
126
  io = StringIO.new
154
- l = PrettyFormatter.new(io, true)
155
- l.row(['|', '\\'], 1)
156
- l.flush_table
157
- io.rewind
158
- io.read.should == ' | \\| | \\\\ |' + "\n"
127
+ l = Gherkin::Formatter::PrettyFormatter.new(io, true)
128
+ l.__send__(:table, [Gherkin::Parser::Row.new(['|', '\\'], [], nil)])
129
+ io.string.should == ' | \\| | \\\\ |' + "\n"
159
130
  end
160
131
  end
161
132
  end
@@ -1,26 +1,26 @@
1
1
  #encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'spec_helper'
3
3
 
4
4
  module Gherkin
5
5
  describe I18nLexer do
6
6
  before do
7
- @lexer = I18nLexer.new(SexpRecorder.new, false)
7
+ @lexer = Gherkin::I18nLexer.new(Gherkin::SexpRecorder.new, false)
8
8
  end
9
9
 
10
10
  it "should store the i18n language of the last scanned feature" do
11
- @lexer.scan("# language: fr\n")
11
+ @lexer.scan("# language: fr\n", "fr.feature", 0)
12
12
  @lexer.i18n_language.iso_code.should == "fr"
13
- @lexer.scan("# language: no\n")
13
+ @lexer.scan("# language: no\n", "en.feature", 0)
14
14
  @lexer.i18n_language.iso_code.should == "no"
15
15
  end
16
16
 
17
17
  it "should use English i18n by default" do
18
- @lexer.scan("Feature: foo\n")
18
+ @lexer.scan("Feature: foo\n", "foo.feature", 0)
19
19
  @lexer.i18n_language.iso_code.should == "en"
20
20
  end
21
21
 
22
22
  it "should === its ruby class, even when the impl is Java" do
23
- I18nLexer.should === I18nLexer.new(SexpRecorder.new, true)
23
+ Gherkin::I18nLexer.should === Gherkin::I18nLexer.new(Gherkin::SexpRecorder.new, true)
24
24
  end
25
25
  end
26
26
  end