Skip to content

Instantly share code, notes, and snippets.

@railscard
Created September 19, 2012 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save railscard/3747821 to your computer and use it in GitHub Desktop.
Save railscard/3747821 to your computer and use it in GitHub Desktop.
so.rb
module UserMacros
def make_user_and_login(user = nil)
user ||= FactoryGirl.create(:user)
visit new_user_session_path
page.should have_selector('title', :text => 'Login')
fill_in('Email', :with => user.email)
fill_in('Password', :with => user.password)
click_button('Login')
page.should have_selector('title', :text => 'Home')
end
end
# And then
describe 'Overview Page' do
it 'shows spending' do
price = FactoryGirl.create(:price)
user = FactoryGirl.create(:user, :price => price)
make_user_and_login(user)
click_link('Overview')
page.should have_selector('title', :text => 'Overview')
within('p.today', :text => 'Today') do
page.should have_content('$1.01')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment