Question

Ok, total Cucumber newbie here so please be gentle. As a learning Ruby/Cucumber/MongoDB endeavor I'm building a simple contact manager. I have a Person (parent) model and an have been able to write a simple test as follows:

Scenario: Show people
  Given the following person exists
 | firstname | lastname |
 | Bob      | Jones    |
  When I am on the home page
  Then I should see "Bob"

So far so good....however now I am adding an array of "Address" child objects to it...problem is now that above test fails....I 'think' it's because I'm not describing my table correctly anymore in the above test, since it now has an address property too.

My question is how do I correctly write the above test if I want to check the child objects?

My two classes follow:

class Person < MongoBase
  key :firstname, String, :required=>true
  key :lastname, String, :required=>true

  many :addresses
end

class Address <MongoBase

  key :person_id, ObjectId
  key :street, String
  key :city, String
  key :State, String
  key :Zip, String

  belongs_to :person
end

Thanks in advance!

Update: the original test now passes but I still can't figure out how to set up the test so that Bob Jones has a child address.

Was it helpful?

Solution

I think the $1,000,000 is "what's the failure"? Also - if you're using MongoMapper than you'll want to explicitly set Address as an EmbeddedDocument (include MongoMapper::EmbeddedDocument) - this is most likely what your failure is since (I don't think) you can use many:XXX with a regular MongoMapper::Document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top