Skip to content

Instantly share code, notes, and snippets.

@ttdonovan
Created February 23, 2011 03:36
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 ttdonovan/839970 to your computer and use it in GitHub Desktop.
Save ttdonovan/839970 to your computer and use it in GitHub Desktop.
Steak - User Sign In Spec
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
require 'steak'
require 'capybara/rails'
require 'capybara/session'
Spec::Runner.configure do |config|
config.include Capybara
end
# Put your acceptance spec helpers inside /spec/acceptance/support
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
module HelperMethods
def should_be_on(path)
page.current_path.should == path
end
end
Spec::Runner.configuration.include(HelperMethods)
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
feature "User Sign In", %q{
In order to access private information
As an user
I want to sign in
} do
let(:user) do
User.create!(Factory.attributes_for(:email_confirmed_user))
end
scenario "should successfully sign in with email" do
visit '/sign_in'
fill_in 'Email Address', :with => user.email
fill_in 'Password', :with => 'password'
click_button 'Sign In'
should_be_on '/account'
page.should have_content('Signed In.')
end
end
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
Spec::Runner.configure do |config|
# If you're not using ActiveRecord you should remove these
# lines, delete config/database.yml and disable :active_record
# in your config/boot.rb
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment