diff --git a/README.md b/README.md index 2f4b7dc..f5d00d5 100644 --- a/README.md +++ b/README.md @@ -56,62 +56,6 @@ end config.to_prepare(&method(:activate).to_proc) ``` -### Testing Helpers - -This gem provides some useful helpers for RSpec to setup an extension's test -environment easily. - -Into your extension's spec/spec_helper.rb: - -```ruby -require "solidus_support/extension/feature_helper" -``` - -This helper loads configuration needed to run extensions feature specs -correctly, setting up Capybara and configuring Rails test application -to precompile assets before the first feature spec. - -This helper requires the `rails_helper`, also provided by this gem and -requireable as a stand-alone helper. - -By doing: - -```ruby -require "solidus_support/extension/rails_helper" -``` - -extension's test suite will have all Rails related tests configuration, -like authorization helpers, Solidus core factories, url helpers, and -other helpers to easily work with Solidus Config. - -This `rails_helper` in turn requires the basic `spec_helper`, which is -responsible to load a basic RSpec configuration, which could be needed -in all extensions. It is also requireable as a stand-alone helper with: - -```ruby -require "solidus_support/extension/spec_helper" -``` - -### Coverage Collection - -The gem also includes a SimpleCov configuration that will send your test -coverage information directly to Codecov.io. Simply add this at the top -of your `spec/spec_helper.rb`: - -```ruby -require "solidus_support/extension/coverage" -``` - -**Note: Make sure to add this at the VERY TOP of your spec_helper, -otherwise you'll get skewed coverage reports!** - -If your extension is in a public repo and being tested on Travis or -CircleCI, there's nothing else you need to do - you'll get coverage -reports for free! - -If your setup is more complex, look at the [SimpleCov](https://github.com/colszowka/simplecov) -and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs. - ## Development After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/lib/solidus_support/extension/coverage.rb b/lib/solidus_support/extension/coverage.rb deleted file mode 100644 index cd234f4..0000000 --- a/lib/solidus_support/extension/coverage.rb +++ /dev/null @@ -1,16 +0,0 @@ -# A SimpleCov and Codecov configuration to track code coverage in your extension -# -# Include it AT THE TOP of your spec/spec_helper.rb: -# -# require 'solidus_support/extension/coverage' -# -# Note that things may not work properly if you don't include this at the very top! -# - -require 'simplecov' -SimpleCov.start 'rails' - -if ENV['CI'] - require 'codecov' - SimpleCov.formatter = SimpleCov::Formatter::Codecov -end diff --git a/lib/solidus_support/extension/feature_helper.rb b/lib/solidus_support/extension/feature_helper.rb deleted file mode 100644 index a425214..0000000 --- a/lib/solidus_support/extension/feature_helper.rb +++ /dev/null @@ -1,44 +0,0 @@ -# A basic feature_helper to be included as the starting point for extensions -# -# Can be required from an extension's spec/feature_helper.rb -# -# require 'solidus_support/extension/feature_helper' -# - -require 'solidus_support/extension/rails_helper' - -require 'capybara-screenshot/rspec' -require 'selenium/webdriver' - -Capybara.register_driver :selenium_chrome_headless do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { args: %w[headless start-maximized] } - ) - - Capybara::Selenium::Driver.new( - app, - browser: :chrome, - desired_capabilities: capabilities - ) -end - -Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym -Capybara.default_max_wait_time = 10 - -require 'spree/testing_support/capybara_ext' - -RSpec.configure do |config| - config.when_first_matching_example_defined(type: :feature) do - config.before :suite do - # Preload assets - if Rails.application.respond_to?(:precompiled_assets) - Rails.application.precompiled_assets - else - # For older sprockets 2.x - Rails.application.config.assets.precompile.each do |asset| - Rails.application.assets.find_asset(asset) - end - end - end - end -end diff --git a/lib/solidus_support/extension/rails_helper.rb b/lib/solidus_support/extension/rails_helper.rb deleted file mode 100644 index 7bcb22d..0000000 --- a/lib/solidus_support/extension/rails_helper.rb +++ /dev/null @@ -1,45 +0,0 @@ -# A basic rails_helper to be included as the starting point for extensions -# -# Can be required from an extension's spec/rails_helper.rb -# -# require 'solidus_support/extension/rails_helper' -# - -require 'solidus_support/extension/spec_helper' - -require 'rspec/rails' -require 'database_cleaner' -require 'ffaker' - -require 'spree/testing_support/authorization_helpers' -require 'spree/testing_support/factories' -require 'spree/testing_support/url_helpers' -require 'spree/testing_support/preferences' -require 'solidus_support/testing_support/preferences' - -RSpec.configure do |config| - config.include FactoryBot::Syntax::Methods - - # visit spree.admin_path - # current_path.should eql(spree.products_path) - config.include Spree::TestingSupport::UrlHelpers - - config.include Spree::TestingSupport::Preferences - config.include SolidusSupport::TestingSupport::Preferences - - config.before :suite do - DatabaseCleaner.clean_with :truncation - end - - # Around each spec check if it is a Javascript test and switch between using - # database transactions or not where necessary. - config.around(:each) do |example| - DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction - - DatabaseCleaner.cleaning do - reset_spree_preferences unless SolidusSupport.reset_spree_preferences_deprecated? - - example.run - end - end -end diff --git a/lib/solidus_support/extension/spec_helper.rb b/lib/solidus_support/extension/spec_helper.rb deleted file mode 100644 index 5b54d26..0000000 --- a/lib/solidus_support/extension/spec_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -# A basic spec_helper to be included as the starting point for extensions -# -# Can be required from an extension's spec/spec_helper.rb -# -# require 'solidus_support/extension/spec_helper' -# - -RSpec.configure do |config| - config.filter_run focus: true - config.run_all_when_everything_filtered = true - - config.mock_with :rspec - config.color = true - - config.fail_fast = ENV['FAIL_FAST'] || false - config.order = 'random' - - Kernel.srand config.seed -end diff --git a/lib/solidus_support/testing_support/preferences.rb b/lib/solidus_support/testing_support/preferences.rb deleted file mode 100644 index 3b515e1..0000000 --- a/lib/solidus_support/testing_support/preferences.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -module SolidusSupport - module TestingSupport - module Preferences - # This wrapper method allows to stub spree preferences using - # the new standard way of solidus core but also works with - # old versions that does not have the stub_spree_preferences - # method yet. This way we can start using this method in our - # extensions safely. - # - # To have this available, it is needed to require in the - # spec/spec_helper.rb of the extension both: - # - # require 'spree/testing_support/preferences' - # require 'solidus_support/testing_support/preferences' - # - # @example Set a preference on Spree::Config - # stub_spree_preferences(allow_guest_checkout: false) - # - # @example Set a preference on Spree::Api::Config - # stub_spree_preferences(Spree::Api::Config, requires_authentication: false) - # - # @example Set a preference on a custom Spree::CustomExtension::Config - # stub_spree_preferences(Spree::CustomExtension::Config, custom_pref: true) - # - # @param prefs_or_conf_class [Class, Hash] the class we want to stub - # preferences for or the preferences hash (see prefs param). If this - # param is an Hash, preferences will be stubbed on Spree::Config. - # @param prefs [Hash, nil] names and values to be stubbed - def stub_spree_preferences(prefs_or_conf_class, prefs = nil) - super && return if SolidusSupport.reset_spree_preferences_deprecated? - - if prefs_or_conf_class.is_a?(Hash) - preference_store_class = Spree::Config - preferences = prefs_or_conf_class - else - preference_store_class = prefs_or_conf_class - preferences = prefs - end - preference_store_class.set(preferences) - end - end - end -end diff --git a/solidus_support.gemspec b/solidus_support.gemspec index 6bc253d..5e5a319 100644 --- a/solidus_support.gemspec +++ b/solidus_support.gemspec @@ -23,7 +23,4 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop' spec.add_development_dependency 'rubocop-rspec' spec.add_development_dependency 'solidus_core' - - spec.add_dependency 'capybara-screenshot' - spec.add_dependency 'codecov' end