Created
March 22, 2011 08:17
-
-
Save justinko/880921 to your computer and use it in GitHub Desktop.
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
# Replaces `for_groups_matching` | |
RSpec.configure do |config| | |
config.shared :type => :model do | |
let(:foo) { 'only in models' } | |
end | |
end | |
# I'm actually against being able to call `shared` | |
# on the configuration instance. It's just not needed. | |
# You could achieve the same by doing this: | |
# In support/model_configuration.rb | |
shared :type => :model do | |
let(:foo) { 'only in models' } | |
end | |
# ------------------------------------- | |
# Replaces `shared_examples_for` | |
# In support/slug_examples.rb | |
shared 'a model with a slug' do | |
it 'sets the slug column upon initialization' do | |
described_class.new.slug.should_not be_blank | |
end | |
end | |
# In post_spec.rb | |
describe Post do | |
it_should_behave_like 'a model with a slug' | |
end | |
# ------------------------------------- | |
# Replaces `SharedContext` | |
# In support/user_setup.rb | |
shared 'basic user' do | |
let(:user) { Factory(:user) } | |
before { user.set_initial_password } | |
end | |
# In user_spec.rb | |
describe User do | |
context 'that is suspended' do | |
with_shared_context 'basic user' | |
before { user.suspend! } | |
it 'does not receive email' do | |
user.receive_email?.should be_false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment