From 3cde78039a7c0625049e4d00f78f350e46a9fb43 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 6 Nov 2017 15:17:17 -0800 Subject: [PATCH 1/5] Allow loading solidus_core without Sprockets --- core/config/initializers/assets.rb | 4 +++- core/lib/spree/testing_support/dummy_app.rb | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/config/initializers/assets.rb b/core/config/initializers/assets.rb index 9f74f4d86b9..10f32a4fb9b 100644 --- a/core/config/initializers/assets.rb +++ b/core/config/initializers/assets.rb @@ -1 +1,3 @@ -Rails.application.config.assets.precompile << 'solidus_core_manifest.js' +if Rails.application.config.respond_to?(:assets) + Rails.application.config.assets.precompile << 'solidus_core_manifest.js' +end diff --git a/core/lib/spree/testing_support/dummy_app.rb b/core/lib/spree/testing_support/dummy_app.rb index a41e830370d..0e4e7ff70c6 100644 --- a/core/lib/spree/testing_support/dummy_app.rb +++ b/core/lib/spree/testing_support/dummy_app.rb @@ -73,8 +73,10 @@ class Application < ::Rails::Application config.action_controller.include_all_helpers = false - config.assets.paths << File.expand_path('../dummy_app/assets/javascripts', __FILE__) - config.assets.paths << File.expand_path('../dummy_app/assets/stylesheets', __FILE__) + if config.respond_to?(:assets) + config.assets.paths << File.expand_path('../dummy_app/assets/javascripts', __FILE__) + config.assets.paths << File.expand_path('../dummy_app/assets/stylesheets', __FILE__) + end config.paths["config/database"] = File.expand_path('../dummy_app/database.yml', __FILE__) config.paths['app/views'] = File.expand_path('../dummy_app/views', __FILE__) From 5b4e7837dc634c4f642664d4a972adbaf4dd13b9 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 6 Nov 2017 15:17:40 -0800 Subject: [PATCH 2/5] Explicitly require rspec/core This isn't necessary when running through the `rspec` command, but is necessary when running files manually (ruby -Ispec spec/foo_spec.rb). --- core/spec/spec_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rb index 0a86edefd91..1246d89e990 100644 --- a/core/spec/spec_helper.rb +++ b/core/spec/spec_helper.rb @@ -12,6 +12,8 @@ end end +require 'rspec/core' + require 'spree/testing_support/preferences' require 'spree/config' require 'with_model' From f4b4999c1cc00c7c6648fd6249fa5b8fa60c9e8c Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 7 Nov 2017 15:08:01 -0800 Subject: [PATCH 3/5] Remove test dependencies from common_dependencies Previously we lumped all spec-related dependencies in the same place, but each project has slightly different requirements. This moves the declarations from a top-level Gemfile (well, file required from Gemfile) to individual projects' gemspecs. This adds explicitness (good) at the expense of repetition (bad) and makes the spec suites faster (good). --- api/solidus_api.gemspec | 10 ++++++++++ .../spree/api/shipments_controller_spec.rb | 1 + api/spec/spec_helper.rb | 5 +++++ backend/solidus_backend.gemspec | 12 +++++++++++ backend/spec/spec_helper.rb | 1 + common_spree_dependencies.rb | 20 ------------------- core/solidus_core.gemspec | 9 +++++++++ frontend/solidus_frontend.gemspec | 10 ++++++++++ frontend/spec/spec_helper.rb | 2 ++ sample/solidus_sample.gemspec | 5 +++++ sample/spec/spec_helper.rb | 2 ++ 11 files changed, 57 insertions(+), 20 deletions(-) diff --git a/api/solidus_api.gemspec b/api/solidus_api.gemspec index f49defdf6f0..78f1ad7344d 100644 --- a/api/solidus_api.gemspec +++ b/api/solidus_api.gemspec @@ -24,4 +24,14 @@ Gem::Specification.new do |gem| gem.add_dependency 'responders' gem.add_dependency 'jbuilder', '~> 2.6' gem.add_dependency 'kaminari', '>= 0.17', '< 2.0' + + gem.add_development_dependency 'timecop' + gem.add_development_dependency 'database_cleaner', '~> 1.3' + gem.add_development_dependency 'factory_bot', '~> 4.8' + gem.add_development_dependency 'rails-controller-testing' + gem.add_development_dependency 'rspec-activemodel-mocks', '~> 1.0.2' + gem.add_development_dependency 'rspec-rails', '~> 3.6.0' + gem.add_development_dependency 'rspec_junit_formatter' + gem.add_development_dependency 'simplecov' + gem.add_development_dependency 'with_model' end diff --git a/api/spec/requests/spree/api/shipments_controller_spec.rb b/api/spec/requests/spree/api/shipments_controller_spec.rb index cca3f196f69..03533a3935c 100644 --- a/api/spec/requests/spree/api/shipments_controller_spec.rb +++ b/api/spec/requests/spree/api/shipments_controller_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require 'timecop' describe Spree::Api::ShipmentsController, type: :request do let!(:shipment) { create(:shipment, inventory_units: [build(:inventory_unit, shipment: nil)]) } diff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rb index 92441edc507..4f70ccfe01e 100644 --- a/api/spec/spec_helper.rb +++ b/api/spec/spec_helper.rb @@ -18,12 +18,17 @@ require 'spree/testing_support/dummy_app' DummyApp::Migrations.auto_migrate +require 'rails-controller-testing' require 'rspec/rails' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f } +require 'with_model' +require 'database_cleaner' +require 'rspec-activemodel-mocks' + require 'spree/testing_support/factories' require 'spree/testing_support/preferences' require 'spree/testing_support/authorization_helpers' diff --git a/backend/solidus_backend.gemspec b/backend/solidus_backend.gemspec index 432d6199d54..1e981f9e032 100644 --- a/backend/solidus_backend.gemspec +++ b/backend/solidus_backend.gemspec @@ -34,4 +34,16 @@ Gem::Specification.new do |s| s.add_dependency 'handlebars_assets', '~> 0.23' s.add_dependency 'autoprefixer-rails', '~> 7.1' + + s.add_development_dependency 'capybara', '~> 2.15' + s.add_development_dependency 'capybara-screenshot', '>= 1.0.18' + s.add_development_dependency 'database_cleaner', '~> 1.3' + s.add_development_dependency 'factory_bot', '~> 4.8' + s.add_development_dependency 'rails-controller-testing' + s.add_development_dependency 'rspec-activemodel-mocks', '~> 1.0.2' + s.add_development_dependency 'rspec-rails', '~> 3.6.0' + s.add_development_dependency 'rspec_junit_formatter' + s.add_development_dependency 'selenium-webdriver' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'with_model' end diff --git a/backend/spec/spec_helper.rb b/backend/spec/spec_helper.rb index cd8a66209af..998da759733 100644 --- a/backend/spec/spec_helper.rb +++ b/backend/spec/spec_helper.rb @@ -29,6 +29,7 @@ require 'database_cleaner' require 'with_model' +require 'rspec-activemodel-mocks' require 'spree/testing_support/authorization_helpers' require 'spree/testing_support/factories' diff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rb index 6e261715b99..b6f1fb69cf3 100644 --- a/common_spree_dependencies.rb +++ b/common_spree_dependencies.rb @@ -15,26 +15,6 @@ gem 'activerecord-jdbcsqlite3-adapter' end -gem 'coffee-rails' -gem 'sass-rails' - -group :test do - gem 'capybara', '~> 2.15' - gem 'capybara-screenshot', '>= 1.0.18' - gem 'database_cleaner', '~> 1.3' - gem 'factory_bot_rails', '~> 4.8' - gem 'launchy' - gem 'rspec-activemodel-mocks', '~>1.0.2' - gem 'rspec-rails', '~> 3.6.0' - gem 'simplecov' - gem 'poltergeist', '~> 1.9' - gem 'timecop' - gem 'with_model' - gem 'rspec_junit_formatter' - gem 'rails-controller-testing' - gem 'selenium-webdriver' -end - group :test, :development do gem 'rubocop' gem 'pry' diff --git a/core/solidus_core.gemspec b/core/solidus_core.gemspec index 29f4c231110..b1116256f69 100644 --- a/core/solidus_core.gemspec +++ b/core/solidus_core.gemspec @@ -39,4 +39,13 @@ Gem::Specification.new do |s| s.add_dependency 'ransack', '~> 1.8' s.add_dependency 'state_machines-activerecord', '~> 0.4' s.add_dependency 'stringex', '~> 1.5.1' + + s.add_development_dependency 'database_cleaner', '~> 1.3' + s.add_development_dependency 'factory_bot', '~> 4.8' + s.add_development_dependency 'rspec-activemodel-mocks', '~>1.0.2' + s.add_development_dependency 'rspec-rails', '~> 3.6.0' + s.add_development_dependency 'rspec_junit_formatter' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'timecop' + s.add_development_dependency 'with_model' end diff --git a/frontend/solidus_frontend.gemspec b/frontend/solidus_frontend.gemspec index 666a0c3bca6..6ad1beba859 100644 --- a/frontend/solidus_frontend.gemspec +++ b/frontend/solidus_frontend.gemspec @@ -31,5 +31,15 @@ Gem::Specification.new do |s| s.add_dependency 'truncate_html', '~> 0.9', '>= 0.9.2' s.add_dependency 'kaminari', '>= 0.17', '< 2.0' + s.add_development_dependency 'capybara', '~> 2.15' s.add_development_dependency 'capybara-accessible' + s.add_development_dependency 'capybara-screenshot', '>= 1.0.18' + s.add_development_dependency 'database_cleaner', '~> 1.3' + s.add_development_dependency 'factory_bot', '~> 4.8' + s.add_development_dependency 'poltergeist', '~> 1.9' + s.add_development_dependency 'rails-controller-testing' + s.add_development_dependency 'rspec-activemodel-mocks', '~> 1.0.2' + s.add_development_dependency 'rspec-rails', '~> 3.6.0' + s.add_development_dependency 'rspec_junit_formatter' + s.add_development_dependency 'simplecov' end diff --git a/frontend/spec/spec_helper.rb b/frontend/spec/spec_helper.rb index e29097e2f49..00a81a059d8 100644 --- a/frontend/spec/spec_helper.rb +++ b/frontend/spec/spec_helper.rb @@ -20,6 +20,7 @@ require 'spree/testing_support/dummy_app' DummyApp::Migrations.auto_migrate +require 'rails-controller-testing' require 'rspec/rails' # Requires supporting files with custom matchers and macros, etc, @@ -27,6 +28,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } require 'database_cleaner' +require 'rspec-activemodel-mocks' require 'spree/testing_support/authorization_helpers' require 'spree/testing_support/capybara_ext' diff --git a/sample/solidus_sample.gemspec b/sample/solidus_sample.gemspec index 78157638d60..b9666ea065b 100644 --- a/sample/solidus_sample.gemspec +++ b/sample/solidus_sample.gemspec @@ -21,4 +21,9 @@ Gem::Specification.new do |s| s.required_rubygems_version = '>= 1.8.23' s.add_dependency 'solidus_core', s.version + + s.add_development_dependency 'database_cleaner', '~> 1.3' + s.add_development_dependency 'rspec-rails', '~> 3.6.0' + s.add_development_dependency 'rspec_junit_formatter' + s.add_development_dependency 'simplecov' end diff --git a/sample/spec/spec_helper.rb b/sample/spec/spec_helper.rb index 1068239cce4..b18e16e6d0c 100644 --- a/sample/spec/spec_helper.rb +++ b/sample/spec/spec_helper.rb @@ -9,6 +9,8 @@ require 'rspec/rails' +require 'database_cleaner' + RSpec.configure do |config| config.color = true config.infer_spec_type_from_file_location! From ef36238c7a35e127adfcd40cd257f5491041a2c7 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 6 Nov 2017 16:05:42 -0800 Subject: [PATCH 4/5] Remove listen from common_spree_dependencies We aren't going to be running in dev mode from within the Solidus project itself, so we don't need listen for code reloading. --- common_spree_dependencies.rb | 1 - core/lib/spree/testing_support/dummy_app/rake_tasks.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rb index b6f1fb69cf3..37b5205a343 100644 --- a/common_spree_dependencies.rb +++ b/common_spree_dependencies.rb @@ -18,7 +18,6 @@ group :test, :development do gem 'rubocop' gem 'pry' - gem 'listen', '~> 3.1.5' platforms :mri do gem 'byebug' diff --git a/core/lib/spree/testing_support/dummy_app/rake_tasks.rb b/core/lib/spree/testing_support/dummy_app/rake_tasks.rb index 729cf339a84..4610772d5d4 100644 --- a/core/lib/spree/testing_support/dummy_app/rake_tasks.rb +++ b/core/lib/spree/testing_support/dummy_app/rake_tasks.rb @@ -40,6 +40,7 @@ rescue LoadError end + require 'rails/command' require 'rails/commands/console/console_command' Rails::Console.new(Rails.application, sandbox: true, environment: "test").start end From a93c9aec1cbd2ae7a09cc26f7ead2f9de4a5e747 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 6 Nov 2017 16:06:36 -0800 Subject: [PATCH 5/5] Avoid requiring rubocop It will be required when running the rubocop executable. --- common_spree_dependencies.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rb index 37b5205a343..d934c241d24 100644 --- a/common_spree_dependencies.rb +++ b/common_spree_dependencies.rb @@ -16,7 +16,7 @@ end group :test, :development do - gem 'rubocop' + gem 'rubocop', require: false gem 'pry' platforms :mri do