Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mongoid steps for features/pickle_api/example_code
- Loading branch information
Showing
7 changed files
with
95 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Given "I create a database setup for the example mongoid app" do | ||
require 'mongo' | ||
pending("Install and start mongodb to run the mongoid features") unless (Mongo::Connection.new.db('pickle_test') rescue nil) | ||
create_file "lib/db.rb", <<-FILE | ||
require 'mongoid' | ||
Mongoid.configure do |config| | ||
config.master = Mongo::Connection.new.db('pickle-test') | ||
end | ||
Mongoid.database.collections.each(&:remove) | ||
FILE | ||
end | ||
|
||
Given "I create the example mongoid app models" do | ||
create_file "lib/user.rb", <<-FILE | ||
class User | ||
include Mongoid::Document | ||
field :name, :default => "made by orm" | ||
has_many_related :notes, :foreign_key => :owner_id | ||
def create_welcome_note | ||
create_note("Welcome \#{name}!") | ||
end | ||
def create_note(body) | ||
Note.create :owner_id => id, :body => body | ||
end | ||
end | ||
FILE | ||
|
||
create_file "lib/note.rb", <<-FILE | ||
class Note | ||
include Mongoid::Document | ||
field :body, :default => "made by orm" | ||
belongs_to_related :owner, :class_name => 'User' | ||
end | ||
FILE | ||
|
||
create_file "lib/models.rb", <<-FILE | ||
require 'user' | ||
require 'note' | ||
FILE | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters