Last active
September 2, 2015 09:20
-
-
Save davejlong/9668972 to your computer and use it in GitHub Desktop.
Capybara with RSpec with a Rails Engine
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
# auth.gemspec | |
require 'auth/version' | |
Gem::Specification.new do |s| | |
... | |
s.add_dependency 'rails', '~> 4.0.4' | |
s.add_dependency 'devise', '~> 3.2.4' | |
s.add_development_dependency 'sqlite3' | |
s.add_development_dependency 'rspec-rails', '~> 3.0.0.beta' | |
s.add_development_dependency 'factory_girl_rails', '~> 4.4.1' | |
s.add_development_dependency 'database_cleaner', '~> 1.2.0' | |
s.add_development_dependency 'capybara', '~> 2.2.1' | |
end |
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
# spec/support/capybara.rb | |
require 'capybara/rspec' | |
require 'capybara/rails' | |
Capybara.app = Auth::Engine | |
RSpec.configure do |config| | |
config.include RecruiticsAuth::Engine.routes.url_helpers | |
end |
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
# spec/features/sign_in_spec.rb | |
require 'spec_helper' | |
describe 'Sign in flow' do | |
let(:user) { FactoryGirl.create :user } | |
context 'with valid credentials' do | |
it 'logs a user in' do | |
visit '/auth/users/sign_in' | |
within '#new_user' do | |
fill_in 'Email', with: user.email | |
fill_in 'Password', with: user.password | |
end | |
click_link 'Sign in' | |
expect(page).to have_content 'Success' | |
end | |
end | |
end |
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
# spec/spec_helper.rb | |
ENV['RAILS_ENV'] = 'test' | |
require File.join File.dirname(__FILE__), 'dummy', 'config', 'environment.rb' | |
Dir[File.join File.dirname(__FILE__), 'support', '**', '*.rb'].each { |f| require f } | |
RSpec.configure do |config| | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment