Created
October 14, 2015 12:01
-
-
Save a7medfahmy94/ea0e815a59996cd74117 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 :spork, :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch('config/environments/test.rb') | |
watch(%r{^config/initializers/.+\.rb$}) | |
watch('Gemfile.lock') | |
watch('spec/spec_helper.rb') { :rspec } | |
watch('test/test_helper.rb') { :test_unit } | |
watch(%r{features/support/}) { :cucumber } | |
end | |
guard :rspec, cmd: "bundle exec rspec --drb" do | |
require "guard/rspec/dsl" | |
dsl = Guard::RSpec::Dsl.new(self) | |
# Feel free to open issues for suggestions and improvements | |
# RSpec files | |
rspec = dsl.rspec | |
watch(rspec.spec_helper) { rspec.spec_dir } | |
watch(rspec.spec_support) { rspec.spec_dir } | |
watch(rspec.spec_files) | |
# Ruby files | |
ruby = dsl.ruby | |
dsl.watch_spec_files_for(ruby.lib_files) | |
# Rails files | |
rails = dsl.rails(view_extensions: %w(erb haml slim)) | |
dsl.watch_spec_files_for(rails.app_files) | |
dsl.watch_spec_files_for(rails.views) | |
watch(rails.controllers) do |m| | |
[ | |
rspec.spec.("routing/#{m[1]}_routing"), | |
rspec.spec.("controllers/#{m[1]}_controller"), | |
rspec.spec.("acceptance/#{m[1]}") | |
] | |
end | |
# Rails config changes | |
watch(rails.spec_helper) { rspec.spec_dir } | |
watch(rails.routes) { "#{rspec.spec_dir}/routing" } | |
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } | |
# Capybara features specs | |
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") } | |
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") } | |
# Turnip features and steps | |
watch(%r{^spec/acceptance/(.+)\.feature$}) | |
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| | |
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" | |
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
require 'spec_helper' | |
ENV['RAILS_ENV'] ||= 'test' | |
# require File.expand_path('../../config/environment', __FILE__) | |
abort("The Rails environment is running in production mode!") if Rails.env.production? | |
ActiveRecord::Migration.maintain_test_schema! | |
RSpec.configure do |config| | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
config.use_transactional_fixtures = false | |
config.infer_spec_type_from_file_location! | |
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 'rubygems' | |
require 'spork' | |
class Spork::TestFramework::RSpec | |
def run_tests(argv, stderr, stdout) | |
if rspec1? | |
::Spec::Runner::CommandLine.run( | |
::Spec::Runner::OptionParser.parse(argv, stderr, stdout) | |
) | |
elsif rspec3? | |
options = ::RSpec::Core::ConfigurationOptions.new(argv) | |
::RSpec::Core::Runner.new(options).run(stderr, stdout) | |
else | |
::RSpec::Core::CommandLine.new(argv).run(stderr, stdout) | |
end | |
end | |
def rspec3? | |
return false if !defined?(::RSpec::Core::Version::STRING) | |
::RSpec::Core::Version::STRING =~ /^3\./ | |
end | |
end | |
Spork.prefork do | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'shoulda/matchers' | |
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } | |
RSpec.configure do |config| | |
config.expect_with :rspec do |expectations| | |
expectations.include_chain_clauses_in_custom_matcher_descriptions = true | |
end | |
config.mock_with :rspec do |mocks| | |
mocks.verify_partial_doubles = true | |
end | |
end | |
end | |
Spork.each_run do | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment