mundo-pepino 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.1.4 2009-10-30
2
+ * Added generator mundo_pepino_steps like mundo_pepino but creating a copy
3
+ of the step definitions in features/step_definitions.
4
+ * Regexp fragment declarations wrapped in MundoPepino::Matchers::Bites
5
+
1
6
  == 0.1.3 2009-10-27
2
7
  * path_to method sensitivity: if present, url_mappings are disabled
3
8
  * Configuration as Rails teach me: MundoPepino.configure
data/Manifest.txt CHANGED
@@ -7,10 +7,14 @@ init.rb
7
7
  lib/mundo_pepino.rb
8
8
  lib/mundo_pepino/base.rb
9
9
  lib/mundo_pepino/config.rb
10
- lib/mundo_pepino/definitions/en_US.rb
11
- lib/mundo_pepino/definitions/es_ES.rb
12
10
  lib/mundo_pepino/en_US.rb
11
+ lib/mundo_pepino/en_US/definitions.rb
12
+ lib/mundo_pepino/en_US/mappings.rb
13
+ lib/mundo_pepino/en_US/matchers.rb
13
14
  lib/mundo_pepino/es_ES.rb
15
+ lib/mundo_pepino/es_ES/definitions.rb
16
+ lib/mundo_pepino/es_ES/mappings.rb
17
+ lib/mundo_pepino/es_ES/matchers.rb
14
18
  lib/mundo_pepino/implementations.rb
15
19
  lib/mundo_pepino/implementations_api.rb
16
20
  lib/mundo_pepino/resources_history.rb
@@ -23,3 +27,7 @@ rails_generators/mundo_pepino/USAGE
23
27
  rails_generators/mundo_pepino/mundo_pepino_generator.rb
24
28
  rails_generators/mundo_pepino/templates/mundo_pepino.rake
25
29
  rails_generators/mundo_pepino/templates/mundo_pepino_es_ES.rb
30
+ rails_generators/mundo_pepino_steps/USAGE
31
+ rails_generators/mundo_pepino_steps/mundo_pepino_steps_generator.rb
32
+ rails_generators/mundo_pepino_steps/templates/mundo_pepino.rake
33
+ rails_generators/mundo_pepino_steps/templates/mundo_pepino_es_ES.rb
data/README_es.markdown CHANGED
@@ -40,9 +40,11 @@ En este punto deberíamos obtener dos errores, ambos debidos a que el *scaffold*
40
40
 
41
41
  Ahora sí, los escenarios deberían ser válidos, sin errores ni definiciones pendientes.
42
42
 
43
+ El generador mundo_pepino nos prepara el entorno para utilizar las definiciones de MundoPepino sin copiarnos las mismas en ''features/steps_definitions'', cargándolas directemente desde su código. Existe otro generador equivalente llamado **mundo_pepino_steps** que hace lo mismo pero copiando dichas definiciones dentro de ''features/steps_definitions''.
44
+
43
45
  La intención del generador de características es más didáctica que pragmática. Ofrece un ejemplo simple que podemos toquetear para probar el plugin. Por otro lado se limita a hacer exactamente lo mismo que hace `generate feature` exceptuando el hecho de que no genera un fichero de **definiciones específicas** para la nueva *caracteristica* (ya que las utilizadas están comprendidas dentro de las **definiciones genéricas** ya implementadas en MundoPepino).
44
46
 
45
- Dentro del plugin, en `features/support/app` está la aplicación que el MundoPepino utiliza para probarse a si mismo. En particular la característica `features/mundo-pepino.feature` pretente ser un compendio de escenarios que muestren las posibilidades que ofrece.
47
+ Dentro del código de MundoPepino, en `features/support/app` está la aplicación que el MundoPepino utiliza para probarse a si mismo. En particular la característica `features/mundo-pepino.feature` pretente ser un compendio de escenarios que muestren las posibilidades que ofrece.
46
48
 
47
49
  ## Instalación
48
50
 
@@ -0,0 +1,9 @@
1
+ # MundoPepino's step definitions in en_US
2
+ # Simple creation w/ optional name/s
3
+ Given /^(?:that we have )?(#{_number_}) (?!.+ #{_which_})(.+?)(?: (?:called )?['"](.+)["'])?$/i do |number, model, name|
4
+ given_we_have_a_number_of_instances_called number, model, name
5
+ end
6
+
7
+ Then /^we have (#{_number_}) ([^ ]+)(?: (?:called )?['"](.+)["'])? in our database$/ do |number, model, names|
8
+ then_we_have_a_number_of_instances_in_our_database number, model, names
9
+ end
@@ -1,4 +1,3 @@
1
- # MundoPepino's step definitions in en_US
2
1
  module MundoPepino
3
2
  class << self
4
3
  def language_specific_mappings
@@ -19,7 +18,13 @@ module MundoPepino
19
18
  /^four$/i => 4,
20
19
  /^fourth$/i => 4,
21
20
  /^five$/i => 5,
22
- /^fifth$/i => 5}) { |string| string.to_i }
21
+ /^fifth$/i => 5,
22
+ /^six$/i => 6,
23
+ /^seven$/i => 7,
24
+ /^eight$/i => 8,
25
+ /^nine$/i => 9,
26
+ /^ten$/i => 10
27
+ }) { |string| string.to_i }
23
28
  String.add_mapper(:crud_action,
24
29
  /^creation$/i => 'new',
25
30
  /^changes?$/i => 'edit',
@@ -32,14 +37,3 @@ module MundoPepino
32
37
  end
33
38
  end
34
39
  end
35
-
36
- match_number = 'a|an|one|two|three|four|five|six|seven|eight|nine|ten|\d+'
37
- which = '(?:which|that have as)'
38
- # Simple creation w/ optional name/s
39
- Given /^(?:that we have )?(#{match_number}) (?!.+ #{which})(.+?)(?: (?:called )?['"](.+)["'])?$/i do |number, model, name|
40
- given_we_have_a_number_of_instances_called number, model, name
41
- end
42
-
43
- Then /^we have (#{match_number}) ([^ ]+)(?: (?:called )?['"](.+)["'])? in our database$/ do |number, model, names|
44
- then_we_have_a_number_of_instances_in_our_database number, model, names
45
- end
@@ -0,0 +1,19 @@
1
+ module MundoPepino
2
+ module Matchers
3
+ class Bites
4
+ class << self
5
+ def _number_
6
+ 'a|an|one|two|three|four|five|six|seven|eight|nine|ten|\d+'
7
+ end
8
+ def _which_
9
+ '(?:which|that have as)'
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ class << self
17
+ delegate :_number_, :_which_, :to => 'MundoPepino::Matchers::Bites'
18
+ end
19
+
@@ -1,2 +1,4 @@
1
1
  require 'mundo_pepino'
2
- require 'mundo_pepino/definitions/en_US'
2
+ require 'mundo_pepino/en_US/mappings'
3
+ require 'mundo_pepino/en_US/matchers'
4
+ require 'mundo_pepino/en_US/definitions'
@@ -1,60 +1,11 @@
1
1
  # MundoPepino's step definitions in es_ES
2
- module MundoPepino
3
- class << self
4
- def language_specific_mappings
5
- String.add_mapper(:real_value, {
6
- /^verdader[oa]$/i => true,
7
- /^fals[ao]$/i => false
8
- }) { |value| value }
9
- String.add_mapper(:field) { |str| :name if str =~ /nombres?/ }
10
-
11
- String.add_mapper(:number, {
12
- /^un[oa]?$/i => 1,
13
- /^primer[oa]?$/i => 1,
14
- :dos => 2,
15
- /^segund[oa]?$/i => 2,
16
- :tres => 3,
17
- /^tercer[ao]/i => 3,
18
- :cuatro => 4,
19
- /^cuart[ao]/i => 4,
20
- :cinco => 5,
21
- /^quint[ao]/i => 5}) { |string| string.to_i }
22
- String.add_mapper(:crud_action,
23
- /^alta$/i => 'new',
24
- /^creaci[óo]n$/i => 'new',
25
- /^nuev(?:o|a|o\/a|a\/o)$/i => 'new',
26
- /^cambio$/i => 'edit',
27
- /^modificaci[oó]n(?:es)?$/i => 'edit',
28
- /^edici[oó]n$/i => 'edit')
29
- String.add_mapper(:month,
30
- :enero => 'January',
31
- :febrero => 'February',
32
- :marzo => 'March',
33
- :abril => 'April',
34
- :mayo => 'May',
35
- :junio => 'June',
36
- :julio => 'July',
37
- :agosto => 'August',
38
- /^sep?tiembre$/i => 'September',
39
- :octubre => 'October',
40
- :noviembre => 'November',
41
- :diciembre => 'December')
42
- unless self.world.respond_to? :path_to
43
- String.url_mappings[/^la (?:portada|home\s?(?:page)?)/i] = self.world.root_path
44
- end
45
-
46
- end
47
- end
48
- end
49
-
50
- nro = 'un|una|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|\d+'
51
- cuyo = '(?:cuy[oa]s?|que tienen? como)'
52
2
  # Creación simple con nombre opcional
53
- Dado /^(?:que tenemos )?(#{nro}) (?!.+ #{cuyo})(.+?)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/i do |numero, modelo, nombre|
3
+ Dado /^(?:que tenemos )?(#{_numero_}) (?!.+ #{_cuyo_})(.+?)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/i do |numero, modelo, nombre|
54
4
  given_we_have_a_number_of_instances_called numero, modelo, nombre
55
5
  end
6
+
56
7
  # Creación con asignación de valor en campo
57
- Dado /^(?:que tenemos )?(#{nro}) (.+) #{cuyo} (.+?) (?:(?:es|son) (?:de )?)?['"](.+)["'](?: .+)?$/i do |numero, modelo, campo, valor|
8
+ Dado /^(?:que tenemos )?(#{_numero_}) (.+) #{_cuyo_} (.+?) (?:(?:es|son) (?:de )?)?['"](.+)["'](?: .+)?$/i do |numero, modelo, campo, valor|
58
9
  Dado "que tenemos #{numero} #{modelo}"
59
10
  Dado "que dichos #{modelo} tienen como #{campo} '#{valor}'"
60
11
  end
@@ -89,7 +40,7 @@ Dado /^que dich[oa]s? (.+) tienen? como (.+) ['"](.+)["'](?:.+)?$/i do |modelo,
89
40
  end
90
41
  end
91
42
 
92
- Dado /^que (?:el|la) (.+) ['"](.+)["'] tiene (#{nro}) (.+?)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/i do |modelo_padre, nombre_del_padre, numero, modelo_hijos, nombres|
43
+ Dado /^que (?:el|la) (.+) ['"](.+)["'] tiene (#{_numero_}) (.+?)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/i do |modelo_padre, nombre_del_padre, numero, modelo_hijos, nombres|
93
44
  given_resource_has_many_children(
94
45
  :resource_model => modelo_padre,
95
46
  :resource_name => nombre_del_padre,
@@ -98,7 +49,7 @@ Dado /^que (?:el|la) (.+) ['"](.+)["'] tiene (#{nro}) (.+?)(?: (?:llamad[oa]s? )
98
49
  :children_names => nombres)
99
50
  end
100
51
 
101
- Dado /^que dich[oa]s? (.+) tienen? (#{nro}) (.+?)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/i do |modelo_padre, numero, modelo_hijos, nombres|
52
+ Dado /^que dich[oa]s? (.+) tienen? (#{_numero_}) (.+?)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/i do |modelo_padre, numero, modelo_hijos, nombres|
102
53
  given_resource_has_many_children(
103
54
  :resource_model => modelo_padre,
104
55
  :number_of_children => numero,
@@ -124,8 +75,7 @@ end
124
75
 
125
76
  ###############################################################################
126
77
 
127
- pagina_re = '(?:p[áa]gina|portada|[íi]ndice|listado|colecci[óo]n)'
128
- Cuando /^(?:que )?visito (?:el|la) #{pagina_re} de ([\w]+|['"][\w ]+["'])$/i do |modelo_en_crudo|
78
+ Cuando /^(?:que )?visito (?:el|la) #{_pagina_} de ([\w]+|['"][\w ]+["'])$/i do |modelo_en_crudo|
129
79
  modelo = modelo_en_crudo.to_unquoted
130
80
  if model = modelo.to_model
131
81
  pile_up model.new
@@ -137,9 +87,9 @@ Cuando /^(?:que )?visito (?:el|la) #{pagina_re} de ([\w]+|['"][\w ]+["'])$/i do
137
87
  end
138
88
  end
139
89
 
140
- Cuando /^(?:que )?visito (?:el|la) #{pagina_re} (?:del|de la) (.+) ['"](.+)["']$/i do |modelo, nombre|
90
+ Cuando /^(?:que )?visito (?:el|la) #{_pagina_} (?:del|de la) (.+) ['"](.+)["']$/i do |modelo, nombre|
141
91
  if resource = last_mentioned_of(modelo, nombre)
142
- do_visit eval("#{resource.class.name.underscore}_path(resource)")
92
+ do_visit send("#{resource.class.name.underscore}_path", resource)
143
93
  else
144
94
  raise MundoPepino::ResourceNotFound.new("model #{modelo}, name #{nombre}")
145
95
  end
@@ -155,14 +105,14 @@ Cuando /^(?:que )?visito la p[áa]gina de (?!la)([\w\/]+) (?:de |de la |del )?(.
155
105
  last_mentioned_called(nombre.to_unquoted)
156
106
  end
157
107
  if resource
158
- do_visit eval("#{action}_#{resource.mr_singular}_path(resource)")
108
+ do_visit send("#{action}_#{resource.mr_singular}_path", resource)
159
109
  else
160
110
  MundoPepino::ResourceNotFound.new("model #{modelo}, name #{nombre}")
161
111
  end
162
112
  else
163
113
  model = modelo.to_unquoted.to_model or raise(MundoPepino::ModelNotMapped.new(modelo))
164
114
  pile_up model.new
165
- do_visit eval("#{action}_#{model.name.underscore}_path")
115
+ do_visit send("#{action}_#{model.name.underscore}_path")
166
116
  end
167
117
  end
168
118
 
@@ -170,8 +120,7 @@ Cuando /^(?:que )?visito su (?:p[áa]gina|portada)$/i do
170
120
  do_visit last_mentioned_url
171
121
  end
172
122
 
173
- negative_lookahead = '(?:la|el) \w+ del? |su p[aá]gina|su portada'
174
- Cuando /^(?:que )?visito (?!#{negative_lookahead})(.+)$/i do |pagina|
123
+ Cuando /^(?:que )?visito (?!#{_pagina_desde_rutas_})(.+)$/i do |pagina|
175
124
  do_visit pagina.to_unquoted.to_url
176
125
  end
177
126
 
@@ -257,14 +206,11 @@ Cuando /^borro (?:el|la|el\/la) (.+) en (?:la )?(\w+|\d+)(?:ª|º)? posición$/
257
206
  end
258
207
 
259
208
  #############################################################################
260
- veo_o_no = '(?:no )?(?:veo|debo ver|deber[ií]a ver)'
261
-
262
- Entonces /^(#{veo_o_no}) el texto (.+)?$/i do |should, text|
209
+ Entonces /^(#{_veo_o_no_}) el texto (.+)?$/i do |should, text|
263
210
  eval('response.body.send(shouldify(should))') =~ /#{Regexp.escape(text.to_unquoted.to_translated)}/m
264
211
  end
265
212
 
266
- leo_o_no = '(?:no )?(?:leo|debo leer|deber[íi]a leer)'
267
- Entonces /^(#{leo_o_no}) el texto (.+)?$/i do |should, text|
213
+ Entonces /^(#{_leo_o_no_}) el texto (.+)?$/i do |should, text|
268
214
  begin
269
215
  HTML::FullSanitizer.new.sanitize(response.body).send(shouldify(should)) =~ /#{Regexp.escape(text.to_unquoted.to_translated)}/m
270
216
  rescue Spec::Expectations::ExpectationNotMetError
@@ -273,19 +219,19 @@ Entonces /^(#{leo_o_no}) el texto (.+)?$/i do |should, text|
273
219
  end
274
220
  end
275
221
 
276
- Entonces /^(#{veo_o_no}) los siguientes textos:$/i do |should, texts|
222
+ Entonces /^(#{_veo_o_no_}) los siguientes textos:$/i do |should, texts|
277
223
  texts.raw.each do |row|
278
224
  Entonces "#{should} el texto #{row[0]}"
279
225
  end
280
226
  end
281
227
 
282
- Entonces /^(#{leo_o_no}) los siguientes textos:$/i do |should, texts|
228
+ Entonces /^(#{_leo_o_no_}) los siguientes textos:$/i do |should, texts|
283
229
  texts.raw.each do |row|
284
230
  Entonces "#{should} el texto #{row[0]}"
285
231
  end
286
232
  end
287
233
 
288
- Entonces /^(#{veo_o_no}) (?:en )?(?:el selector|la etiqueta|el tag) (["'].+?['"]|[^ ]+)(?:(?: con)? el (?:valor|texto) )?["']?([^"']+)?["']?$/ do |should, tag, value |
234
+ Entonces /^(#{_veo_o_no_}) (?:en )?(?:el selector|la etiqueta|el tag) (["'].+?['"]|[^ ]+)(?:(?: con)? el (?:valor|texto) )?["']?([^"']+)?["']?$/ do |should, tag, value |
289
235
  lambda {
290
236
  if value
291
237
  response.should have_tag(tag.to_unquoted, /.*#{value.to_translated}.*/i)
@@ -295,7 +241,7 @@ Entonces /^(#{veo_o_no}) (?:en )?(?:el selector|la etiqueta|el tag) (["'].+?['"]
295
241
  }.send(not_shouldify(should), raise_error)
296
242
  end
297
243
 
298
- Entonces /^(#{veo_o_no}) (?:las|los) siguientes (?:etiquetas|selectores):$/i do |should, texts|
244
+ Entonces /^(#{_veo_o_no_}) (?:las|los) siguientes (?:etiquetas|selectores):$/i do |should, texts|
299
245
  check_contents, from_index = texts.raw[0].size == 2 ? [true, 1] : [false, 0]
300
246
  texts.raw[from_index..-1].each do |row|
301
247
  if check_contents
@@ -306,7 +252,7 @@ Entonces /^(#{veo_o_no}) (?:las|los) siguientes (?:etiquetas|selectores):$/i do
306
252
  end
307
253
  end
308
254
 
309
- Entonces /^(#{veo_o_no}) un enlace (?:al?|para) (.+)?$/i do |should, pagina|
255
+ Entonces /^(#{_veo_o_no_}) un enlace (?:al?|para) (.+)?$/i do |should, pagina|
310
256
  lambda {
311
257
  href = relative_page(pagina) || pagina.to_unquoted.to_url
312
258
  response.should have_tag('a[href=?]', href)
@@ -314,11 +260,11 @@ Entonces /^(#{veo_o_no}) un enlace (?:al?|para) (.+)?$/i do |should, pagina|
314
260
  end
315
261
 
316
262
 
317
- Entonces /^(#{veo_o_no}) marcad[ao] (?:la casilla|el checkbox)? ?(.+)$/ do |should, campo|
263
+ Entonces /^(#{_veo_o_no_}) marcad[ao] (?:la casilla|el checkbox)? ?(.+)$/ do |should, campo|
318
264
  field_labeled(campo.to_unquoted).send shouldify(should), be_checked
319
265
  end
320
266
 
321
- Entonces /^(#{veo_o_no}) (?:una|la) tabla (?:(["'].+?['"]|[^ ]+) )?con (?:el|los) (?:siguientes? )?(?:valore?s?|contenidos?):$/ do |should, table_id, valores|
267
+ Entonces /^(#{_veo_o_no_}) (?:una|la) tabla (?:(["'].+?['"]|[^ ]+) )?con (?:el|los) (?:siguientes? )?(?:valore?s?|contenidos?):$/ do |should, table_id, valores|
322
268
  table_id = "##{table_id.to_unquoted}" if table_id
323
269
  shouldified = shouldify(should)
324
270
  response.send shouldified, have_selector("table#{table_id}")
@@ -341,7 +287,7 @@ Entonces /^(#{veo_o_no}) (?:una|la) tabla (?:(["'].+?['"]|[^ ]+) )?con (?:el|los
341
287
  end
342
288
  end
343
289
 
344
- Entonces /^(#{veo_o_no}) un formulario con (?:el|los) (?:siguientes? )?(?:campos?|elementos?):$/ do |should, elementos|
290
+ Entonces /^(#{_veo_o_no_}) un formulario con (?:el|los) (?:siguientes? )?(?:campos?|elementos?):$/ do |should, elementos|
345
291
  shouldified = shouldify(should)
346
292
  response.send(shouldified, have_tag('form')) do
347
293
  elementos.raw[1..-1].each do |row|
@@ -364,26 +310,24 @@ Entonces /^(#{veo_o_no}) un formulario con (?:el|los) (?:siguientes? )?(?:campos
364
310
  end
365
311
 
366
312
  #BBDD
367
- en_bbdd_tenemos = '(?:en (?:la )?(?:bb?dd?|base de datos) tenemos|tenemos en (?:la )?(?:bb?dd?|base de datos))'
368
- tiene_en_bbdd = '(?:tiene en (?:la )?bbdd|en (?:la )?bbdd tiene|tiene en (?:la )?base de datos|en (?:la )?base de datos tiene)'
369
- Entonces /^#{en_bbdd_tenemos} (#{nro}) ([^ ]+)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/ do |numero, modelo, nombre|
313
+ Entonces /^#{_tenemos_en_bbdd_} (#{_numero_}) ([^ ]+)(?: (?:llamad[oa]s? )?['"](.+)["'])?$/ do |numero, modelo, nombre|
370
314
  then_we_have_a_number_of_instances_in_our_database numero, modelo, nombre
371
315
  end
372
316
 
373
- Entonces /^(?:el|la) (.+) "(.+)" #{tiene_en_bbdd} como (.+) "(.+)"(?: \w+)?$/ do |modelo, nombre, campo, valor|
317
+ Entonces /^(?:el|la) (.+) "(.+)" #{_tiene_en_bbdd_} como (.+) "(.+)"(?: \w+)?$/ do |modelo, nombre, campo, valor|
374
318
  add_resource_from_database(modelo, nombre)
375
319
  last_mentioned_should_have_value(campo, valor.to_real_value)
376
320
  end
377
321
 
378
- Entonces /^#{tiene_en_bbdd} como (.+) "(.+)"(?: \w+)?$/ do |campo, valor|
322
+ Entonces /^#{_tiene_en_bbdd_} como (.+) "(.+)"(?: \w+)?$/ do |campo, valor|
379
323
  last_mentioned_should_have_value(campo, valor.to_real_value)
380
324
  end
381
325
 
382
- Entonces /^(?:el|la) (.+) "(.+)" #{tiene_en_bbdd} una? (.+) "(.+)"$/ do |padre, nombre_del_padre, hijo, nombre_del_hijo|
326
+ Entonces /^(?:el|la) (.+) "(.+)" #{_tiene_en_bbdd_} una? (.+) "(.+)"$/ do |padre, nombre_del_padre, hijo, nombre_del_hijo|
383
327
  add_resource_from_database(padre, nombre_del_padre)
384
328
  last_mentioned_should_have_child(hijo, nombre_del_hijo)
385
329
  end
386
330
 
387
- Entonces /^#{tiene_en_bbdd} una? (.+) "(.+)"$/ do |hijo, nombre_del_hijo|
331
+ Entonces /^#{_tiene_en_bbdd_} una? (.+) "(.+)"$/ do |hijo, nombre_del_hijo|
388
332
  last_mentioned_should_have_child(hijo, nombre_del_hijo)
389
333
  end
@@ -0,0 +1,53 @@
1
+ module MundoPepino
2
+ class << self
3
+ def language_specific_mappings
4
+ String.add_mapper(:real_value, {
5
+ /^verdader[oa]$/i => true,
6
+ /^fals[ao]$/i => false
7
+ }) { |value| value }
8
+ String.add_mapper(:field) { |str| :name if str =~ /nombres?/ }
9
+
10
+ String.add_mapper(:number, {
11
+ /^un[oa]?$/i => 1,
12
+ /^primer[oa]?$/i => 1,
13
+ :dos => 2,
14
+ /^segund[oa]?$/i => 2,
15
+ :tres => 3,
16
+ /^tercer[ao]/i => 3,
17
+ :cuatro => 4,
18
+ /^cuart[ao]/i => 4,
19
+ :cinco => 5,
20
+ /^quint[ao]/i => 5,
21
+ :seis => 6,
22
+ :siete => 7,
23
+ :ocho => 8,
24
+ :nueve => 9,
25
+ :diez => 10
26
+ }) { |string| string.to_i }
27
+ String.add_mapper(:crud_action,
28
+ /^alta$/i => 'new',
29
+ /^creaci[óo]n$/i => 'new',
30
+ /^nuev(?:o|a|o\/a|a\/o)$/i => 'new',
31
+ /^cambio$/i => 'edit',
32
+ /^modificaci[oó]n(?:es)?$/i => 'edit',
33
+ /^edici[oó]n$/i => 'edit')
34
+ String.add_mapper(:month,
35
+ :enero => 'January',
36
+ :febrero => 'February',
37
+ :marzo => 'March',
38
+ :abril => 'April',
39
+ :mayo => 'May',
40
+ :junio => 'June',
41
+ :julio => 'July',
42
+ :agosto => 'August',
43
+ /^sep?tiembre$/i => 'September',
44
+ :octubre => 'October',
45
+ :noviembre => 'November',
46
+ :diciembre => 'December')
47
+ unless self.world.respond_to? :path_to
48
+ String.url_mappings[/^la (?:portada|home\s?(?:page)?)/i] = self.world.root_path
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,38 @@
1
+ module MundoPepino
2
+ module Matchers
3
+ class Bites
4
+ class << self
5
+ def _numero_
6
+ 'un|una|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|\d+'
7
+ end
8
+ def _cuyo_
9
+ '(?:cuy[oa]s?|que tienen? como)'
10
+ end
11
+ def _pagina_
12
+ '(?:p[áa]gina|portada|[íi]ndice|listado|colecci[óo]n)'
13
+ end
14
+ def _pagina_desde_rutas_ # páginas obtenida a partir de las rutas
15
+ '(?:la|el) \w+ del? |su p[aá]gina|su portada'
16
+ end
17
+ def _veo_o_no_
18
+ '(?:no )?(?:veo|debo ver|deber[ií]a ver)'
19
+ end
20
+ def _leo_o_no_
21
+ '(?:no )?(?:leo|debo leer|deber[íi]a leer)'
22
+ end
23
+ def _tenemos_en_bbdd_
24
+ '(?:en (?:la )?(?:bb?dd?|base de datos) tenemos|tenemos en (?:la )?(?:bb?dd?|base de datos))'
25
+ end
26
+ def _tiene_en_bbdd_
27
+ '(?:tiene en (?:la )?bbdd|en (?:la )?bbdd tiene|tiene en (?:la )?base de datos|en (?:la )?base de datos tiene)'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ class << self
35
+ delegate :_numero_, :_cuyo_, :_pagina_, :_pagina_desde_rutas_,
36
+ :_veo_o_no_, :_leo_o_no_, :_tenemos_en_bbdd_, :_tiene_en_bbdd_,
37
+ :to => 'MundoPepino::Matchers::Bites'
38
+ end
@@ -1,2 +1,4 @@
1
1
  require 'mundo_pepino'
2
- require 'mundo_pepino/definitions/es_ES'
2
+ require 'mundo_pepino/es_ES/mappings'
3
+ require 'mundo_pepino/es_ES/matchers'
4
+ require 'mundo_pepino/es_ES/definitions'
@@ -2,7 +2,7 @@ module MundoPepino #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 3
5
+ TINY = 4
6
6
  PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
data/lib/mundo_pepino.rb CHANGED
@@ -11,6 +11,8 @@ require 'mundo_pepino/config'
11
11
 
12
12
  require 'string-mapper'
13
13
 
14
+ World(MundoPepino)
15
+
14
16
  module MundoPepino
15
17
  include Base
16
18
  include ImplementationsApi
@@ -1,6 +1,8 @@
1
1
  # Este generador crea una plantilla de caracteristica (feature) ligada a un modelo
2
2
  module Rails::Generator::Commands
3
- MUNDO_PEPINO_ENV = 'features/step_definitions/mundo_pepino_es_ES.rb'
3
+ CLONED_STEPS_ENV = 'features/support/mundo_pepino_es_ES.rb'
4
+ SHARED_STEPS_ENV = 'features/step_definitions/mundo_pepino_es_ES.rb'
5
+ MUNDO_PEPINO_ENV = File.file?(CLONED_STEPS_ENV) ? CLONED_STEPS_ENV : SHARED_STEPS_ENV
4
6
 
5
7
  MODEL_CLEANING = '"\n # ENTRADA AUTO-GENERADA PARA #{model}\n' +
6
8
  ' #{model}, # ' +
@@ -3,7 +3,7 @@ Description:
3
3
  features in Spanish. After running this generator you will get a new
4
4
  rake task called "caracteristicas".
5
5
 
6
- This also generates the necessary files in the "caracteristicas"
6
+ This also generates the necessary files in the "features"
7
7
  directory.
8
8
 
9
9
  Also see the caracteristica generator, which you can use to generate
@@ -1,9 +1,5 @@
1
1
  require 'mundo_pepino/es_ES'
2
2
 
3
- Webrat.configure do |config|
4
- config.mode = :rails
5
- end
6
-
7
3
  MundoPepino.configure do |config|
8
4
  config.models_to_clean = [
9
5
  # MODELOS PARA LIMPIAR antes de cada escenario,
@@ -44,5 +40,3 @@ end
44
40
  # require 'factory_girl'
45
41
  # #Definición de las factorias equivalente a example_data.rb en fixture_replacement
46
42
  # require File.expand_path(File.dirname(__FILE__) + '/app/db/factories')
47
-
48
- World(MundoPepino)
@@ -0,0 +1,13 @@
1
+ Description:
2
+ Sets up MundoPepino in your Rails project in order to start writing
3
+ features in Spanish. After running this generator you will get a new
4
+ rake task called "caracteristicas".
5
+
6
+ This also generates the necessary files in the "features"
7
+ directory included copy of the step definitions.
8
+
9
+ Also see the caracteristica generator, which you can use to generate
10
+ skeletons for new features in Spanish.
11
+
12
+ Examples:
13
+ `./script/generate mundo_pepino`
@@ -0,0 +1,24 @@
1
+ require 'rbconfig'
2
+
3
+ # This generator bootstraps a Rails project for use with MundoPepino,
4
+ # an implemented set of Cucumber step definitions written in Spanish.
5
+ class MundoPepinoStepsGenerator < Rails::Generator::Base
6
+ def manifest
7
+ record do |m|
8
+ m.directory 'features/support'
9
+ m.file 'mundo_pepino_es_ES.rb', 'features/support/mundo_pepino_es_ES.rb'
10
+
11
+ m.directory 'features/step_definitions'
12
+ m.file '../../../lib/mundo_pepino/es_ES/definitions.rb', 'features/step_definitions/mundo_pepino_steps_es_ES.rb'
13
+
14
+ m.directory 'lib/tasks'
15
+ m.file 'mundo_pepino.rake', 'lib/tasks/mundo_pepino.rake'
16
+ end
17
+ end
18
+
19
+ protected
20
+
21
+ def banner
22
+ "Usage: #{$0} mundo_pepino_steps"
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ $:.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new(:caracteristicas) do |t|
5
+ t.cucumber_opts = "--format pretty --language es features"
6
+ end
7
+ task :caracteristicas => 'db:test:prepare'
@@ -0,0 +1,44 @@
1
+ require 'mundo_pepino'
2
+ require 'mundo_pepino/es_ES/matchers'
3
+ require 'mundo_pepino/es_ES/mappings'
4
+
5
+ MundoPepino.configure do |config|
6
+ config.models_to_clean = [
7
+ # MODELOS PARA LIMPIAR antes de cada escenario,
8
+ # por ejemplo:
9
+ # Orchard, Terrace, Crop...
10
+ ]
11
+
12
+ config.model_mappings = {
13
+ # TRADUCCIÓN DE MODELOS AQUÍ, por ejemplo:
14
+ # /^huert[oa]s?/i => Orchard,
15
+ # /^bancal(es)?$/i => Terrace,
16
+ # /^cultivos?$/i => Crop...
17
+ }
18
+
19
+ config.field_mappings = {
20
+ # TRADUCCIÓN DE CAMPOS AQUÍ:
21
+ # /^[Ááa]reas?$/i => 'area',
22
+ # /^color(es)?$/i => 'color',
23
+ # /^latitud(es)?$/i => 'latitude',
24
+ # /^longitud(es)?/i => 'length'
25
+ #
26
+ # TRADUCCIÓN ESPECÍFICA PARA UN MODELO
27
+ # /^Orchard::longitud(es)?$/ => 'longitude'
28
+ }
29
+ end
30
+
31
+ Before do
32
+ MundoPepino.clean_models
33
+ end
34
+
35
+ #module MundoPepino
36
+ # # Helpers específicos de nuestras features que necesiten estar
37
+ # # "incluidos" (no extendidos), por ejemplo:
38
+ # include FixtureReplacement # probado!
39
+ # include Machinist # probado!
40
+ #end
41
+ # # Si utilizas factory_girl # probado!
42
+ # require 'factory_girl'
43
+ # #Definición de las factorias equivalente a example_data.rb en fixture_replacement
44
+ # require File.expand_path(File.dirname(__FILE__) + '/app/db/factories')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mundo-pepino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fernando Garc\xC3\xADa Samblas"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-27 00:00:00 +01:00
12
+ date: 2009-10-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -102,10 +102,14 @@ files:
102
102
  - lib/mundo_pepino.rb
103
103
  - lib/mundo_pepino/base.rb
104
104
  - lib/mundo_pepino/config.rb
105
- - lib/mundo_pepino/definitions/en_US.rb
106
- - lib/mundo_pepino/definitions/es_ES.rb
107
105
  - lib/mundo_pepino/en_US.rb
106
+ - lib/mundo_pepino/en_US/definitions.rb
107
+ - lib/mundo_pepino/en_US/mappings.rb
108
+ - lib/mundo_pepino/en_US/matchers.rb
108
109
  - lib/mundo_pepino/es_ES.rb
110
+ - lib/mundo_pepino/es_ES/definitions.rb
111
+ - lib/mundo_pepino/es_ES/mappings.rb
112
+ - lib/mundo_pepino/es_ES/matchers.rb
109
113
  - lib/mundo_pepino/implementations.rb
110
114
  - lib/mundo_pepino/implementations_api.rb
111
115
  - lib/mundo_pepino/resources_history.rb
@@ -118,6 +122,10 @@ files:
118
122
  - rails_generators/mundo_pepino/mundo_pepino_generator.rb
119
123
  - rails_generators/mundo_pepino/templates/mundo_pepino.rake
120
124
  - rails_generators/mundo_pepino/templates/mundo_pepino_es_ES.rb
125
+ - rails_generators/mundo_pepino_steps/USAGE
126
+ - rails_generators/mundo_pepino_steps/mundo_pepino_steps_generator.rb
127
+ - rails_generators/mundo_pepino_steps/templates/mundo_pepino.rake
128
+ - rails_generators/mundo_pepino_steps/templates/mundo_pepino_es_ES.rb
121
129
  has_rdoc: true
122
130
  homepage: http://github.com/nando/mundo-pepino
123
131
  licenses: []