gherkin 1.0.13-i386-mingw32 → 1.0.14-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ == 1.0.14 (2010-04-18)
2
+ (Something went wrong when releasing 1.0.13)
3
+
1
4
  == 1.0.13 (2010-04-18)
2
5
 
3
6
  === New Features
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :minor: 0
4
4
  :build:
5
- :patch: 13
5
+ :patch: 14
@@ -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(space=true)
126
- keywords('but', space)
127
+ def but_keywords
128
+ keywords('but')
127
129
  end
128
130
 
129
- def and_keywords(space=true)
130
- keywords('and', space)
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
- %w{given when then and but}.map{|key| keywords(key, true)}.flatten.uniq
137
+ STEP_KEYWORD_KEYS.map{|key| keywords(key)}.flatten.uniq
136
138
  end
137
139
 
138
140
  def gwt_keywords
139
- %w{given when then}.map{|key| keywords(key, true)}.flatten.uniq
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, space=false)
159
+ def keywords(key)
158
160
  raise "No #{key} in #{@keywords.inspect}" if @keywords[key].nil?
159
- @keywords[key].split('|').map{|kw| space ? keyword_space(kw) : kw}
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(val)
165
- (val + ' ').sub(/< $/,'')
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
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 13
9
- version: 1.0.13
8
+ - 14
9
+ version: 1.0.14
10
10
  platform: i386-mingw32
11
11
  authors:
12
12
  - Mike Sassak