Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
shared_context 'user' do
before :all do
@user = User.create( :name => "Bob", :password => "foo", :admin => false )
end
def login
visit( url( :login ) )
fill_in :name, :with => "Bob"
fill_in :password, :with => "foo"
click_button "Login"
response
end
end
shared_context 'admin' do
before :all do
@user = User.create( :name => "Sally", :password => "bar", :admin => true )
end
def login
visit( url( :login ) )
fill_in :name, :with => "Sally"
fill_in :password, :with => "bar"
click_button "Login"
response
end
end
# Write your specs:
describe "Logging in" do
describe "as an user" do
include_context 'user'
it "should log them in" do
login.should be_successful
end
end
describe "as an admin" do
include_context 'admin'
it "should log them in" do
login.should be_successful
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment