Created
November 19, 2014 00:54
-
-
Save anonymous/0fd8fd2c9e6a7416321e to your computer and use it in GitHub Desktop.
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
guard :rspec, cmd: 'bundle exec rspec' do | |
watch(%r{^spec/.+_spec\.rb$}) | |
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |
watch('spec/spec_helper.rb') { "spec" } | |
# Rails example | |
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | |
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } | |
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } | |
#watch(%r{^spec/support/(.+)\.rb$}) { "spec" } | |
watch('config/routes.rb') { "spec/routing" } | |
watch('app/controllers/application_controller.rb') { "spec/acceptance" } | |
watch('spec/rails_helper.rb') { "spec" } | |
# Capybara features specs | |
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } | |
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
#spec/spec_helper.rb | |
require 'spork' | |
require 'capybara/rspec' | |
Spork.prefork do | |
require "rails/application" | |
Spork.trap_method(Rails::Application, :reload_routes!) | |
Spork.trap_method(Rails::Application::RoutesReloader, :reload!) | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rubygems' | |
require 'faker' | |
require 'database_cleaner' | |
require 'shoulda-matchers' | |
end | |
Spork.each_run do | |
load "#{Rails.root}/config/routes.rb" | |
Dir["#{Rails.root}/lib/**/*.rb"].each {|f| load f} | |
#use thin for capybara | |
Capybara.server do |app, port| | |
require 'rack/handler/thin' | |
Rack::Handler::Thin.run(app, :Port => port) | |
end | |
Capybara.server_port = 3001 | |
Capybara.default_host = 'http://localhost:3001' | |
OmniAuth.config.test_mode = true | |
# This code will be run each time you run your specs. | |
RSpec.configure do |config| | |
config.mock_with :rspec | |
config.use_transactional_fixtures = false | |
end | |
FactoryGirl.reload | |
end | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[Rails.root.join("spec/modules/**/*.rb")].each {|f| require f} | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
Dir[Rails.root.join("spec/matchers/**/*.rb")].each {|f| require f} | |
Dir[Rails.root.join("spec/core_ext/**/*.rb")].each {|f| require f} | |
RSpec.configure do |config| | |
config.infer_spec_type_from_file_location! | |
config.include LoginHelpers, type: :feature | |
config.include DownloadHelpers, type: :feature | |
config.include InputExampleGroup, type: :input | |
Capybara.register_driver :firefox do |app| | |
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile['browser.download.dir'] = DownloadHelpers::PATH.to_s #set download dir | |
profile['browser.download.folderList'] = 2 #prevent open with dialog | |
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/plain" | |
Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile) | |
end | |
Capybara.javascript_driver = :firefox | |
Faker::Config.locale = 'en' | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each, :js => true) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
PrimaryAtDeviceArea.seed | |
PrimaryUseArea.seed | |
ItemType.seed | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
config.include FactoryGirl::Syntax::Methods | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment