Created
April 1, 2011 09:25
-
-
Save c-vetter/897935 to your computer and use it in GitHub Desktop.
Use these files to share blueprints between rspec and cucumber, centralize shams in one file, and store the blueprints in the blueprints directory in rails root. Don't forget to put machinist and ffaker in your Gemfile
This file contains hidden or 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/active_record' | |
require 'sham' | |
require 'ffaker' | |
# load all other .rb files in this directory | |
Dir[File.dirname(__FILE__)+'/*.rb'].each {|f| require f} |
This file contains hidden or 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
Sham.define do | |
# attribute { value } | |
end |
This file contains hidden or 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
# Load machinist blueprints | |
require Rails.root.join('blueprints/_setup.rb') | |
Before { Sham.reset } |
This file contains hidden or 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
# Load machinist blueprints | |
require Rails.root.join('blueprints/_setup.rb') |
This file contains hidden or 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
# wrap the mocking/stubbing (=faking) of models for improved spec readability | |
def fake(model, overrides={} ) | |
# stub_model gives a rails-specific interface, as opposed to double(model) | |
# model.plan harnesses the neatness of machinist blueprints | |
stub_model model, model.plan.merge(overrides.symbolize_keys) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment