Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2012 23:18
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save simeonwillbanks/1685767 to your computer and use it in GitHub Desktop.
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
source ''
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => '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 for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
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'
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')
# 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 => false).start
DatabaseCleaner.strategy = :truncation
config.before(:each) do
config.after(:each) do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment