Skip to content

Instantly share code, notes, and snippets.

@davejlong

davejlong/auth.gemspec

Last active Sep 2, 2015
Embed
What would you like to do?
Capybara with RSpec with a Rails Engine
# 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
# 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
# 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
# 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
You can’t perform that action at this time.