Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Created June 5, 2011 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchelimsky/1009111 to your computer and use it in GitHub Desktop.
Save dchelimsky/1009111 to your computer and use it in GitHub Desktop.
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