mattscilipoti-model_steps 0.3.1 → 0.3.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -67,6 +67,7 @@ Then /^I should see (?:these|this|the following) (\D+):$/ do |requested_model, t
67
67
 
68
68
  css_class = requested_table.pluralize.underscore
69
69
 
70
+ #TODO: yell if table does not exist
70
71
  html_table = table(tableish("table.#{css_class} tr", 'td,th'))
71
72
 
72
73
  mapped_table.diff!(html_table)
@@ -129,23 +130,22 @@ Given /^(\D+):(.+) has (\D+):(.+)$/ do |requested_model, default_identifier, ass
129
130
  model_under_test = requested_model_with_identifier_to_model_instance(requested_model, default_identifier)
130
131
  associated_model = requested_model_to_model(association_model_name)
131
132
  factory_name = model_to_factory_symbol(associated_model)
132
- associated_model_under_test = associated_model.find(default_identifier) || Factory(factory_name, associated_model.friendly_id_config.column => default_identifier)
133
133
 
134
- possible_associations = [association_model_name.underscore, association_model_name.pluralize.underscore]
135
- association_name = possible_associations.detect {|association_name| model_under_test.respond_to?(association_name)}
134
+ parent = model_under_test.class.name.underscore
136
135
 
137
- if association_name
138
- if association_name.pluralize == association_name
139
- associated_items = model_under_test.send(association_name)
140
- associated_items << associated_model_under_test
141
- else
142
- model_under_test.send(association_name + '=', associated_model_under_test)
143
- end
144
- model_under_test.save!
136
+ parent_association = associated_model.instance_methods.include?(parent.pluralize) ?
137
+ {parent.pluralize => [model_under_test]} :
138
+ {parent => model_under_test}
145
139
 
146
- else
147
- raise "Neither of these associations exist for #{model_under_test.class.name}: #{possible_associations.inspect}"
140
+ begin
141
+ associated_model_under_test = associated_model.find(associated_model_default_identifier)
142
+ associated_model_under_test.update_attributes!(parent_association)
143
+ rescue ActiveRecord::RecordNotFound
144
+ associated_model_params = { associated_model.friendly_id_config.column => associated_model_default_identifier}.merge(parent_association)
145
+ associated_model_under_test = Factory(factory_name, associated_model_params)
148
146
  end
147
+
148
+ model_under_test
149
149
  end
150
150
 
151
151
  Given /^(.+):(.+) (?:has|had) (?:these|this|the following) attributes:$/ do |requested_model, default_identifier, table|
@@ -563,7 +563,7 @@ def create_requested_model_associations(model_under_test, association_quantity,
563
563
  if scope
564
564
  associated_models = associated_models.send(scope)
565
565
  end
566
-
566
+
567
567
  #TODO: smoke test
568
568
  end
569
569
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mattscilipoti-model_steps}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Scilipoti", "Chris Cahoon"]
12
- s.date = %q{2010-08-02}
12
+ s.date = %q{2010-08-05}
13
13
  s.description = %q{Step Definitions for cucumber which support ActiveRecord Models}
14
14
  s.email = %q{matt@scilipoti.name}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mattscilipoti-model_steps
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Scilipoti
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-02 00:00:00 -04:00
19
+ date: 2010-08-05 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency