cucumber 0.3.95 → 0.3.96

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/History.txt +21 -0
  2. data/Manifest.txt +9 -3
  3. data/examples/sinatra/features/support/env.rb +1 -3
  4. data/features/cucumber_cli.feature +1 -0
  5. data/features/drb_server_integration.feature +56 -3
  6. data/features/junit_formatter.feature +23 -12
  7. data/features/step_definitions/cucumber_steps.rb +13 -2
  8. data/features/support/env.rb +19 -3
  9. data/lib/cucumber/ast/feature_element.rb +1 -1
  10. data/lib/cucumber/ast/step.rb +1 -1
  11. data/lib/cucumber/ast/step_invocation.rb +3 -2
  12. data/lib/cucumber/cli/configuration.rb +9 -25
  13. data/lib/cucumber/cli/drb_client.rb +7 -3
  14. data/lib/cucumber/cli/language_help_formatter.rb +4 -4
  15. data/lib/cucumber/cli/main.rb +26 -46
  16. data/lib/cucumber/cli/options.rb +3 -0
  17. data/lib/cucumber/constantize.rb +28 -0
  18. data/lib/cucumber/feature_file.rb +3 -3
  19. data/lib/cucumber/formatter/junit.rb +13 -9
  20. data/lib/cucumber/formatter/pretty.rb +2 -2
  21. data/lib/cucumber/language_support/hook_methods.rb +9 -0
  22. data/lib/cucumber/language_support/language_methods.rb +47 -0
  23. data/lib/cucumber/language_support/step_definition_methods.rb +44 -0
  24. data/lib/cucumber/parser/natural_language.rb +72 -0
  25. data/lib/cucumber/rb_support/rb_dsl.rb +73 -0
  26. data/lib/cucumber/rb_support/rb_hook.rb +19 -0
  27. data/lib/cucumber/rb_support/rb_language.rb +129 -0
  28. data/lib/cucumber/rb_support/rb_step_definition.rb +56 -0
  29. data/lib/cucumber/step_match.rb +2 -2
  30. data/lib/cucumber/step_mother.rb +87 -206
  31. data/lib/cucumber/version.rb +1 -1
  32. data/lib/cucumber/webrat/element_locator.rb +7 -7
  33. data/lib/cucumber/world.rb +28 -8
  34. data/rails_generators/cucumber/templates/cucumber_environment.rb +2 -2
  35. data/rails_generators/cucumber/templates/spork_env.rb +0 -2
  36. data/rails_generators/cucumber/templates/webrat_steps.rb +17 -0
  37. data/spec/cucumber/ast/background_spec.rb +8 -5
  38. data/spec/cucumber/ast/feature_factory.rb +4 -5
  39. data/spec/cucumber/ast/feature_spec.rb +7 -1
  40. data/spec/cucumber/ast/scenario_outline_spec.rb +10 -6
  41. data/spec/cucumber/ast/scenario_spec.rb +8 -3
  42. data/spec/cucumber/ast/step_collection_spec.rb +2 -2
  43. data/spec/cucumber/cli/configuration_spec.rb +15 -0
  44. data/spec/cucumber/cli/drb_client_spec.rb +35 -1
  45. data/spec/cucumber/cli/main_spec.rb +5 -4
  46. data/spec/cucumber/cli/options_spec.rb +6 -0
  47. data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
  48. data/spec/cucumber/parser/table_parser_spec.rb +1 -1
  49. data/spec/cucumber/step_definition_spec.rb +26 -25
  50. data/spec/cucumber/step_mother_spec.rb +46 -41
  51. data/spec/cucumber/world/pending_spec.rb +4 -5
  52. metadata +11 -5
  53. data/lib/cucumber/cli/rb_step_def_loader.rb +0 -14
  54. data/lib/cucumber/parser/i18n/language.rb +0 -87
  55. data/lib/cucumber/step_definition.rb +0 -122
@@ -6,7 +6,7 @@ module Cucumber
6
6
  module Parser
7
7
  describe 'Tables' do
8
8
  before do
9
- @parser = I18n::EnglishParser.new
9
+ @parser = NaturalLanguage.get(StepMother.new, 'en').parser
10
10
  end
