gherkin 1.0.13-i386-mswin32 → 1.0.14-i386-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -0
- data/VERSION.yml +1 -1
- data/lib/gherkin/i18n.rb +37 -10
- data/spec/gherkin/i18n_spec.rb +18 -0
- metadata +2 -2
data/History.txt
CHANGED
data/VERSION.yml
CHANGED
data/lib/gherkin/i18n.rb
CHANGED
@@ -3,6 +3,8 @@ require 'yaml'
|
|
3
3
|
module Gherkin
|
4
4
|
class I18n
|
5
5
|
KEYWORD_KEYS = %w{name native feature background scenario scenario_outline examples given when then and but}
|
6
|
+
STEP_KEYWORD_KEYS = %w{given when then and but}
|
7
|
+
GWT_KEYWORD_KEYS = %w{given when then}
|
6
8
|
LANGUAGES = YAML.load_file(File.dirname(__FILE__) + '/i18n.yml')
|
7
9
|
|
8
10
|
class << self
|
@@ -122,21 +124,21 @@ module Gherkin
|
|
122
124
|
keywords('examples')
|
123
125
|
end
|
124
126
|
|
125
|
-
def but_keywords
|
126
|
-
keywords('but'
|
127
|
+
def but_keywords
|
128
|
+
keywords('but')
|
127
129
|
end
|
128
130
|
|
129
|
-
def and_keywords
|
130
|
-
keywords('and'
|
131
|
+
def and_keywords
|
132
|
+
keywords('and')
|
131
133
|
end
|
132
134
|
|
133
135
|
# Keywords that can be used in Gherkin source
|
134
136
|
def step_keywords
|
135
|
-
|
137
|
+
STEP_KEYWORD_KEYS.map{|key| keywords(key)}.flatten.uniq
|
136
138
|
end
|
137
139
|
|
138
140
|
def gwt_keywords
|
139
|
-
|
141
|
+
GWT_KEYWORD_KEYS.map{|key| keywords(key)}.flatten.uniq
|
140
142
|
end
|
141
143
|
|
142
144
|
# Keywords that can be used in code
|
@@ -154,15 +156,40 @@ module Gherkin
|
|
154
156
|
@keywords['native']
|
155
157
|
end
|
156
158
|
|
157
|
-
def keywords(key
|
159
|
+
def keywords(key)
|
158
160
|
raise "No #{key} in #{@keywords.inspect}" if @keywords[key].nil?
|
159
|
-
@keywords[key].split('|').map{|
|
161
|
+
@keywords[key].split('|').map{|keyword| keyword_space(key, keyword)}
|
162
|
+
end
|
163
|
+
|
164
|
+
def keyword_table
|
165
|
+
require 'stringio'
|
166
|
+
require 'gherkin/formatter/pretty_formatter'
|
167
|
+
io = StringIO.new
|
168
|
+
pf = Gherkin::Formatter::PrettyFormatter.new(io, true)
|
169
|
+
|
170
|
+
(KEYWORD_KEYS - %w{name native}).each do |key|
|
171
|
+
pf.row([key, keywords(key).map{|keyword| %{"#{keyword}"}}.join(', ')], 0)
|
172
|
+
end
|
173
|
+
%w{given when then}.each do |key|
|
174
|
+
code_keywords = keywords(key).reject{|kw| kw == '* '}.map do |kw|
|
175
|
+
%{"#{self.class.code_keyword_for(kw)}"}
|
176
|
+
end.join(', ')
|
177
|
+
pf.row(["#{key} (code)", code_keywords], 0)
|
178
|
+
end
|
179
|
+
|
180
|
+
pf.flush_table
|
181
|
+
io.rewind
|
182
|
+
io.read
|
160
183
|
end
|
161
184
|
|
162
185
|
private
|
163
186
|
|
164
|
-
def keyword_space(
|
165
|
-
(
|
187
|
+
def keyword_space(key, keyword)
|
188
|
+
if(STEP_KEYWORD_KEYS.index(key))
|
189
|
+
(keyword + ' ').sub(/< $/,'')
|
190
|
+
else
|
191
|
+
keyword
|
192
|
+
end
|
166
193
|
end
|
167
194
|
end
|
168
195
|
end
|
data/spec/gherkin/i18n_spec.rb
CHANGED
@@ -113,6 +113,24 @@ module Gherkin
|
|
113
113
|
| vi | Vietnamese | Tiếng Việt |
|
114
114
|
| zh-CN | Chinese simplified | 简体中文 |
|
115
115
|
| zh-TW | Chinese traditional | 繁體中文 |
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should print keywords for a given language" do
|
120
|
+
("\n" + I18n.get('fr').keyword_table).should == %{
|
121
|
+
| feature | "Fonctionnalité" |
|
122
|
+
| background | "Contexte" |
|
123
|
+
| scenario | "Scénario" |
|
124
|
+
| scenario_outline | "Plan du scénario", "Plan du Scénario" |
|
125
|
+
| examples | "Exemples" |
|
126
|
+
| given | "* ", "Soit ", "Etant donné " |
|
127
|
+
| when | "* ", "Quand ", "Lorsque ", "Lorsqu'" |
|
128
|
+
| then | "* ", "Alors " |
|
129
|
+
| and | "* ", "Et " |
|
130
|
+
| but | "* ", "Mais " |
|
131
|
+
| given (code) | "Soit", "Etantdonné" |
|
132
|
+
| when (code) | "Quand", "Lorsque", "Lorsqu" |
|
133
|
+
| then (code) | "Alors" |
|
116
134
|
}
|
117
135
|
end
|
118
136
|
end
|