public
Last active

Steak - User Sign In Spec

  • Download Gist
acceptance_helper.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11
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}
helpers.rb
Ruby
1 2 3 4 5 6 7 8 9
module HelperMethods
 
def should_be_on(path)
page.current_path.should == path
end
 
end
 
Spec::Runner.configuration.include(HelperMethods)
sign_in_spec.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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
spec_helper.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.