Created
September 4, 2012 19:13
-
-
Save nickL/3625226 to your computer and use it in GitHub Desktop.
spec helper example w/ spork
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 'rubygems' | |
require 'spork' | |
require 'faker' | |
begin | |
require 'simplecov' | |
SimpleCov.start 'rails' do | |
add_filter "/rocket_pants/" | |
end | |
rescue LoadError => e | |
puts 'SimpleCov not available, skipping coverage...' | |
end | |
Spork.prefork do | |
ENV['RAILS_ENV'] ||= 'test' | |
require_relative '../config/environment' | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
require 'capybara/rspec' | |
require 'capybara/rails' | |
# Require all of the RSpec Support libraries | |
require_relative 'support/support' | |
require_relative 'support/controller_macros' | |
require_relative 'support/devise' | |
require 'draper/test/rspec_integration' | |
#simpleCov | |
begin | |
require 'simplecov' | |
SimpleCov.start 'rails' do | |
add_filter "/rocket_pants/" | |
end | |
rescue LoadError => e | |
puts 'SimpleCov not available, skipping coverage...' | |
end | |
RSpec.configure do |config| | |
# Bring in the Mailer Macros | |
# config.include MailerMacros | |
config.tty = true | |
config.include RocketPants::TestHelper, :type => :controller | |
config.include RocketPants::RSpecMatchers, :type => :controller | |
config.extend VCR::RSpec::Macros | |
# Bring in the Mongoid matchers | |
#config.include Mongoid::Matchers | |
# Reset all emails before each run | |
# config.before(:each) { reset_email } | |
end | |
require 'vcr' | |
VCR.configure do |c| | |
c.cassette_library_dir = Rails.root.join('spec', 'fixtures') | |
c.hook_into :webmock | |
c.default_cassette_options = { :record => :new_episodes } | |
c.preserve_exact_body_bytes do |http_message| | |
http_message.body.encoding.name == 'ASCII-8BIT' || !http_message.body.valid_encoding? | |
end | |
end | |
end | |
Spork.each_run { | |
# Hack to ensure models get reloaded by Spork - remove as soon as this is fixed in Spork. | |
# Silence warnings to avoid all the 'warning: already initialized constant' messages that | |
# appear for constants defined in the models. | |
silence_warnings do | |
Dir["#{Rails.root}/app/models/**/*.rb"].each {|f| load f} | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment