Sha256: 6de595fa39f948b38048178e83ed0416ac769a4adb261f4b86ad6e8c9339c34a

Contents?: true

Size: 1015 Bytes

Versions: 30

Compression:

Stored size: 1015 Bytes

Contents

When /^I update the '(.+)' for '(.+)' to '(.+)'$/ do |attr, doc_name, value|
  doc = instance_variable_get("@#{doc_name}")
  attrs = {attr => value}
  @last_return = doc.update_attributes(attrs)
end

When /^someone else changes the (.+?) '(.+)' of '(.+)' to$/ do |assoc_klass, assoc_name, name, table|
  orig = instance_variable_get("@#{name}")
  doc = orig.class.find_one(orig._id)
  obj = assoc_klass.constantize.new
  table.hashes.each do |hash|
    hash.each do |key, value|
      obj.send("#{key.underscore.gsub(' ', '_')}=", value)
    end
  end
  doc.send("#{assoc_name.underscore.gsub(' ', '_')}=", obj)
  doc.save
end

When /^someone else changes the (.+) of '(.+)':$/ do |assoc_name, name, table|
  orig = instance_variable_get("@#{name}")
  doc = orig.class.find_one(orig._id)
  doc.send(assoc_name).clear
  table.hashes.each do |hash|
    doc.send(assoc_name) << hash.inject({}) do |attrs, (attr, value)|
      attrs["#{attr.underscore.gsub(' ', '_')}"] = value
      attrs
    end
  end
  doc.save
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
mongo_doc-0.6.26 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.25 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.23 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.22 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.21 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.20 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.19 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.18 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.17 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.16 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.15 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.14 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.13 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.12 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.11 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.10 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.9 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.8 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.7 features/step_definitions/partial_update_steps.rb
mongo_doc-0.6.6 features/step_definitions/partial_update_steps.rb