Created
January 26, 2012 23:18
-
-
Save simeonwillbanks/1685767 to your computer and use it in GitHub Desktop.
#gemfile rails 3, rspec-rails, capybara, capybara-webkit, headless in order to run request specs that can test javascript
This file contains 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
source 'https://rubygems.org' | |
gem 'rails', '3.2.0' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'sqlite3' | |
# 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' | |
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | |
# gem 'therubyracer' | |
gem 'uglifier', '>= 1.0.3' | |
end | |
gem 'jquery-rails' | |
# To use ActiveModel has_secure_password | |
# gem 'bcrypt-ruby', '~> 3.0.0' | |
# To use Jbuilder templates for JSON | |
# gem 'jbuilder' | |
# Use unicorn as the web server | |
# gem 'unicorn' | |
# Deploy with Capistrano | |
# gem 'capistrano' | |
# To use debugger | |
# gem 'ruby-debug19', :require => 'ruby-debug' | |
group :development, :test do | |
gem 'rspec-rails' | |
gem 'capybara' | |
gem 'capybara-webkit' | |
gem 'headless' | |
gem 'database_cleaner' | |
end |
This file contains 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
require 'spec_helper' | |
describe 'Search' do | |
context 'when logged in' do | |
# :js => true means JavaScript will execute | |
describe 'search result add comment link', :js => true do | |
it 'shows user comment form' do | |
search_for shared_keyword | |
within('#search-results') do | |
click_link('Add Comment') | |
page.should have_content('Share your ideas') | |
end | |
end | |
end | |
end | |
end |
This file contains 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
# 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 'capybara/rspec' | |
require 'capybara-webkit' | |
require 'headless' | |
require 'database_cleaner' | |
# 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| | |
Capybara.javascript_driver = :webkit | |
config.use_transactional_fixtures = false | |
config.before(:suite) do | |
# Use the headless gem to manage your Xvfb server | |
# Do not destroy X server incase another process is using it | |
Headless.new(:destroy_on_exit => false).start | |
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