Created
June 5, 2011 16:16
-
-
Save dchelimsky/1009111 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
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