Sha256: aa4355644a9a96ec4d5d99ebf8bb0665f19faed49520fbe1caaf11f92b811c8e

Contents?: true

Size: 1.38 KB

Versions: 42

Compression:

Stored size: 1.38 KB

Contents

Given /^an object '(.*)'$/ do |name|
  @movie = Movie.new
  @movie.title = 'Gone with the Wind'
  @movie.director = 'Victor Fleming'
  @movie.writers = ['Sidney Howard']
  @director = Director.new
  @director.name = 'Victor Fleming'
  @award = AcademyAward.new
  @award.year = '1940'
  @award.category = 'Best Director'
  @director.awards = [@award]
  @movie.director = @director
end

Given /^a hash named '(.*)':$/ do |name, table|
  @all = []
  table.hashes.each do |hash|
    @last = hash.inject({}) do |h, (key, value)|
      h["#{key.underscore.gsub(' ', '_')}"] = value
      h
    end
    @all << @last
  end
  instance_variable_set("@#{name}", @last)
end

Given /^'(.*)' has (.*), an array of:$/ do |name, attribute, table|
  object = instance_variable_get("@#{name}")
  object.send(attribute + "=", [])
  table.hashes.each do |hash|
    hash.each {|key, value| object.send(attribute) << value}
  end
end


When /^I save the object '(.*)'$/ do |name|
  object = instance_variable_get("@#{name}")
  @last_save = @collection.save(object)
end

Then /^the object '(.*)' roundtrips$/ do |name|
  object = instance_variable_get("@#{name}")
  object.instance_variable_set("@_id", @last_save)
  @collection.find_one(@last_save).should == object
end

Then /^the attribute '(.*)' of '(.*)' is '(.*)'$/ do |attr, var, value|
  object = instance_variable_get("@#{var}")
  object.send(attr).to_s.should == value
end

Version data entries

42 entries across 42 versions & 3 rubygems

Version Path
mongodoc-0.1.1 features/step_definitions/object_steps.rb
mongodoc-0.1.0 features/step_definitions/object_steps.rb