11
11
 
12
12
  def parse(text)
@@ -2,72 +2,73 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  require 'cucumber/ast'
4
4
  require 'cucumber/step_mother'
5
- require 'cucumber/step_definition'
5
+ require 'cucumber/rb_support/rb_language'
6
6
 
7
7
  module Cucumber
8
- describe StepDefinition do
9
- before do
10
- extend StepMother
11
- @world = new_world!
8
+ describe RbStepDefinition do
9
+ before do
10
+ @step_mother = StepMother.new
11
+ @step_mother.load_natural_language('en')
12
+ @rb = @step_mother.load_programming_language('rb')
13
+ @dsl = Object.new
14
+ @dsl.extend RbSupport::RbDsl
15
+ @step_mother.begin_scenario
16
+
12
17
  $inside = nil
13
18
  end
14
19
 
15
20
  it "should allow calling of other steps" do
16
- Given /Outside/ do
21
+ @dsl.Given /Outside/ do
17
22
  Given "Inside"
18
23
  end
19
- Given /Inside/ do
24
+ @dsl.Given /Inside/ do
20
25
  $inside = true
21
26
  end
22
27
 
23
- step_match("Outside").invoke(@world, nil)
28
+ @step_mother.step_match("Outside").invoke(nil)
24
29
  $inside.should == true
25
30
  end
26
31
 
27
32
  it "should allow calling of other steps with inline arg" do
28
- Given /Outside/ do
33
+ @dsl.Given /Outside/ do
29
34
  Given "Inside", Ast::Table.new([['inside']])
30
35
  end
31
- Given /Inside/ do |table|
36
+ @dsl.Given /Inside/ do |table|
32
37
  $inside = table.raw[0][0]
33
38
  end
34
39
 
35
- step_match("Outside").invoke(@world, nil)
40
+ @step_mother.step_match("Outside").invoke(nil)
36
41
  $inside.should == 'inside'
37
42
  end
38
43
 
39
44
  it "should raise Undefined when inside step is not defined" do
40
- Given /Outside/ do
45
+ @dsl.Given /Outside/ do
41
46
  Given 'Inside'
42
47
  end
43
48
 
44
- step = mock('Step')
45
- step.should_receive(:exception=)
46
49
  lambda do
47
- @world.__cucumber_current_step = step
48
- step_match('Outside').invoke(@world, nil)
50
+ @step_mother.step_match('Outside').invoke(nil)
49
51
  end.should raise_error(Undefined, 'Undefined step: "Inside"')
50
52
  end
51
53
 
52
54
  it "should allow forced pending" do
53
- Given /Outside/ do
55
+ @dsl.Given /Outside/ do
54
56
  pending("Do me!")
55
57
  end
56
58
 
57
59
  lambda do
58
- step_match("Outside").invoke(@world, nil)
60
+ @step_mother.step_match("Outside").invoke(nil)
59
61
  end.should raise_error(Pending, "Do me!")
60
62
  end
61
63
 
62
64
  it "should allow announce" do
63
65
  v = mock('visitor')
64
66
  v.should_receive(:announce).with('wasup')
65
- self.visitor = v
66
- world = new_world!
67
- Given /Loud/ do
67
+ @step_mother.visitor = v
68
+ @dsl.Given /Loud/ do
68
69
  announce 'wasup'
69
70
  end
70
- step_match("Loud").invoke(world, nil)
71
+ @step_mother.step_match("Loud").invoke(nil)
71
72
  end
72
73
 
73
74
  def unindented(s)
@@ -75,7 +76,7 @@ module Cucumber
75
76
  end
76
77
 
77
78
  it "should recognise quotes in name and make according regexp" do
