Created
January 28, 2010 14:56
-
-
Save samullen/288809 to your computer and use it in GitHub Desktop.
Testing MongoMapper with Machinist
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
require 'machinist/mongomapper' | |
require 'sham' | |
require 'faker' | |
Sham.define do | |
username { Faker::Internet.user_name } | |
email { Faker::Internet.email } | |
# confirmed_at { ...date... } | |
# confirmation_sent_at { ...date... } | |
# remember_token { 'Cj4ja2A3Xp6MEK6rdUej' } | |
# remember_created_at { date } | |
end | |
User.blueprint do | |
username { Sham.username } | |
email { Sham.email } | |
password "foobarbaz" | |
password_confirmation "foobarbaz" | |
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
# Install Machinist Gem | |
# http://github.com/notahat/machinist | |
sudo gem install machinist --source http://gemcutter.org | |
# Install Faker Gem - used to fake data for Machinist | |
# http://faker.rubyforge.org/ | |
sudo gem install faker | |
# Install machinist_mongo Gem - used to interface Machinist to Mongo | |
# http://github.com/nmerouze/machinist_mongo | |
gem install machinist_mongo | |
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
ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") | |
require 'test_help' | |
require File.expand_path(File.dirname(__FILE__) + "/blueprints") | |
class ActiveSupport::TestCase | |
setup { Sham.reset } | |
def teardown | |
MongoMapper.database.collections.each do |collection| | |
collection.remove # remove documents from collection | |
end | |
end | |
# Every Test using this helper incorporates the above teardown to its own | |
def inherited(base) # applied upon inheritance | |
base.define_method teardown do | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment