Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactorización

  • Loading branch information...
commit fa7d13f93522410faee53015cfe1e77992a40c0a 1 parent 73fdb5a
Fernando García Samblas authored
3  features/lib/exceptions.feature
View
@@ -21,9 +21,6 @@ Feature: MP gives good feedback :through exceptions
|step_implementation |raiser_param |exception |
|given_we_have_a_number_of_instances_called |:model=>'unmapped' |ModelNotMapped |
|given_we_have_the_following_instances_from_step_table|:model=>'unmapped' |ModelNotMapped |
-|given_resource_has_value_in_field |:model=>'unmapped' |ModelNotMapped |
-|given_resource_has_value_in_field |:name=>'U' |NotFoundInHistoryNorDatabase|
-|given_resource_has_value_in_field |:field=>'foo' |FieldNotMapped |
|given_those_resources_have_value_in_field |:model=>'unmapped' |ModelNotMapped |
|given_those_resources_have_value_in_field |:field=>'foo' |FieldNotMapped |
|given_resource_has_many_children |:model=>'unmapped' |ModelNotMapped |
2  lib/mundo_pepino/es_ES/definitions.rb
View
@@ -19,7 +19,7 @@
end
Dado /^que (?:el|la) (.+) ['"](.+)["'] tiene como (.+) ['"](.+)["'](?: \w+)?$/ do |modelo, nombre, campo, valor|
- given_resource_has_value_in_field :model => modelo,
+ given_those_resources_have_value_in_field :model => modelo,
:name => nombre,
:field => campo,
:value => valor
19 lib/mundo_pepino/implementations.rb
View
@@ -22,26 +22,11 @@ def given_we_have_the_following_instances_from_step_table(params)
# Params:
# :model
- # :name
- # :field
- # :value
- def given_resource_has_value_in_field(params)
- if resource = last_mentioned_of(params[:model], params[:name])
- if field = field_for(resource.class, params[:field])
- resource.update_attribute field, real_value_for(params[:value])
- pile_up resource
- else
- raise MundoPepino::FieldNotMapped.new(params[:field])
- end
- end
- end
-
- # Params:
- # :model
# :field
# :value
+ # :name (optional)
def given_those_resources_have_value_in_field(params)
- if res = last_mentioned_of(params[:model])
+ if res = params[:name] ? [last_mentioned_of(params[:model], params[:name])] : last_mentioned_of(params[:model])
resources, field, values = resources_array_field_and_values(res, params[:field], params[:value])
if field
resources.each_with_index do |r, i|
Please sign in to comment.
Something went wrong with that request. Please try again.