78
- StepDefinition.snippet_text('Given', 'A "first" arg').should == unindented(%{
79
+ @rb.snippet_text('Given', 'A "first" arg').should == unindented(%{
79
80
  Given /^A "([^\\"]*)" arg$/ do |arg1|
80
81
  pending
81
82
  end
@@ -83,7 +84,7 @@ module Cucumber
83
84
  end
84
85
 
85
86
  it "should recognise several quoted words in name and make according regexp and args" do
86
- StepDefinition.snippet_text('Given', 'A "first" and "second" arg').should == unindented(%{
87
+ @rb.snippet_text('Given', 'A "first" and "second" arg').should == unindented(%{
87
88
  Given /^A "([^\\"]*)" and "([^\\"]*)" arg$/ do |arg1, arg2|
88
89
  pending
89
90
  end
@@ -91,7 +92,7 @@ module Cucumber
91
92
  end
92
93
 
93
94
  it "should not use quote group when there are no quotes" do
94
- StepDefinition.snippet_text('Given', 'A first arg').should == unindented(%{
95
+ @rb.snippet_text('Given', 'A first arg').should == unindented(%{
95
96
  Given /^A first arg$/ do
96
97
  pending
97
98
  end
@@ -1,34 +1,40 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- require 'cucumber/step_mother'
3
+ require 'cucumber'
4
+ require 'cucumber/rb_support/rb_language'
4
5
 
5
6
  module Cucumber
6
7
  describe StepMother do
7
8
  before do
8
- @step_mother = Object.new
9
- @step_mother.extend(StepMother)
9
+ @dsl = Object.new
10
+ @dsl.extend(RbSupport::RbDsl)
11
+
12
+ @step_mother = StepMother.new
13
+ @step_mother.load_natural_language('en')
14
+ @rb = @step_mother.load_programming_language('rb')
15
+
10
16
  @visitor = mock('Visitor')
11
17
  end
12
18
 
13
19
  it "should format step names" do
14
- @step_mother.Given(/it (.*) in (.*)/) do |what, month|
20
+ @dsl.Given(/it (.*) in (.*)/) do |what, month|
15
21
  end
16
- @step_mother.Given(/nope something else/) do |what, month|
22
+ @dsl.Given(/nope something else/) do |what, month|
17
23
  end
18
24
  format = @step_mother.step_match("it snows in april").format_args("[%s]")
19
25
  format.should == "it [snows] in [april]"
20
26
  end
21
27
 
22
28
  it "should raise Ambiguous error with guess hint when multiple step definitions match" do
23
- @step_mother.Given(/Three (.*) mice/) {|disability|}
24
- @step_mother.Given(/Three blind (.*)/) {|animal|}
29
+ @dsl.Given(/Three (.*) mice/) {|disability|}
30
+ @dsl.Given(/Three blind (.*)/) {|animal|}
25
31
 
26
32
  lambda do
27
33
  @step_mother.step_match("Three blind mice")
28
34
  end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
29
35
 
30
- spec/cucumber/step_mother_spec.rb:23:in `/Three (.*) mice/'
31
- spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
36
+ spec/cucumber/step_mother_spec.rb:29:in `/Three (.*) mice/'
37
+ spec/cucumber/step_mother_spec.rb:30:in `/Three blind (.*)/'
32
38
 
33
39
  You can run again with --guess to make Cucumber be more smart about it
34
40
  })
@@ -36,23 +42,23 @@ You can run again with --guess to make Cucumber be more smart about it
36
42
 
37
43
  it "should not show --guess hint when --guess is used" do
38
44
  @step_mother.options = {:guess => true}
39
- @step_mother.Given(/Three (.*) mice/) {|disability|}
40
- @step_mother.Given(/Three cute (.*)/) {|animal|}
45
+ @dsl.Given(/Three (.*) mice/) {|disability|}
46
+ @dsl.Given(/Three cute (.*)/) {|animal|}
41
47
 
42
48
  lambda do
43
49
  @step_mother.step_match("Three cute mice")
44
50
  end.should raise_error(Ambiguous, %{Ambiguous match of "Three cute mice":
45
51
 
46
- spec/cucumber/step_mother_spec.rb:39:in `/Three (.*) mice/'
47
- spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
52
+ spec/cucumber/step_mother_spec.rb:45:in `/Three (.*) mice/'
53
+ spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
48
54
 
49
55
  })
50
56
  end
51
57
 
52
58
  it "should not raise Ambiguous error when multiple step definitions match, but --guess is enabled" do
53
59
  @step_mother.options = {:guess => true}
54
- @step_mother.Given(/Three (.*) mice/) {|disability|}
55
- @step_mother.Given(/Three (.*)/) {|animal|}
60
+ @dsl.Given(/Three (.*) mice/) {|disability|}
61
+ @dsl.Given(/Three (.*)/) {|animal|}
56
62
 
57
63
  lambda do
58
64
  @step_mother.step_match("Three blind mice")
@@ -61,23 +67,23 @@ spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
61
67
 
62
68
  it "should pick right step definition when --guess is enabled and equal number of capture groups" do
63
69
  @step_mother.options = {:guess => true}
64
- right = @step_mother.Given(/Three (.*) mice/) {|disability|}
65
- wrong = @step_mother.Given(/Three (.*)/) {|animal|}
70
+ right = @dsl.Given(/Three (.*) mice/) {|disability|}
71
+ wrong = @dsl.Given(/Three (.*)/) {|animal|}
66
72
  @step_mother.step_match("Three blind mice").step_definition.should == right
67
73
  end
68
74
 
69
75
  it "should pick right step definition when --guess is enabled and unequal number of capture groups" do
70
76
  @step_mother.options = {:guess => true}
71
- right = @step_mother.Given(/Three (.*) mice ran (.*)/) {|disability|}
72
- wrong = @step_mother.Given(/Three (.*)/) {|animal|}
77
+ right = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
78
+ wrong = @dsl.Given(/Three (.*)/) {|animal|}
73
79
  @step_mother.step_match("Three blind mice ran far").step_definition.should == right
74
80
  end
75
81
 
76
82
  it "should pick most specific step definition when --guess is enabled and unequal number of capture groups" do
77
83
  @step_mother.options = {:guess => true}
78
- general = @step_mother.Given(/Three (.*) mice ran (.*)/) {|disability|}
79
- specific = @step_mother.Given(/Three blind mice ran far/) {}
80
- more_specific = @step_mother.Given(/^Three blind mice ran far$/) {}
84
+ general = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
85
+ specific = @dsl.Given(/Three blind mice ran far/) {}
86
+ more_specific = @dsl.Given(/^Three blind mice ran far$/) {}
81
87
  @step_mother.step_match("Three blind mice ran far").step_definition.should == more_specific
82
88
  end
83
89
 
@@ -88,28 +94,28 @@ spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
88
94
  end
89
95
 
90
96
  it "should raise Redundant error when same regexp is registered twice" do
91
- @step_mother.Given(/Three (.*) mice/) {|disability|}
97
+ @dsl.Given(/Three (.*) mice/) {|disability|}
92
98
  lambda do
93
- @step_mother.Given(/Three (.*) mice/) {|disability|}
99
+ @dsl.Given(/Three (.*) mice/) {|disability|}
94
100
  end.should raise_error(Redundant)
95
101
  end
96
102
 
97
103
  # http://railsforum.com/viewtopic.php?pid=93881
98
104
  it "should not raise Redundant unless it's really redundant" do
99
- @step_mother.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
100
- @step_mother.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
105
+ @dsl.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
106
+ @dsl.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
101
107
  end
102
108
 
103
109
  it "should raise an error if the world is nil" do
104
- @step_mother.World do
110
+ @dsl.World do
105
111
  end
106
112
 
107
113
  begin
108
114
  @step_mother.before_and_after(nil) {}
109
115
  raise "Should fail"
110
- rescue NilWorld => e
116
+ rescue RbSupport::NilWorld => e
111
117
  e.message.should == "World procs should never return nil"
112
- e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:104:in `World'"]
118
+ e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:110:in `World'"]
113
119
  end
114
120
  end
115
121
 
@@ -123,25 +129,24 @@ spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
123
129
  end
124
130
 
125
131
  it "should implicitly extend world with modules" do
126
- @step_mother.World(ModuleOne, ModuleTwo)
127
-
128
- w = @step_mother.__send__(:new_world!)
129
- class << w
132
+ @dsl.World(ModuleOne, ModuleTwo)
133
+ @step_mother.begin_scenario
134
+ class << @rb.current_world
130
135
  included_modules.index(ModuleOne).should_not == nil
131
136
  included_modules.index(ModuleTwo).should_not == nil
132
137
  end
133
- w.class.should == Object
138
+ @rb.current_world.class.should == Object
134
139
  end
135
140
 
136
141
  it "should raise error when we try to register more than one World proc" do
137
- @step_mother.World { Hash.new }
142
+ @dsl.World { Hash.new }
138
143
  lambda do
139
- @step_mother.World { Array.new }
140
- end.should raise_error(MultipleWorld, %{You can only pass a proc to #World once, but it's happening
144
+ @dsl.World { Array.new }
145
+ end.should raise_error(RbSupport::MultipleWorld, %{You can only pass a proc to #World once, but it's happening
141
146
  in 2 places:
142
147
 
143
- spec/cucumber/step_mother_spec.rb:137:in `World'
144
- spec/cucumber/step_mother_spec.rb:139:in `World'
148
+ spec/cucumber/step_mother_spec.rb:142:in `World'
149
+ spec/cucumber/step_mother_spec.rb:144:in `World'
145
150
 
146
151
  Use Ruby modules instead to extend your worlds. See the Cucumber::StepMother#World RDoc
147
152
  or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
@@ -150,8 +155,8 @@ or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
150
155
  end
151
156
 
152
157
  it "should find before hooks" do
153
- fish = @step_mother.Before('@fish'){}
154
- meat = @step_mother.Before('@meat'){}
158
+ fish = @dsl.Before('@fish'){}
159
+ meat = @dsl.Before('@meat'){}
155
160
 
156
161
  scenario = mock('Scenario')
157
162
  scenario.should_receive(:accept_hook?).with(fish).and_return(true)
@@ -1,13 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'cucumber/rb_support/rb_language'
2
3
 
3
4
  module Cucumber
4
- module StepMother
5
5
  describe 'Pending' do
6
6
 
7
7
  before(:each) do
8
- @step_mom = Object.new
9
- @step_mom.extend(StepMother)
10
- @world = @step_mom.__send__(:new_world!)
8
+ l = RbSupport::RbLanguage.new(StepMother.new)
9
+ l.begin_scenario
10
+ @world = l.current_world
11
11
  end
12
12
 
13
13
  it 'should raise a Pending if no block is supplied' do
@@ -43,5 +43,4 @@ module Cucumber
43
43
  end
44
44
 
45
45
  end
46
- end
47
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.95
4
+ version: 0.3.96
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-08-13 00:00:00 +02:00
12
+ date: 2009-08-20 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -388,7 +388,7 @@ files:
388
388
  - lib/cucumber/cli/main.rb
389
389
  - lib/cucumber/cli/options.rb
390
390
  - lib/cucumber/cli/profile_loader.rb
391
- - lib/cucumber/cli/rb_step_def_loader.rb
391
+ - lib/cucumber/constantize.rb
392
392
  - lib/cucumber/core_ext/exception.rb
393
393
  - lib/cucumber/core_ext/instance_exec.rb
394
394
  - lib/cucumber/core_ext/proc.rb
@@ -413,12 +413,15 @@ files:
413
413
  - lib/cucumber/formatter/unicode.rb
414
414
  - lib/cucumber/formatter/usage.rb
415
415
  - lib/cucumber/formatters/unicode.rb
416
+ - lib/cucumber/language_support/hook_methods.rb
417
+ - lib/cucumber/language_support/language_methods.rb
418
+ - lib/cucumber/language_support/step_definition_methods.rb
416
419
  - lib/cucumber/languages.yml
417
420
  - lib/cucumber/parser.rb
418
421
  - lib/cucumber/parser/feature.rb
419
422
  - lib/cucumber/parser/feature.tt
420
423
  - lib/cucumber/parser/i18n.tt
421
- - lib/cucumber/parser/i18n/language.rb
424
+ - lib/cucumber/parser/natural_language.rb
422
425
  - lib/cucumber/parser/table.rb
423
426
  - lib/cucumber/parser/table.tt
424
427
  - lib/cucumber/parser/treetop_ext.rb
@@ -426,8 +429,11 @@ files:
426
429
  - lib/cucumber/rails/rspec.rb
427
430
  - lib/cucumber/rails/world.rb
428
431
  - lib/cucumber/rake/task.rb
432
+ - lib/cucumber/rb_support/rb_dsl.rb
433
+ - lib/cucumber/rb_support/rb_hook.rb
434
+ - lib/cucumber/rb_support/rb_language.rb
435
+ - lib/cucumber/rb_support/rb_step_definition.rb
429
436
  - lib/cucumber/rspec_neuter.rb
430
- - lib/cucumber/step_definition.rb
431
437
  - lib/cucumber/step_match.rb
432
438
  - lib/cucumber/step_mother.rb
433
439
  - lib/cucumber/version.rb
@@ -1,14 +0,0 @@
1
- module Cucumber
2
- module Cli
3
- class RbStepDefLoader
4
- def load_step_def_file(main, step_def_file)
5
- begin
6
- require step_def_file
7
- rescue LoadError => e
8
- e.message << "\nFailed to load #{step_def_file}"
9
- raise e
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,87 +0,0 @@
1
- module Cucumber
2
- module Parser
3
- module I18n
4
- class Language
5
- KEYWORD_KEYS = %w{name native encoding feature background scenario scenario_outline examples given when then but}
6
-
7
- class << self
8
- LANGUAGES = Hash.new{|h,k| h[k] = Language.new(k)}
9
-
10
- def [](key)
11
- LANGUAGES[key]
12
- end
13
-
14
- def alias_step_definitions(keywords) #:nodoc:
15
- all_keywords = %w{given when then and but}.map{|keyword| keywords[keyword].split('|')}.flatten
16
- alias_steps(all_keywords)
17
- end
18
-
19
- # Sets up additional method aliases for Given, When and Then.
20
- # This does *not* affect how feature files are parsed. If you
21
- # want to create aliases in the parser, you have to do this in
22
- # languages.yml. For example:
23
- #
24
- # and: And|With
25
- def alias_steps(keywords)
26
- keywords.each do |adverb|
27
- StepMother.alias_adverb(adverb)
28
- World.alias_adverb(adverb)
29
- end
30
- end
31
- end
32
-
33
- alias_step_definitions(Cucumber::LANGUAGES['en'])
34
-
35
- def initialize(lang)
36
- @keywords = Cucumber::LANGUAGES[lang]
37
- raise "Language not supported: #{lang.inspect}" if @keywords.nil?
38
- @keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
39
- end
40
-
41
- def parser
42
- return @parser if @parser
43
- i18n_tt = File.expand_path(File.dirname(__FILE__) + '/../i18n.tt')
44
- template = File.open(i18n_tt, Cucumber.file_mode('r')).read
45
- erb = ERB.new(template)
46
- grammar = erb.result(binding)
47
- Treetop.load_from_string(grammar)
48
- self.class.alias_step_definitions(@keywords)
49
- @parser = Parser::I18n.const_get("#{@keywords['grammar_name']}Parser").new
50
- def @parser.inspect
51
- "#<#{self.class.name}>"
52
- end
53
- @parser
54
- end
55
-
56
- def parse(source, path, filter)
57
- feature = parser.parse_or_fail(source, path, filter)
58
- feature.language = self if feature
59
- feature
60
- end
61
-
62
- def keywords(key, raw=false)
63
- return @keywords[key] if raw
64
- return nil unless @keywords[key]
65
- values = @keywords[key].split('|')
66
- values.map{|value| "'#{value}'"}.join(" / ")
67
- end
68
-
69
- def incomplete?
70
- KEYWORD_KEYS.detect{|key| @keywords[key].nil?}
71
- end
72
-
73
- def scenario_keyword
74
- @keywords['scenario'].split('|')[0] + ':'
75
- end
76
-
77
- def but_keywords
78
- @keywords['but'].split('|')
79
- end
80
-
81
- def and_keywords
82
- @keywords['and'].split('|')
83
- end
84
- end
85
- end
86
- end
87
- end