This is my spec_helper.rb file:
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’ # doesn’t work…<=================
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|
== Mock Framework
If you prefer to use mocha, flexmock or RR, uncomment the
appropriate
line:
config.mock_with :mocha
config.mock_with :flexmock
config.mock_with :rr
config.mock_with :rspec
Remove this line if you’re not using ActiveRecord or ActiveRecord
fixtures
config.fixture_path = “#{::Rails.root}/spec/fixtures”
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
end
Oddly, although I followed the instruction on the github page, this
fails:
it “shows a list of all organizations” do
render
within(“ul#organization_list”) do
rendered.should have_selector(“li.sort”)
end
end
with this error:
- superadmin/organizations/index.html.erb shows a list of all
organizations
Failure/Error: within(“ul#organization_list”) do
NoMethodError:
undefined method `within’ for
#RSpec::Core::ExampleGroup::Nested_1:0x00000105949ef8
Why might that be? I’m using Rails 3.1rc4, and my Gemfile should be all
set:
source ‘http://rubygems.org’
gem ‘rails’, ‘3.1.0.rc4’ # using ruby 1.9.2p180
gem ‘mysql2’ # using mysql db
gem ‘authlogic’ # smart user authentication
gem ‘dynamic_form’ # easy error messages for forms
Asset template engines
gem ‘sass-rails’, “~> 3.1.0.rc”
gem ‘coffee-script’
gem ‘uglifier’ # compresses JS code for production
gem ‘jquery-rails’
group :test do
helpers
gem ‘factory_girl_rails’
gem ‘forgery’
gem ‘database_cleaner’
core testing frameworks
gem ‘rspec-rails’, ‘>= 2.6.1’
gem ‘cucumber-rails’, ‘>= 1.0.0’
gem ‘capybara’, ‘>= 1.0.0’
Pretty printed test output
gem ‘turn’, :require => false
end