Skip to content

Instantly share code, notes, and snippets.

@phillipkoebbe
Created April 9, 2012 20:26
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 phillipkoebbe/2346391 to your computer and use it in GitHub Desktop.
Save phillipkoebbe/2346391 to your computer and use it in GitHub Desktop.
request spec slowdown
source 'https://rubygems.org'
gem 'rails', '3.2.2'
gem 'haml'
gem 'haml-rails'
gem 'coffee-filter'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :production, :staging do
gem 'pg'
end
group :development do
gem 'capistrano'
gem 'capistrano-ext'
end
group :development, :test do
gem 'mail' # this is installed via actionmailer, but i was having a load order problem trying to use capybara-email
gem 'rspec'
gem 'rspec-rails'
gem 'capybara'
gem 'capybara-webkit'
gem 'capybara-email', :require => false
gem 'simplecov', :require => false
gem 'simplecov-html', :require => false
gem 'sqlite3'
gem 'unicorn'
gem 'unicorn-rails'
gem 'ruby-debug19', :require => 'ruby-debug'
end
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
archive-tar-minitar (0.5.2)
arel (3.0.2)
builder (3.0.0)
capistrano (2.11.2)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capistrano-ext (1.2.1)
capistrano (>= 1.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
capybara-email (0.1.2)
capybara-webkit (0.11.0)
capybara (>= 1.0.0, < 1.2)
json
childprocess (0.3.1)
ffi (~> 1.0.6)
coffee-filter (0.1.1)
coffee-script (>= 2.2.0)
haml (>= 3.0.18)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
columnize (0.3.6)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
ffi (1.0.11)
haml (3.1.4)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
highline (1.6.11)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.6.6)
kgio (2.7.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.2.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.3.0)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.2)
pg (0.13.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
raindrops (0.8.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.9.0)
rspec-core (~> 2.9.0)
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.9.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.7)
sass (3.1.15)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.20.0)
childprocess (>= 0.2.5)
ffi (~> 1.0)
multi_json (~> 1.0)
rubyzip
simplecov (0.6.1)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
unicorn (4.2.1)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
unicorn-rails (0.0.1)
rack
unicorn
xpath (0.1.4)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
capistrano
capistrano-ext
capybara
capybara-email
capybara-webkit
coffee-filter
coffee-rails (~> 3.2.1)
haml
haml-rails
mail
pg
rails (= 3.2.2)
rspec
rspec-rails
ruby-debug19
sass-rails (~> 3.2.3)
simplecov
simplecov-html
sqlite3
uglifier (>= 1.0.3)
unicorn
unicorn-rails
require 'spec_helper'
require 'capybara/rspec'
require 'capybara/email/rspec'
Capybara.default_driver = :webkit
Capybara.javascript_driver = :webkit
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
RSpec.configure do |config|
config.before(:each, :type => :request) do
clear_emails
end
config.after(:each, :type => :request) do
Capybara.reset_sessions!
Capybara.use_default_driver
end
end
require 'support/integration_helpers'
module Grounect
module IntegrationHelpers
def disable_javascript
# just in case it is needed somewhere
Capybara.current_driver = :rack_test
end
def sign_in(options = {})
member = options.delete(:member)
member ||= create_member options
visit root_path
fill_in 'Email', :with => member.email
fill_in 'Password', :with => member.initial_password
click_button 'Sign In'
end
end
end
RSpec.configure do |config|
config.include(Grounect::IntegrationHelpers, :type => :request)
end
require 'integration_helper'
describe 'reset password' do
before(:each) do
# get to the sign up form and fill it in
# with some test data that will be used
# in basically all the tests
@member = create_member
visit root_path
click_link 'reset-password-link'
fill_in 'Email', :with => @member.email
end
it 'should fail without an email' do
fill_in 'Email', :with => ''
click_button 'Reset Password'
page.should have_content(EMAIL_MISSING_ERROR)
end
it 'should fail with an invalid email' do
fill_in 'Email', :with => 'invalid.email example.com'
click_button 'Reset Password'
page.should have_content(EMAIL_INVALID_ERROR)
end
it 'should fail with an unknown email' do
fill_in 'Email', :with => 'unknown.email@example.com'
click_button 'Reset Password'
page.should have_content(EMAIL_UNKNOWN_ERROR)
end
it 'should generate a new password for the member when email is correct' do
click_button 'Reset Password'
@member.initial_password.should_not be_nil
end
it 'should send an email to the user' do
click_button 'Reset Password'
open_email @member.email
current_email.should_not be_nil
end
it 'should include the new password in the email' do
click_button 'Reset Password'
@member.reload
open_email @member.email
current_email.base.email.parts.each { |part| part.body.should =~ /#{@member.initial_password}/ }
end
it 'should refresh the page so the user can log in' do
click_button 'Reset Password'
page.find_button('Sign In').should be_visible
end
it 'should populate email on the sign in form' do
click_button 'Reset Password'
page.find_field('Email').value.should == @member.email
end
it 'should inform the user a message was just sent' do
click_button 'Reset Password'
page.should have_content(NEW_PASSWORD_EMAILED_TO_YOU_MESSAGE)
end
end
module Grounect
module SharedHelpers
def valid_member_attributes(overrides = {})
{
:first_name => 'Some',
:last_name => 'Member',
:email => 'some.member@example.com',
:password => nil,
:address => nil,
:city => nil,
:state => nil,
:zip_code => nil,
:phone_number => nil
}.merge(overrides)
end
def new_member(overrides = {})
Member.new valid_member_attributes(overrides)
end
def create_member(overrides = {})
Member.create valid_member_attributes(overrides)
end
end
end
RSpec.configure do |config|
config.include(Grounect::SharedHelpers)
end
require File.expand_path(File.join(File.dirname(__FILE__),'..','lib','coverage_setup'))
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'support/shared_helpers'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
# Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.include(Grounect::Constants)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment