solidus_support 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +35 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +2 -8
- data/Gemfile +13 -1
- data/README.md +21 -45
- data/Rakefile +2 -0
- data/lib/solidus_support.rb +3 -0
- data/lib/solidus_support/engine_extensions.rb +3 -0
- data/lib/solidus_support/engine_extensions/decorators.rb +37 -0
- data/lib/solidus_support/migration.rb +2 -0
- data/lib/solidus_support/version.rb +3 -1
- data/solidus_support.gemspec +4 -6
- data/spec/solidus_support_spec.rb +8 -4
- data/spec/spec_helper.rb +3 -1
- data/spec/support/dummy_app.rb +2 -0
- data/spec/support/dummy_app/database.yml +12 -0
- metadata +19 -35
- data/lib/solidus_support/extension/coverage.rb +0 -16
- data/lib/solidus_support/extension/feature_helper.rb +0 -44
- data/lib/solidus_support/extension/rails_helper.rb +0 -45
- data/lib/solidus_support/extension/spec_helper.rb +0 -19
- data/lib/solidus_support/testing_support/preferences.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06f44b07249f357975f818d24cd533b0e4419c957c1608c6dfd398956176a456
|
4
|
+
data.tar.gz: 7a5c3c693cb6a9c0d36a056bbab25338c54a756a4a2f745a997a3ae1f1a221cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa4396cf0f842d9c14a3a846cb6e49b053eeaebbfc43d7f6f9b42523054f0d1574eaaa8756a433d2c62902fed6b8ac0539bcb4a6da87d4671285d2db87fff866
|
7
|
+
data.tar.gz: 2674c879410db8025d8dba10e961598c7bc28b7b17e8bb6d771ece89ae280aad1c257acb948c5ee6c0c810e9574874529c66c3563968bcefc15dc54c5e3162e1
|
@@ -0,0 +1,35 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
# Always take the latest version of the orb, this allows us to
|
5
|
+
# run specs against Solidus supported versions only without the need
|
6
|
+
# to change this configuration every time a Solidus version is released
|
7
|
+
# or goes EOL.
|
8
|
+
solidusio_extensions: solidusio/extensions@volatile
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
run-specs-with-postgres:
|
12
|
+
executor: solidusio_extensions/postgres
|
13
|
+
steps:
|
14
|
+
- solidusio_extensions/run-tests
|
15
|
+
run-specs-with-mysql:
|
16
|
+
executor: solidusio_extensions/mysql
|
17
|
+
steps:
|
18
|
+
- solidusio_extensions/run-tests
|
19
|
+
|
20
|
+
workflows:
|
21
|
+
"Run specs on supported Solidus versions":
|
22
|
+
jobs:
|
23
|
+
- run-specs-with-postgres
|
24
|
+
- run-specs-with-mysql
|
25
|
+
"Weekly run specs against master":
|
26
|
+
triggers:
|
27
|
+
- schedule:
|
28
|
+
cron: "0 0 * * 4" # every Thursday
|
29
|
+
filters:
|
30
|
+
branches:
|
31
|
+
only:
|
32
|
+
- master
|
33
|
+
jobs:
|
34
|
+
- run-specs-with-postgres
|
35
|
+
- run-specs-with-mysql
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
@@ -6,5 +8,15 @@ gem 'solidus_core', github: 'solidusio/solidus', branch: branch
|
|
6
8
|
# Specify your gem's dependencies in solidus_support.gemspec
|
7
9
|
gemspec
|
8
10
|
|
11
|
+
gem 'solidus_extension_dev_tools', github: 'solidusio-contrib/solidus_extension_dev_tools'
|
12
|
+
gem 'sprockets', '~> 3'
|
9
13
|
gem 'sprockets-rails'
|
10
|
-
|
14
|
+
|
15
|
+
case ENV['DB']
|
16
|
+
when 'postgresql'
|
17
|
+
gem 'pg'
|
18
|
+
when 'mysql'
|
19
|
+
gem 'mysql2'
|
20
|
+
else
|
21
|
+
gem 'sqlite3'
|
22
|
+
end
|
data/README.md
CHANGED
@@ -24,62 +24,38 @@ SolidusSupport::Migration[5.0] # same as `ActiveRecord::Migration[5.0]`
|
|
24
24
|
|
25
25
|
There's no reason to use `SolidusSupport::Migration[5.0]` over `ActiveRecord::Migration[5.0]`, but it is provided.
|
26
26
|
|
27
|
-
###
|
27
|
+
### Engine Extensions
|
28
28
|
|
29
|
-
This
|
30
|
-
|
29
|
+
This extension provides a module that extends `Rails::Engine` functionalities
|
30
|
+
to support loading correctly the decorators class created into an extension
|
31
|
+
both for development and production enviroments.
|
31
32
|
|
32
|
-
|
33
|
+
To use it just include the provided module in the Engine as follow:
|
33
34
|
|
34
35
|
```ruby
|
35
|
-
|
36
|
+
module SolidusExtensionName
|
37
|
+
class Engine < Rails::Engine
|
38
|
+
engine_name 'solidus_extension_name'
|
39
|
+
|
40
|
+
include SolidusSupport::EngineExtensions::Decorators
|
41
|
+
# ...
|
42
|
+
end
|
43
|
+
end
|
36
44
|
```
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
to precompile assets before the first feature spec.
|
41
|
-
|
42
|
-
This helper requires the `rails_helper`, also provided by this gem and
|
43
|
-
requireable as a stand-alone helper.
|
44
|
-
|
45
|
-
By doing:
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
require "solidus_support/extension/rails_helper"
|
49
|
-
```
|
50
|
-
|
51
|
-
extension's test suite will have all Rails related tests configuration,
|
52
|
-
like authorization helpers, Solidus core factories, url helpers, and
|
53
|
-
other helpers to easily work with Solidus Config.
|
54
|
-
|
55
|
-
This `rails_helper` in turn requires the basic `spec_helper`, which is
|
56
|
-
responsible to load a basic RSpec configuration, which could be needed
|
57
|
-
in all extensions. It is also requireable as a stand-alone helper with:
|
46
|
+
To make it work, be sure to remove the previous implementation from the
|
47
|
+
Engine, that should be something like:
|
58
48
|
|
59
49
|
```ruby
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
50
|
+
def self.activate
|
51
|
+
Dir.glob(File.join(root, "app/**/*_decorator*.rb")) do |c|
|
52
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
53
|
+
end
|
54
|
+
end
|
64
55
|
|
65
|
-
|
66
|
-
coverage information directly to Codecov.io. Simply add this at the top
|
67
|
-
of your `spec/spec_helper.rb`:
|
68
|
-
|
69
|
-
```ruby
|
70
|
-
require "solidus_support/extension/coverage"
|
56
|
+
config.to_prepare(&method(:activate).to_proc)
|
71
57
|
```
|
72
58
|
|
73
|
-
**Note: Make sure to add this at the VERY TOP of your spec_helper,
|
74
|
-
otherwise you'll get skewed coverage reports!**
|
75
|
-
|
76
|
-
If your extension is in a public repo and being tested on Travis or
|
77
|
-
CircleCI, there's nothing else you need to do - you'll get coverage
|
78
|
-
reports for free!
|
79
|
-
|
80
|
-
If your setup is more complex, look at the [SimpleCov](https://github.com/colszowka/simplecov)
|
81
|
-
and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs.
|
82
|
-
|
83
59
|
## Development
|
84
60
|
|
85
61
|
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.
|
data/Rakefile
CHANGED
data/lib/solidus_support.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusSupport
|
4
|
+
module EngineExtensions
|
5
|
+
module Decorators
|
6
|
+
def self.included(engine)
|
7
|
+
engine.class_eval do
|
8
|
+
extend ClassMethods
|
9
|
+
config.to_prepare(&method(:activate).to_proc)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def activate
|
15
|
+
base_path = root.join('app/decorators')
|
16
|
+
|
17
|
+
if Rails.respond_to?(:autoloaders)
|
18
|
+
# Add decorators folder to the Rails autoloader. This
|
19
|
+
# allows Zeitwerk to resolve decorators paths correctly,
|
20
|
+
# when used.
|
21
|
+
Dir.glob(base_path.join('*')) do |decorators_folder|
|
22
|
+
Rails.autoloaders.main.push_dir(decorators_folder)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Load decorator files. This is needed since they are
|
27
|
+
# never explicitely referenced in the application code
|
28
|
+
# and won't be loaded by default. We need them to be
|
29
|
+
# executed anyway to extend exisiting classes.
|
30
|
+
Dir.glob(base_path.join('**/*.rb')) do |decorator_path|
|
31
|
+
Rails.configuration.cache_classes ? require(decorator_path) : load(decorator_path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/solidus_support.gemspec
CHANGED
@@ -17,13 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_development_dependency 'bundler'
|
21
|
-
spec.add_development_dependency 'rake'
|
22
|
-
spec.add_development_dependency 'rspec-rails'
|
20
|
+
spec.add_development_dependency 'bundler'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec-rails'
|
23
23
|
spec.add_development_dependency 'rubocop'
|
24
24
|
spec.add_development_dependency 'rubocop-rspec'
|
25
25
|
spec.add_development_dependency 'solidus_core'
|
26
|
-
|
27
|
-
spec.add_dependency 'capybara-screenshot'
|
28
|
-
spec.add_dependency 'codecov'
|
26
|
+
spec.add_development_dependency 'solidus_extension_dev_tools'
|
29
27
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe SolidusSupport do
|
2
4
|
describe '.payment_method_parent_class' do
|
3
5
|
subject { described_class.payment_method_parent_class(credit_card: credit_card) }
|
@@ -10,32 +12,34 @@ RSpec.describe SolidusSupport do
|
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
|
-
context '
|
15
|
+
context 'with Solidus < 2.3' do
|
14
16
|
let(:solidus_version) { '2.2.1' }
|
15
17
|
|
16
18
|
it { is_expected.to eq(Spree::Gateway) }
|
17
19
|
end
|
18
20
|
|
19
|
-
context '
|
21
|
+
context 'with Solidus >= 2.3' do
|
20
22
|
let(:solidus_version) { '2.3.1' }
|
21
23
|
|
22
24
|
it { is_expected.to eq(Spree::PaymentMethod) }
|
23
25
|
end
|
24
26
|
|
27
|
+
# rubocop:disable RSpec/NestedGroups
|
25
28
|
context 'with credit_card: true' do
|
26
29
|
let(:credit_card) { true }
|
27
30
|
|
28
|
-
context '
|
31
|
+
context 'with Solidus < 2.3' do
|
29
32
|
let(:solidus_version) { '2.2.1' }
|
30
33
|
|
31
34
|
it { is_expected.to eq(Spree::Gateway) }
|
32
35
|
end
|
33
36
|
|
34
|
-
context '
|
37
|
+
context 'with Solidus >= 2.3' do
|
35
38
|
let(:solidus_version) { '2.3.1' }
|
36
39
|
|
37
40
|
it { is_expected.to eq(Spree::PaymentMethod::CreditCard) }
|
38
41
|
end
|
39
42
|
end
|
43
|
+
# rubocop:enable RSpec/NestedGroups
|
40
44
|
end
|
41
45
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/dummy_app.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
+
<% if ENV['DB'] == 'postgresql' %>
|
2
|
+
test:
|
3
|
+
adapter: postgresql
|
4
|
+
database: circle_test
|
5
|
+
username: root
|
6
|
+
<% elsif ENV['DB'] == 'mysql' %>
|
7
|
+
test:
|
8
|
+
adapter: mysql2
|
9
|
+
database: circle_test
|
10
|
+
username: root
|
11
|
+
<% else %>
|
1
12
|
test:
|
2
13
|
adapter: sqlite3
|
3
14
|
database: ':memory:'
|
4
15
|
timeout: 10000
|
16
|
+
<% end %>
|
metadata
CHANGED
@@ -1,59 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec-rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.7'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.7'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -67,7 +53,7 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop
|
56
|
+
name: rubocop
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: rubocop-rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
@@ -95,13 +81,13 @@ dependencies:
|
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: solidus_core
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
89
|
version: '0'
|
104
|
-
type: :
|
90
|
+
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
@@ -109,13 +95,13 @@ dependencies:
|
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: solidus_extension_dev_tools
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
|
-
type: :
|
104
|
+
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
@@ -129,6 +115,7 @@ executables: []
|
|
129
115
|
extensions: []
|
130
116
|
extra_rdoc_files: []
|
131
117
|
files:
|
118
|
+
- ".circleci/config.yml"
|
132
119
|
- ".gitignore"
|
133
120
|
- ".rspec"
|
134
121
|
- ".rubocop.yml"
|
@@ -137,12 +124,9 @@ files:
|
|
137
124
|
- README.md
|
138
125
|
- Rakefile
|
139
126
|
- lib/solidus_support.rb
|
140
|
-
- lib/solidus_support/
|
141
|
-
- lib/solidus_support/
|
142
|
-
- lib/solidus_support/extension/rails_helper.rb
|
143
|
-
- lib/solidus_support/extension/spec_helper.rb
|
127
|
+
- lib/solidus_support/engine_extensions.rb
|
128
|
+
- lib/solidus_support/engine_extensions/decorators.rb
|
144
129
|
- lib/solidus_support/migration.rb
|
145
|
-
- lib/solidus_support/testing_support/preferences.rb
|
146
130
|
- lib/solidus_support/version.rb
|
147
131
|
- solidus_support.gemspec
|
148
132
|
- spec/solidus_support_spec.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# A SimpleCov and Codecov configuration to track code coverage in your extension
|
2
|
-
#
|
3
|
-
# Include it AT THE TOP of your spec/spec_helper.rb:
|
4
|
-
#
|
5
|
-
# require 'solidus_support/extension/coverage'
|
6
|
-
#
|
7
|
-
# Note that things may not work properly if you don't include this at the very top!
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start 'rails'
|
12
|
-
|
13
|
-
if ENV['CI']
|
14
|
-
require 'codecov'
|
15
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
16
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# A basic feature_helper to be included as the starting point for extensions
|
2
|
-
#
|
3
|
-
# Can be required from an extension's spec/feature_helper.rb
|
4
|
-
#
|
5
|
-
# require 'solidus_support/extension/feature_helper'
|
6
|
-
#
|
7
|
-
|
8
|
-
require 'solidus_support/extension/rails_helper'
|
9
|
-
|
10
|
-
require 'capybara-screenshot/rspec'
|
11
|
-
require 'selenium/webdriver'
|
12
|
-
|
13
|
-
Capybara.register_driver :selenium_chrome_headless do |app|
|
14
|
-
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
15
|
-
chromeOptions: { args: %w[headless start-maximized] }
|
16
|
-
)
|
17
|
-
|
18
|
-
Capybara::Selenium::Driver.new(
|
19
|
-
app,
|
20
|
-
browser: :chrome,
|
21
|
-
desired_capabilities: capabilities
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
|
26
|
-
Capybara.default_max_wait_time = 10
|
27
|
-
|
28
|
-
require 'spree/testing_support/capybara_ext'
|
29
|
-
|
30
|
-
RSpec.configure do |config|
|
31
|
-
config.when_first_matching_example_defined(type: :feature) do
|
32
|
-
config.before :suite do
|
33
|
-
# Preload assets
|
34
|
-
if Rails.application.respond_to?(:precompiled_assets)
|
35
|
-
Rails.application.precompiled_assets
|
36
|
-
else
|
37
|
-
# For older sprockets 2.x
|
38
|
-
Rails.application.config.assets.precompile.each do |asset|
|
39
|
-
Rails.application.assets.find_asset(asset)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# A basic rails_helper to be included as the starting point for extensions
|
2
|
-
#
|
3
|
-
# Can be required from an extension's spec/rails_helper.rb
|
4
|
-
#
|
5
|
-
# require 'solidus_support/extension/rails_helper'
|
6
|
-
#
|
7
|
-
|
8
|
-
require 'solidus_support/extension/spec_helper'
|
9
|
-
|
10
|
-
require 'rspec/rails'
|
11
|
-
require 'database_cleaner'
|
12
|
-
require 'ffaker'
|
13
|
-
|
14
|
-
require 'spree/testing_support/authorization_helpers'
|
15
|
-
require 'spree/testing_support/factories'
|
16
|
-
require 'spree/testing_support/url_helpers'
|
17
|
-
require 'spree/testing_support/preferences'
|
18
|
-
require 'solidus_support/testing_support/preferences'
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
config.include FactoryBot::Syntax::Methods
|
22
|
-
|
23
|
-
# visit spree.admin_path
|
24
|
-
# current_path.should eql(spree.products_path)
|
25
|
-
config.include Spree::TestingSupport::UrlHelpers
|
26
|
-
|
27
|
-
config.include Spree::TestingSupport::Preferences
|
28
|
-
config.include SolidusSupport::TestingSupport::Preferences
|
29
|
-
|
30
|
-
config.before :suite do
|
31
|
-
DatabaseCleaner.clean_with :truncation
|
32
|
-
end
|
33
|
-
|
34
|
-
# Around each spec check if it is a Javascript test and switch between using
|
35
|
-
# database transactions or not where necessary.
|
36
|
-
config.around(:each) do |example|
|
37
|
-
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
38
|
-
|
39
|
-
DatabaseCleaner.cleaning do
|
40
|
-
reset_spree_preferences unless SolidusSupport.reset_spree_preferences_deprecated?
|
41
|
-
|
42
|
-
example.run
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# A basic spec_helper to be included as the starting point for extensions
|
2
|
-
#
|
3
|
-
# Can be required from an extension's spec/spec_helper.rb
|
4
|
-
#
|
5
|
-
# require 'solidus_support/extension/spec_helper'
|
6
|
-
#
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.filter_run focus: true
|
10
|
-
config.run_all_when_everything_filtered = true
|
11
|
-
|
12
|
-
config.mock_with :rspec
|
13
|
-
config.color = true
|
14
|
-
|
15
|
-
config.fail_fast = ENV['FAIL_FAST'] || false
|
16
|
-
config.order = 'random'
|
17
|
-
|
18
|
-
Kernel.srand config.seed
|
19
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidusSupport
|
4
|
-
module TestingSupport
|
5
|
-
module Preferences
|
6
|
-
# This wrapper method allows to stub spree preferences using
|
7
|
-
# the new standard way of solidus core but also works with
|
8
|
-
# old versions that does not have the stub_spree_preferences
|
9
|
-
# method yet. This way we can start using this method in our
|
10
|
-
# extensions safely.
|
11
|
-
#
|
12
|
-
# To have this available, it is needed to require in the
|
13
|
-
# spec/spec_helper.rb of the extension both:
|
14
|
-
#
|
15
|
-
# require 'spree/testing_support/preferences'
|
16
|
-
# require 'solidus_support/testing_support/preferences'
|
17
|
-
#
|
18
|
-
# @example Set a preference on Spree::Config
|
19
|
-
# stub_spree_preferences(allow_guest_checkout: false)
|
20
|
-
#
|
21
|
-
# @example Set a preference on Spree::Api::Config
|
22
|
-
# stub_spree_preferences(Spree::Api::Config, requires_authentication: false)
|
23
|
-
#
|
24
|
-
# @example Set a preference on a custom Spree::CustomExtension::Config
|
25
|
-
# stub_spree_preferences(Spree::CustomExtension::Config, custom_pref: true)
|
26
|
-
#
|
27
|
-
# @param prefs_or_conf_class [Class, Hash] the class we want to stub
|
28
|
-
# preferences for or the preferences hash (see prefs param). If this
|
29
|
-
# param is an Hash, preferences will be stubbed on Spree::Config.
|
30
|
-
# @param prefs [Hash, nil] names and values to be stubbed
|
31
|
-
def stub_spree_preferences(prefs_or_conf_class, prefs = nil)
|
32
|
-
super && return if SolidusSupport.reset_spree_preferences_deprecated?
|
33
|
-
|
34
|
-
if prefs_or_conf_class.is_a?(Hash)
|
35
|
-
preference_store_class = Spree::Config
|
36
|
-
preferences = prefs_or_conf_class
|
37
|
-
else
|
38
|
-
preference_store_class = prefs_or_conf_class
|
39
|
-
preferences = prefs
|
40
|
-
end
|
41
|
-
preference_store_class.set(preferences)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|