summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2020-07-07 16:50:59 -0700
committerGitHub <noreply@github.com>2020-07-07 16:50:59 -0700
commit15e30c62c721bd6f5e17dcd3d2f610f4b164269c (patch)
treed3f843c86420e758bb11f64f255a1f923072393d
parent4eefcea9f2c70a8a3075b60cec2046fe2d40bde3 (diff)
parentdef4803b461559a3420912f63d83fa6e4bf3ecfe (diff)
Merge pull request #21 from SuperGoodSoft/solidus_dev_support_support
solidus_dev_support-support
-rw-r--r--.gitignore32
-rw-r--r--.travis.yml11
-rw-r--r--CHANGELOG.md2
-rw-r--r--Gemfile26
-rw-r--r--LICENSE26
-rw-r--r--LICENSE.txt21
-rw-r--r--Rakefile21
-rwxr-xr-xbin/rails7
-rwxr-xr-xbin/rails-engine13
-rwxr-xr-xbin/rails-sandbox16
-rwxr-xr-xbin/rake7
-rwxr-xr-xbin/sandbox84
-rw-r--r--lib/super_good-solidus_taxjar.rb1
-rw-r--r--spec/spec_helper.rb46
-rw-r--r--super_good-solidus_taxjar.gemspec31
15 files changed, 237 insertions, 107 deletions
diff --git a/.gitignore b/.gitignore
index 94ec22c..325c3c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,20 @@
-/.bundle/
-/.yardoc
-/_yardoc/
-/coverage/
-/doc/
-/pkg/
-/spec/reports/
-/tmp/
-
-# rspec failure tracking
-.rspec_status
-
+*.gem
+\#*
+*~
+.#*
+.DS_Store
+.idea
+.project
+.sass-cache
+coverage
Gemfile.lock
-/spec/dummy
+tmp
+nbproject
+pkg
+*.swp
+spec/dummy
+spec/examples.txt
+/sandbox
+.rvmrc
+.ruby-version
+.ruby-gemset
diff --git a/.travis.yml b/.travis.yml
index 4598c2e..c4ebfce 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,11 +3,12 @@ dist: trusty
sudo: false
language: ruby
cache: bundler
-rvm:
- - 2.3.7
-env:
- matrix:
- - SOLIDUS_BRANCH=v2.4 DB=postgres RAILS_VERSION="~> 5.1.0"
+jobs:
+ include:
+ - rvm: 2.5.8
+ env: SOLIDUS_BRANCH=v2.9 DB=postgresql RAILS_VERSION="~> 5.1.0"
+ - rvm: 2.6.6
+ env: SOLIDUS_BRANCH=v2.10 DB=postgresql RAILS_VERSION="~> 5.2.0"
before_install:
- gem update --system
- gem install bundler
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c78ad7b..50e844b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## master
+- Migrated project to `solidus_dev_support`
+
## v0.17.1
- Fixed bug where shipping calculator was not used for order shipping param. (Thanks @spaghetticode!)
diff --git a/Gemfile b/Gemfile
index b1849de..6be78e4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,12 +6,21 @@ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch
-if ENV['RAILS_VERSION']
- gem "rails", ENV['RAILS_VERSON']
-end
+# Needed to help Bundler figure out how to resolve dependencies,
+# otherwise it takes forever to resolve them.
+# See https://github.com/bundler/bundler/issues/6677
+gem "rails", ENV.fetch("RAILS_VERSION") { ">0.a" }
+
+# Provides basic authentication functionality for testing parts of your engine
+gem "solidus_auth_devise"
-if ENV.fetch('DB') == 'postgres'
- gem 'pg'
+case ENV["DB"]
+when "mysql"
+ gem "mysql2"
+when "postgresql"
+ gem "pg"
+else
+ gem "sqlite3"
end
group :development, :test do
@@ -19,3 +28,10 @@ group :development, :test do
end
gemspec
+
+# Use a local Gemfile to include development dependencies that might not be
+# relevant for the project or for other contributors, e.g. pry-byebug.
+#
+# We use `send` instead of calling `eval_gemfile` to work around an issue with
+# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
+send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d8bdc9a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2020 Super Good Software, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name Solidus nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE.txt b/LICENSE.txt
deleted file mode 100644
index f850b77..0000000
--- a/LICENSE.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2018 Jared Norman
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/Rakefile b/Rakefile
index 560b892..c08aa46 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,19 +1,6 @@
-require "bundler/gem_tasks"
-require "rspec/core/rake_task"
-require 'spree/testing_support/extension_rake'
+# frozen_string_literal: true
-RSpec::Core::RakeTask.new(:spec)
+require 'solidus_dev_support/rake_tasks'
+SolidusDevSupport::RakeTasks.install
-task :default do
- if Dir["spec/dummy"].empty?
- Rake::Task[:test_app].invoke
- Dir.chdir("../../")
- end
- Rake::Task[:spec].invoke
-end
-
-desc 'Generates a dummy app for testing'
-task :test_app do
- ENV['LIB_NAME'] = 'super_good/solidus_taxjar'
- Rake::Task['extension:test_app'].invoke
-end
+task default: 'extension:specs'
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 0000000..6dbbbc3
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+if %w[g generate].include? ARGV.first
+ exec "#{__dir__}/rails-engine", *ARGV
+else
+ exec "#{__dir__}/rails-sandbox", *ARGV
+end
diff --git a/bin/rails-engine b/bin/rails-engine
new file mode 100755
index 0000000..3684b30
--- /dev/null
+++ b/bin/rails-engine
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails gems
+# installed from the root of your application.
+
+ENGINE_ROOT = File.expand_path('..', __dir__)
+ENGINE_PATH = File.expand_path('../lib/solidus_taxjar/engine', __dir__)
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
+
+require 'rails/all'
+require 'rails/engine/commands'
diff --git a/bin/rails-sandbox b/bin/rails-sandbox
new file mode 100755
index 0000000..c89b2ae
--- /dev/null
+++ b/bin/rails-sandbox
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+
+app_root = 'sandbox'
+
+unless File.exist? "#{app_root}/bin/rails"
+ warn 'Creating the sandbox app...'
+ Dir.chdir "#{__dir__}/.." do
+ system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
+ warn 'Automatic creation of the sandbox app failed'
+ exit 1
+ end
+ end
+end
+
+Dir.chdir app_root
+exec 'bin/rails', *ARGV
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 0000000..1e6eacd
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rake", "rake")
diff --git a/bin/sandbox b/bin/sandbox
new file mode 100755
index 0000000..ca0fa22
--- /dev/null
+++ b/bin/sandbox
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+
+set -e
+
+case "$DB" in
+postgres|postgresql)
+ RAILSDB="postgresql"
+ ;;
+mysql)
+ RAILSDB="mysql"
+ ;;
+sqlite|'')
+ RAILSDB="sqlite3"
+ ;;
+*)
+ echo "Invalid DB specified: $DB"
+ exit 1
+ ;;
+esac
+
+if [ ! -z $SOLIDUS_BRANCH ]
+then
+ BRANCH=$SOLIDUS_BRANCH
+else
+ BRANCH="master"
+fi
+
+extension_name="solidus_taxjar"
+
+# Stay away from the bundler env of the containing extension.
+function unbundled {
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
+}
+
+rm -rf ./sandbox
+unbundled bundle exec rails new sandbox --database="$RAILSDB" \
+ --skip-bundle \
+ --skip-git \
+ --skip-keeps \
+ --skip-rc \
+ --skip-spring \
+ --skip-test \
+ --skip-javascript
+
+if [ ! -d "sandbox" ]; then
+ echo 'sandbox rails application failed'
+ exit 1
+fi
+
+cd ./sandbox
+cat <<RUBY >> Gemfile
+gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
+gem 'solidus_auth_devise', '>= 2.1.0'
+gem 'rails-i18n'
+gem 'solidus_i18n'
+
+gem '$extension_name', path: '..'
+
+group :test, :development do
+ platforms :mri do
+ gem 'pry-byebug'
+ end
+end
+RUBY
+
+unbundled bundle install --gemfile Gemfile
+
+unbundled bundle exec rake db:drop db:create
+
+unbundled bundle exec rails generate spree:install \
+ --auto-accept \
+ --user_class=Spree::User \
+ --enforce_available_locales=true \
+ --with-authentication=false \
+ $@
+
+unbundled bundle exec rails generate solidus:auth:install
+
+echo
+echo "🚀 Sandbox app successfully created for $extension_name!"
+echo "🚀 Using $RAILSDB and Solidus $BRANCH"
+echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
+echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
+echo "🚀 This app is intended for test purposes."
diff --git a/lib/super_good-solidus_taxjar.rb b/lib/super_good-solidus_taxjar.rb
new file mode 100644
index 0000000..e41f8a4
--- /dev/null
+++ b/lib/super_good-solidus_taxjar.rb
@@ -0,0 +1 @@
+require 'super_good/solidus_taxjar'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d79d49a..e55b5c5 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,38 +1,20 @@
-ENV['RAILS_ENV'] ||= 'test'
+# frozen_string_literal: true
-require "bundler/setup"
-require "database_cleaner"
+# Configure Rails Environment
+ENV['RAILS_ENV'] = 'test'
-begin
- require File.expand_path('../dummy/config/environment', __FILE__)
-rescue LoadError
- puts 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'
- exit
-end
-
-RSpec.configure do |config|
- config.expect_with :rspec do |c|
- c.syntax = :expect
- end
+require File.expand_path('dummy/config/environment.rb', __dir__).tap { |file|
+ # Create the dummy app if it's still missing.
+ system 'bin/rake extension:test_app' unless File.exist? file
+}
- config.disable_monkey_patching!
- config.filter_run :focus
- config.run_all_when_everything_filtered = true
- config.default_formatter = 'doc' if config.files_to_run.one?
+require 'solidus_dev_support/rspec/rails_helper'
- config.order = "random"
- Kernel.srand config.seed
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
- config.before :suite do
- DatabaseCleaner.strategy = :transaction
- end
-
- config.before :each do
- DatabaseCleaner.start
- end
-
- # After each spec clean the database.
- config.after :each do
- DatabaseCleaner.clean
- end
+RSpec.configure do |config|
+ config.infer_spec_type_from_file_location!
+ config.use_transactional_fixtures = false
end
diff --git a/super_good-solidus_taxjar.gemspec b/super_good-solidus_taxjar.gemspec
index a5bbed6..d54cd91 100644
--- a/super_good-solidus_taxjar.gemspec
+++ b/super_good-solidus_taxjar.gemspec
@@ -3,31 +3,34 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "super_good/solidus_taxjar/version"
Gem::Specification.new do |spec|
- spec.name = "super_good-solidus_taxjar"
- spec.version = SuperGood::SolidusTaxJar::VERSION
- spec.authors = ["Jared Norman"]
- spec.email = ["jared@super.gd"]
+ spec.name = "super_good-solidus_taxjar"
+ spec.version = SuperGood::SolidusTaxJar::VERSION
+ spec.authors = ["Jared Norman"]
+ spec.email = ["jared@super.gd"]
- spec.summary = "Support for using TaxJar to handle tax calculations in Solidus"
- spec.description = spec.summary
- spec.homepage = "https://github.com/SuperGoodSoft/solidus_taxjar"
- spec.license = "MIT"
+ spec.summary = "Support for using TaxJar to handle tax calculations in Solidus"
+ spec.description = spec.summary
+ spec.homepage = "https://github.com/SuperGoodSoft/solidus_taxjar"
+ spec.license = 'BSD-3-Clause'
+
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
+
+ spec.files = files.grep_v(%r{^(test|spec|features)/})
+ spec.test_files = files.grep(%r{^(test|spec|features)/})
+ spec.bindir = "exe"
+ spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "solidus_core", ">= 2.4.0"
spec.add_dependency "solidus_support"
spec.add_dependency "taxjar-ruby"
+ spec.add_development_dependency "solidus_dev_support"
spec.add_development_dependency "bundler"
- spec.add_development_dependency "database_cleaner"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rspec-rails"