cucumber 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +81 -0
- data/Manifest.txt +30 -9
- data/README.txt +1 -2
- data/bin/cucumber +1 -1
- data/examples/calculator/README.txt +5 -0
- data/examples/calculator/Rakefile +1 -2
- data/examples/calculator/features/addition.feature +1 -0
- data/examples/chinese_simplified_calculator/Rakefile +6 -0
- data/examples/chinese_simplified_calculator/features/addition.feature +17 -0
- data/examples/chinese_simplified_calculator/features/steps/calculator_steps.rb +24 -0
- data/examples/chinese_simplified_calculator/lib/calculator.rb +10 -0
- data/examples/java/features/steps/hello_steps.rb +1 -1
- data/examples/swedish_calculator/Rakefile +5 -0
- data/examples/swedish_calculator/features/steps/kalkulator_steps.rb +22 -0
- data/examples/swedish_calculator/features/summering.feature +17 -0
- data/examples/swedish_calculator/lib/kalkulator.rb +11 -0
- data/examples/tickets/Rakefile +8 -1
- data/examples/tickets/cucumber.yml +2 -0
- data/examples/tickets/features/steps/tickets_steps.rb +15 -0
- data/examples/tickets/features/tickets.feature +12 -1
- data/gem_tasks/treetop.rake +35 -23
- data/lib/cucumber.rb +1 -0
- data/lib/cucumber/cli.rb +19 -5
- data/lib/cucumber/core_ext/proc.rb +8 -5
- data/lib/cucumber/executor.rb +7 -1
- data/lib/cucumber/formatters.rb +1 -1
- data/lib/cucumber/formatters/html_formatter.rb +6 -3
- data/lib/cucumber/formatters/pretty_formatter.rb +29 -7
- data/lib/cucumber/formatters/profile_formatter.rb +92 -0
- data/lib/cucumber/languages.yml +39 -12
- data/lib/cucumber/model.rb +1 -0
- data/lib/cucumber/model/table.rb +28 -0
- data/lib/cucumber/rails/world.rb +1 -3
- data/lib/cucumber/rake/task.rb +1 -1
- data/lib/cucumber/tree/feature.rb +8 -2
- data/lib/cucumber/tree/scenario.rb +23 -6
- data/lib/cucumber/tree/step.rb +5 -4
- data/lib/cucumber/treetop_parser/feature.treetop.erb +54 -12
- data/lib/cucumber/treetop_parser/feature_da.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_de.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_en.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_es.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_et.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_fr.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_nl.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_pt.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_ru.rb +415 -74
- data/lib/cucumber/treetop_parser/feature_se.rb +419 -78
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1593 -0
- data/lib/cucumber/version.rb +1 -1
- data/{generators → rails_generators}/cucumber/cucumber_generator.rb +0 -0
- data/{generators → rails_generators}/cucumber/templates/common_webrat.rb +1 -10
- data/{generators → rails_generators}/cucumber/templates/cucumber +0 -0
- data/{generators → rails_generators}/cucumber/templates/cucumber.rake +0 -0
- data/{generators → rails_generators}/cucumber/templates/env.rb +0 -0
- data/{generators → rails_generators}/feature/feature_generator.rb +0 -0
- data/{generators → rails_generators}/feature/templates/feature.erb +1 -0
- data/{generators → rails_generators}/feature/templates/steps.erb +0 -0
- data/spec/cucumber/cli_spec.rb +11 -3
- data/spec/cucumber/core_ext/proc_spec.rb +6 -0
- data/spec/cucumber/formatters/html_formatter_spec.rb +16 -1
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +54 -25
- data/spec/cucumber/formatters/profile_formatter_spec.rb +193 -0
- data/spec/cucumber/model/table_spec.rb +20 -0
- data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
- data/spec/cucumber/rails/stubs/test_help.rb +1 -0
- data/spec/cucumber/rails/world_spec.rb +11 -0
- data/spec/cucumber/tree/feature_spec.rb +12 -0
- data/spec/cucumber/tree/scenario_spec.rb +22 -0
- data/spec/cucumber/tree/step_spec.rb +12 -2
- data/spec/cucumber/treetop_parser/empty_scenario.feature +1 -1
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +18 -0
- data/spec/cucumber/treetop_parser/fit_scenario.feature +1 -0
- data/spec/cucumber/treetop_parser/multiline_steps.feature +13 -0
- data/spec/cucumber/treetop_parser/multiple_tables.feature +2 -0
- data/spec/cucumber/treetop_parser/test_dos.feature +1 -0
- data/spec/cucumber/treetop_parser/with_comments.feature +6 -2
- metadata +34 -12
- data/examples/calculator/cucumber.yml +0 -1
data/History.txt
CHANGED
@@ -1,3 +1,84 @@
|
|
1
|
+
== 0.1.8 2008-10-18
|
2
|
+
|
3
|
+
This release extends the support for tables. PLEASE NOTE THAT TABLES ARE STILL EXPERIMENTAL.
|
4
|
+
In previous releases it has been possible to use tables to define "more examples" of a scenario i
|
5
|
+
n a FIT-style column fixture kind of way. Now you can also use tables as arguments to steps.
|
6
|
+
|
7
|
+
Tables used to define more examples after a scenario must now be prefixed. In English it looks like this:
|
8
|
+
|
9
|
+
Feature: Addition
|
10
|
+
In order to avoid silly mistakes
|
11
|
+
As a math idiot
|
12
|
+
I want to be told the sum of two numbers
|
13
|
+
|
14
|
+
Scenario: Add two numbers
|
15
|
+
Given I have entered 50 into the calculator
|
16
|
+
And I have entered 70 into the calculator
|
17
|
+
When I press add
|
18
|
+
Then the result should be 120 on the screen
|
19
|
+
And the result class should be Fixnum
|
20
|
+
|
21
|
+
More Examples:
|
22
|
+
| input_1 | input_2 | button | output | class |
|
23
|
+
| 20 | 30 | add | 50 | Fixnum |
|
24
|
+
| 2 | 5 | add | 7 | Fixnum |
|
25
|
+
| 0 | 40 | add | 40 | Fixnum |
|
26
|
+
|
27
|
+
Languages that are not updated yet will have to use "More Examples" until we get the translations.
|
28
|
+
|
29
|
+
Tables can also be used as arguments to individual steps. In fact, steps now support a single argument
|
30
|
+
that can span several lines. This can be a table or a string.
|
31
|
+
|
32
|
+
Example:
|
33
|
+
|
34
|
+
Given the following people exist:
|
35
|
+
| name | email | phone |
|
36
|
+
| Aslak | aslak@email.com | 123 |
|
37
|
+
| Joe | joe@email.com | 234 |
|
38
|
+
| Bryan | bryan@email.org | 234 |
|
39
|
+
When I search for email.com
|
40
|
+
Then I should see:
|
41
|
+
| name | email | phone |
|
42
|
+
| Aslak | aslak@email.com | 123 |
|
43
|
+
| Joe | joe@email.com | 234 |
|
44
|
+
And I should see:
|
45
|
+
"Some text
|
46
|
+
on several lines"
|
47
|
+
|
48
|
+
The step definitions for such multiline steps must define an extra block argument for the argument:
|
49
|
+
|
50
|
+
Given /the following people exist:/ do |people_table|
|
51
|
+
# people_table is of type Cucumber::Model::Table
|
52
|
+
# See RDoc for more info
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /I should see:/ do |string|
|
56
|
+
# string is a plain old ruby String with leading spaces on each line removed
|
57
|
+
end
|
58
|
+
|
59
|
+
=== New features
|
60
|
+
* Added profile formatter. (#35, Joseph Wilk)
|
61
|
+
* Added support for Chinese Simplified. (Liming Lian)
|
62
|
+
* Added support for Dutch. (Sjoerd Tieleman)
|
63
|
+
* Multiline steps are now supported. (#4, Aslak Hellesøy)
|
64
|
+
* Tables used to define more examples for a scenario must be prefixed "More Examples" (see languages.yml for other languages)
|
65
|
+
* Show the file and line number for scenarios as a comment when displaying with the pretty formatter. (#40, Joseph Wilk)
|
66
|
+
* Show the file for the feature as a comment when displaying with the pretty formatter. (#40, Joseph Wilk)
|
67
|
+
* Show the feature file and line for pending steps as a comment when displaying with the pretty formatter. (#40, Joseph Wilk)
|
68
|
+
|
69
|
+
=== Bugfixes
|
70
|
+
* Fixed speling errors in Spanish (Daniel Cadenas)
|
71
|
+
* ActionMailer delivery_method should not be set to test (#41, Luke Melia)
|
72
|
+
* Reverse incorrectly ordered args in webrat select step (#43, David Chelimsky)
|
73
|
+
* Support comments above the first scenario (#31, Aslak Hellesøy)
|
74
|
+
* Fixed the HTML Formatter to use actual values for FIT table headers (#30, Joseph Wilk)
|
75
|
+
|
76
|
+
=== Removed features
|
77
|
+
* Removed the /^I go to (.*)$/ step from common_webrat.rb - it's not language agnostic and provides little value.
|
78
|
+
|
79
|
+
=== New features
|
80
|
+
* Added new --out option to make it easier to specify output from Rake and cucumber.yml
|
81
|
+
|
1
82
|
== 0.1.7
|
2
83
|
|
3
84
|
This release fixes a few bugs and adds some new features. The most notable features are:
|
data/Manifest.txt
CHANGED
@@ -8,8 +8,8 @@ bin/cucumber
|
|
8
8
|
config/hoe.rb
|
9
9
|
config/requirements.rb
|
10
10
|
cucumber.yml
|
11
|
+
examples/calculator/README.txt
|
11
12
|
examples/calculator/Rakefile
|
12
|
-
examples/calculator/cucumber.yml
|
13
13
|
examples/calculator/features/addition.feature
|
14
14
|
examples/calculator/features/division.feature
|
15
15
|
examples/calculator/features/steps/calculator_steps.rb
|
@@ -20,6 +20,10 @@ examples/calculator_ruby_features/features/steps/calculator_steps.rb
|
|
20
20
|
examples/calculatrice_francaise_avec_soit_scenario/Rakefile
|
21
21
|
examples/calculatrice_francaise_avec_soit_scenario/features/addition.feature
|
22
22
|
examples/calculatrice_francaise_avec_soit_scenario/features/calculatrice_steps.rb
|
23
|
+
examples/chinese_simplified_calculator/Rakefile
|
24
|
+
examples/chinese_simplified_calculator/features/addition.feature
|
25
|
+
examples/chinese_simplified_calculator/features/steps/calculator_steps.rb
|
26
|
+
examples/chinese_simplified_calculator/lib/calculator.rb
|
23
27
|
examples/cs/README.textile
|
24
28
|
examples/cs/Rakefile
|
25
29
|
examples/cs/features/hello.feature
|
@@ -57,7 +61,12 @@ examples/spanish_calculator/Rakefile
|
|
57
61
|
examples/spanish_calculator/features/adicion.feature
|
58
62
|
examples/spanish_calculator/features/steps/calculador_steps.rb
|
59
63
|
examples/spanish_calculator/lib/Calculador.rb
|
64
|
+
examples/swedish_calculator/Rakefile
|
65
|
+
examples/swedish_calculator/features/steps/kalkulator_steps.rb
|
66
|
+
examples/swedish_calculator/features/summering.feature
|
67
|
+
examples/swedish_calculator/lib/kalkulator.rb
|
60
68
|
examples/tickets/Rakefile
|
69
|
+
examples/tickets/cucumber.yml
|
61
70
|
examples/tickets/features/steps/tickets_steps.rb
|
62
71
|
examples/tickets/features/tickets.feature
|
63
72
|
examples/watir/Rakefile
|
@@ -73,14 +82,6 @@ gem_tasks/flog.rake
|
|
73
82
|
gem_tasks/gemspec.rake
|
74
83
|
gem_tasks/rspec.rake
|
75
84
|
gem_tasks/treetop.rake
|
76
|
-
generators/cucumber/cucumber_generator.rb
|
77
|
-
generators/cucumber/templates/common_webrat.rb
|
78
|
-
generators/cucumber/templates/cucumber
|
79
|
-
generators/cucumber/templates/cucumber.rake
|
80
|
-
generators/cucumber/templates/env.rb
|
81
|
-
generators/feature/feature_generator.rb
|
82
|
-
generators/feature/templates/feature.erb
|
83
|
-
generators/feature/templates/steps.erb
|
84
85
|
lib/cucumber.rb
|
85
86
|
lib/cucumber/cli.rb
|
86
87
|
lib/cucumber/core_ext/proc.rb
|
@@ -93,8 +94,11 @@ lib/cucumber/formatters/cucumber.js
|
|
93
94
|
lib/cucumber/formatters/html_formatter.rb
|
94
95
|
lib/cucumber/formatters/jquery.js
|
95
96
|
lib/cucumber/formatters/pretty_formatter.rb
|
97
|
+
lib/cucumber/formatters/profile_formatter.rb
|
96
98
|
lib/cucumber/formatters/progress_formatter.rb
|
97
99
|
lib/cucumber/languages.yml
|
100
|
+
lib/cucumber/model.rb
|
101
|
+
lib/cucumber/model/table.rb
|
98
102
|
lib/cucumber/rails/rspec.rb
|
99
103
|
lib/cucumber/rails/world.rb
|
100
104
|
lib/cucumber/rake/task.rb
|
@@ -115,12 +119,22 @@ lib/cucumber/treetop_parser/feature_en.rb
|
|
115
119
|
lib/cucumber/treetop_parser/feature_es.rb
|
116
120
|
lib/cucumber/treetop_parser/feature_et.rb
|
117
121
|
lib/cucumber/treetop_parser/feature_fr.rb
|
122
|
+
lib/cucumber/treetop_parser/feature_nl.rb
|
118
123
|
lib/cucumber/treetop_parser/feature_no.rb
|
119
124
|
lib/cucumber/treetop_parser/feature_parser.rb
|
120
125
|
lib/cucumber/treetop_parser/feature_pt.rb
|
121
126
|
lib/cucumber/treetop_parser/feature_ru.rb
|
122
127
|
lib/cucumber/treetop_parser/feature_se.rb
|
128
|
+
lib/cucumber/treetop_parser/feature_zh-CN.rb
|
123
129
|
lib/cucumber/version.rb
|
130
|
+
rails_generators/cucumber/cucumber_generator.rb
|
131
|
+
rails_generators/cucumber/templates/common_webrat.rb
|
132
|
+
rails_generators/cucumber/templates/cucumber
|
133
|
+
rails_generators/cucumber/templates/cucumber.rake
|
134
|
+
rails_generators/cucumber/templates/env.rb
|
135
|
+
rails_generators/feature/feature_generator.rb
|
136
|
+
rails_generators/feature/templates/feature.erb
|
137
|
+
rails_generators/feature/templates/steps.erb
|
124
138
|
script/console
|
125
139
|
script/console.cmd
|
126
140
|
script/destroy
|
@@ -138,9 +152,15 @@ spec/cucumber/formatters/ansicolor_spec.rb
|
|
138
152
|
spec/cucumber/formatters/features.html
|
139
153
|
spec/cucumber/formatters/html_formatter_spec.rb
|
140
154
|
spec/cucumber/formatters/pretty_formatter_spec.rb
|
155
|
+
spec/cucumber/formatters/profile_formatter_spec.rb
|
141
156
|
spec/cucumber/formatters/progress_formatter_spec.rb
|
157
|
+
spec/cucumber/model/table_spec.rb
|
158
|
+
spec/cucumber/rails/stubs/mini_rails.rb
|
159
|
+
spec/cucumber/rails/stubs/test_help.rb
|
160
|
+
spec/cucumber/rails/world_spec.rb
|
142
161
|
spec/cucumber/sell_cucumbers.feature
|
143
162
|
spec/cucumber/step_mother_spec.rb
|
163
|
+
spec/cucumber/tree/feature_spec.rb
|
144
164
|
spec/cucumber/tree/scenario_spec.rb
|
145
165
|
spec/cucumber/tree/step_spec.rb
|
146
166
|
spec/cucumber/treetop_parser/empty_feature.feature
|
@@ -148,6 +168,7 @@ spec/cucumber/treetop_parser/empty_scenario.feature
|
|
148
168
|
spec/cucumber/treetop_parser/feature_parser_spec.rb
|
149
169
|
spec/cucumber/treetop_parser/fit_scenario.feature
|
150
170
|
spec/cucumber/treetop_parser/given_scenario.feature
|
171
|
+
spec/cucumber/treetop_parser/multiline_steps.feature
|
151
172
|
spec/cucumber/treetop_parser/multiple_tables.feature
|
152
173
|
spec/cucumber/treetop_parser/spaces.feature
|
153
174
|
spec/cucumber/treetop_parser/test_dos.feature
|
data/README.txt
CHANGED
data/bin/cucumber
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
|
3
3
|
require 'cucumber/cli'
|
4
4
|
Cucumber::CLI.execute
|
@@ -1,6 +1,5 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib') # If you're running off a Cucumber gem you can skip this line
|
2
2
|
require 'cucumber/rake/task'
|
3
3
|
|
4
4
|
Cucumber::Rake::Task.new do |t|
|
5
|
-
t.cucumber_opts = "--profile default"
|
6
5
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec'
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
3
|
+
require 'calculator'
|
4
|
+
|
5
|
+
Before do
|
6
|
+
@calc = Calculator.new
|
7
|
+
end
|
8
|
+
|
9
|
+
After do
|
10
|
+
end
|
11
|
+
|
12
|
+
Given "我已经在计算器里输入$n" do |n|
|
13
|
+
@calc.push n.to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
When /我按(.*)按钮/ do |op|
|
17
|
+
if op == '相加'
|
18
|
+
@result = @calc.send "add"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /我应该在屏幕上看到的结果是(.*)/ do |result|
|
23
|
+
@result.should == result.to_f
|
24
|
+
end
|
@@ -20,6 +20,6 @@ Then /I should remember (\w+) as a friend/ do |name|
|
|
20
20
|
@hello.friend?(name).should == true
|
21
21
|
end
|
22
22
|
|
23
|
-
Then /I should get (\w+)'s phone number/ do |name|
|
23
|
+
Then /I should get (\w+)'s phone number/ do |name| #'
|
24
24
|
@hello.getPhoneNumber(name).should_not == nil
|
25
25
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec'
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
3
|
+
require 'kalkulator'
|
4
|
+
|
5
|
+
Before do
|
6
|
+
@calc = Kalkulator.new
|
7
|
+
end
|
8
|
+
|
9
|
+
After do
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /att jag har knappat in (\d+)/ do |n|
|
13
|
+
@calc.push n.to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
When 'jag summerar' do
|
17
|
+
@result = @calc.add
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /ska resultatet vara (\d+)/ do |result|
|
21
|
+
@result.should == result.to_i
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Egenskap: Summering
|
2
|
+
För att slippa att göra dumma fel
|
3
|
+
Som räknare
|
4
|
+
Vill jag kunna lägga samman
|
5
|
+
|
6
|
+
Scenario: två tal
|
7
|
+
Givet att jag har knappat in 5
|
8
|
+
Och att jag har knappat in 7
|
9
|
+
När jag summerar
|
10
|
+
Så ska resultatet vara 12
|
11
|
+
|
12
|
+
Scenario: tre tal
|
13
|
+
Givet att jag har knappat in 5
|
14
|
+
Och att jag har knappat in 4
|
15
|
+
Och att jag har knappat in 3
|
16
|
+
När jag summerar
|
17
|
+
Så ska resultatet vara 12
|
data/examples/tickets/Rakefile
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
2
|
require 'cucumber/rake/task'
|
3
3
|
|
4
|
-
|
4
|
+
# Try these:
|
5
|
+
#
|
6
|
+
# rake features
|
7
|
+
# rake features PROFILE=html
|
8
|
+
Cucumber::Rake::Task.new do |t|
|
9
|
+
profile = ENV['PROFILE'] || 'default'
|
10
|
+
t.cucumber_opts = "--profile #{profile}"
|
11
|
+
end
|
@@ -15,3 +15,18 @@ end
|
|
15
15
|
Then "nested step should be executed" do
|
16
16
|
@magic.should == 'mushroom'
|
17
17
|
end
|
18
|
+
|
19
|
+
Given /^the following table$/ do |table|
|
20
|
+
@table = table
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^I should be (\w+) in (\w+)$/ do |key, value|
|
24
|
+
hash = @table.hashes[0]
|
25
|
+
hash[key].should == value
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^I shoule see a multiline string like$/ do |s|
|
29
|
+
s.should == %{A string
|
30
|
+
that spans
|
31
|
+
several lines}
|
32
|
+
end
|
@@ -8,4 +8,15 @@ Feature: Cucumber
|
|
8
8
|
|
9
9
|
Scenario: Call step from step
|
10
10
|
Given nested step is called
|
11
|
-
Then nested step should be executed
|
11
|
+
Then nested step should be executed
|
12
|
+
|
13
|
+
Scenario: Reading a table
|
14
|
+
Given the following table
|
15
|
+
| born | working |
|
16
|
+
| Oslo | London |
|
17
|
+
Then I should be working in London
|
18
|
+
And I should be born in Oslo
|
19
|
+
And I shoule see a multiline string like
|
20
|
+
"A string
|
21
|
+
that spans
|
22
|
+
several lines"
|
data/gem_tasks/treetop.rake
CHANGED
@@ -1,37 +1,49 @@
|
|
1
1
|
class FeatureCompiler
|
2
|
-
def
|
2
|
+
def initialize
|
3
3
|
require 'yaml'
|
4
4
|
require 'erb'
|
5
|
-
|
5
|
+
|
6
|
+
@tt = PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'
|
6
7
|
|
7
|
-
template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
|
8
|
-
langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
8
|
+
@template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
|
9
|
+
@langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
|
10
|
+
end
|
11
|
+
|
12
|
+
def compile_all
|
13
|
+
@langs.keys.each do |lang|
|
14
|
+
compile(lang)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def compile(lang)
|
19
|
+
words = @langs['en'].merge(@langs[lang]) # Use English words if languages.yml is missing a word
|
20
|
+
grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
|
21
|
+
ruby_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.rb"
|
22
|
+
grammar = @template.result(binding)
|
23
|
+
File.open(grammar_file, "wb") do |io|
|
24
|
+
io.write(grammar)
|
25
|
+
end
|
26
|
+
sh "#{@tt} #{grammar_file}"
|
27
|
+
FileUtils.rm(grammar_file)
|
28
|
+
|
29
|
+
# Change code so it isn't part of RDoc
|
30
|
+
lines = IO.read(ruby_file).split("\n")
|
31
|
+
lines.each do |line|
|
32
|
+
if line =~ /\s*(def|class|module)/
|
33
|
+
line << " #:nodoc:"
|
26
34
|
end
|
27
|
-
File.open(ruby_file, 'wb'){|io| io.write(lines.join("\n"))}
|
28
35
|
end
|
36
|
+
File.open(ruby_file, 'wb'){|io| io.write(lines.join("\n"))}
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
32
40
|
namespace :treetop do
|
33
41
|
desc 'Compile the grammar for all languages in languages.yml'
|
34
42
|
task :compile do
|
35
|
-
FeatureCompiler.new.
|
43
|
+
FeatureCompiler.new.compile_all
|
44
|
+
end
|
45
|
+
|
46
|
+
task :compile_en do
|
47
|
+
FeatureCompiler.new.compile('en')
|
36
48
|
end
|
37
49
|
end
|