-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic spec_helper for extensions to include
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# A basic spec_helper to included as the starting point for extensions | ||
# | ||
# Use this by including it in you extensions' spec/spec_helper.rb | ||
# | ||
# require 'solidus_support/extension/spec_helper.rb' | ||
# | ||
|
||
require 'rspec/rails' | ||
require 'database_cleaner' | ||
require 'ffaker' | ||
require 'capybara-screenshot/rspec' | ||
require 'capybara/poltergeist' | ||
|
||
Capybara.register_driver :poltergiest do |app| | ||
Capybara::Poltergeist::Driver.new(app, js_errors: true, timeout: 90) | ||
end | ||
|
||
Capybara.javascript_driver = :poltergeist | ||
Capybara.default_max_wait_time = 10 | ||
|
||
require 'spree/testing_support/authorization_helpers' | ||
require 'spree/testing_support/capybara_ext' | ||
require 'spree/testing_support/factories' | ||
require 'spree/testing_support/url_helpers' | ||
|
||
RSpec.configure do |config| | ||
config.include FactoryGirl::Syntax::Methods | ||
|
||
# visit spree.admin_path | ||
# current_path.should eql(spree.products_path) | ||
config.include Spree::TestingSupport::UrlHelpers | ||
|
||
config.filter_run focus: true | ||
config.run_all_when_everything_filtered = true | ||
|
||
config.mock_with :rspec | ||
config.color = true | ||
|
||
config.use_transactional_fixtures = false | ||
|
||
config.when_first_matching_example_defined(type: :feature) do | ||
config.before :suite do | ||
# Preload assets | ||
Rails.application.precompiled_assets | ||
end | ||
end | ||
|
||
# Ensure Suite is set to use transactions for speed. | ||
config.before :suite do | ||
DatabaseCleaner.clean_with :truncation | ||
end | ||
|
||
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary. | ||
config.before :each do | ||
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction | ||
DatabaseCleaner.start | ||
end | ||
|
||
# After each spec clean the database. | ||
config.after :each do | ||
DatabaseCleaner.clean | ||
end | ||
|
||
config.fail_fast = ENV['FAIL_FAST'] || false | ||
config.order = 'random' | ||
end |