solidus_extension_dev_tools 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3e8f4dcd3340ff2ab08034052765cf899a16aa945990dd11a5087121c2670b94
4
+ data.tar.gz: '007478ad0b5ec40e8f91833f1fcddffa44ff0e2f3f88358b71bd4f3207111c0d'
5
+ SHA512:
6
+ metadata.gz: aa5b8cbfebb5c18b0239a17b9b317a6080760c52e92670a0f485bdbce1598919a0e33c02178710636c0c13070f3f4dbff98d347f0c73fc43c7a47a9ea77831e0
7
+ data.tar.gz: ffc5a00edfa92a550b925b7ec44007970baa1bceccc9c0844b67b7a809e3d806c75add1ef7443cad22d48feb3851277472487de2b22379c4ce770026619ca471
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,174 @@
1
+ # Relaxed.Ruby.Style
2
+ ## Version 2.4
3
+
4
+ Style/Alias:
5
+ Enabled: false
6
+ StyleGuide: https://relaxed.ruby.style/#stylealias
7
+
8
+ Style/AsciiComments:
9
+ Enabled: false
10
+ StyleGuide: https://relaxed.ruby.style/#styleasciicomments
11
+
12
+ Style/BeginBlock:
13
+ Enabled: false
14
+ StyleGuide: https://relaxed.ruby.style/#stylebeginblock
15
+
16
+ Style/BlockDelimiters:
17
+ Enabled: false
18
+ StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
19
+
20
+ Style/CommentAnnotation:
21
+ Enabled: false
22
+ StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+ StyleGuide: https://relaxed.ruby.style/#styledocumentation
27
+
28
+ Layout/DotPosition:
29
+ Enabled: false
30
+ StyleGuide: https://relaxed.ruby.style/#layoutdotposition
31
+
32
+ Style/DoubleNegation:
33
+ Enabled: false
34
+ StyleGuide: https://relaxed.ruby.style/#styledoublenegation
35
+
36
+ Style/EndBlock:
37
+ Enabled: false
38
+ StyleGuide: https://relaxed.ruby.style/#styleendblock
39
+
40
+ Style/FormatString:
41
+ Enabled: false
42
+ StyleGuide: https://relaxed.ruby.style/#styleformatstring
43
+
44
+ Style/IfUnlessModifier:
45
+ Enabled: false
46
+ StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
47
+
48
+ Style/Lambda:
49
+ Enabled: false
50
+ StyleGuide: https://relaxed.ruby.style/#stylelambda
51
+
52
+ Style/ModuleFunction:
53
+ Enabled: false
54
+ StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
55
+
56
+ Style/MultilineBlockChain:
57
+ Enabled: false
58
+ StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
59
+
60
+ Style/NegatedIf:
61
+ Enabled: false
62
+ StyleGuide: https://relaxed.ruby.style/#stylenegatedif
63
+
64
+ Style/NegatedWhile:
65
+ Enabled: false
66
+ StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
67
+
68
+ Style/NumericPredicate:
69
+ Enabled: false
70
+ StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
71
+
72
+ Style/ParallelAssignment:
73
+ Enabled: false
74
+ StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
75
+
76
+ Style/PercentLiteralDelimiters:
77
+ Enabled: false
78
+ StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
79
+
80
+ Style/PerlBackrefs:
81
+ Enabled: false
82
+ StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
83
+
84
+ Style/Semicolon:
85
+ Enabled: false
86
+ StyleGuide: https://relaxed.ruby.style/#stylesemicolon
87
+
88
+ Style/SignalException:
89
+ Enabled: false
90
+ StyleGuide: https://relaxed.ruby.style/#stylesignalexception
91
+
92
+ Style/SingleLineBlockParams:
93
+ Enabled: false
94
+ StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
95
+
96
+ Style/SingleLineMethods:
97
+ Enabled: false
98
+ StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
99
+
100
+ Layout/SpaceBeforeBlockBraces:
101
+ Enabled: false
102
+ StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
103
+
104
+ Layout/SpaceInsideParens:
105
+ Enabled: false
106
+ StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
107
+
108
+ Style/SpecialGlobalVars:
109
+ Enabled: false
110
+ StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
111
+
112
+ Style/StringLiterals:
113
+ Enabled: false
114
+ StyleGuide: https://relaxed.ruby.style/#stylestringliterals
115
+
116
+ Style/TrailingCommaInArguments:
117
+ Enabled: false
118
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
119
+
120
+ Style/TrailingCommaInArrayLiteral:
121
+ Enabled: false
122
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
123
+
124
+ Style/TrailingCommaInHashLiteral:
125
+ Enabled: false
126
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
127
+
128
+ Style/SymbolArray:
129
+ Enabled: false
130
+ StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
131
+
132
+ Style/WhileUntilModifier:
133
+ Enabled: false
134
+ StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
135
+
136
+ Style/WordArray:
137
+ Enabled: false
138
+ StyleGuide: https://relaxed.ruby.style/#stylewordarray
139
+
140
+ Lint/AmbiguousRegexpLiteral:
141
+ Enabled: false
142
+ StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
143
+
144
+ Lint/AssignmentInCondition:
145
+ Enabled: false
146
+ StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
147
+
148
+ Metrics/AbcSize:
149
+ Enabled: false
150
+
151
+ Metrics/BlockNesting:
152
+ Enabled: false
153
+
154
+ Metrics/ClassLength:
155
+ Enabled: false
156
+
157
+ Metrics/ModuleLength:
158
+ Enabled: false
159
+
160
+ Metrics/CyclomaticComplexity:
161
+ Enabled: false
162
+
163
+ Metrics/LineLength:
164
+ Enabled: false
165
+
166
+ Metrics/MethodLength:
167
+ Enabled: false
168
+
169
+ Metrics/ParameterLists:
170
+ Enabled: false
171
+
172
+ Metrics/PerceivedComplexity:
173
+ Enabled: false
174
+
@@ -0,0 +1,180 @@
1
+ # Relaxed.Ruby.Style
2
+ ## Version 2.4
3
+
4
+ Style/Alias:
5
+ Enabled: false
6
+ StyleGuide: https://relaxed.ruby.style/#stylealias
7
+
8
+ Style/AsciiComments:
9
+ Enabled: false
10
+ StyleGuide: https://relaxed.ruby.style/#styleasciicomments
11
+
12
+ Style/BeginBlock:
13
+ Enabled: false
14
+ StyleGuide: https://relaxed.ruby.style/#stylebeginblock
15
+
16
+ Style/BlockDelimiters:
17
+ Enabled: false
18
+ StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
19
+
20
+ Style/CommentAnnotation:
21
+ Enabled: false
22
+ StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+ StyleGuide: https://relaxed.ruby.style/#styledocumentation
27
+
28
+ Layout/DotPosition:
29
+ Enabled: false
30
+ StyleGuide: https://relaxed.ruby.style/#layoutdotposition
31
+
32
+ Style/DoubleNegation:
33
+ Enabled: false
34
+ StyleGuide: https://relaxed.ruby.style/#styledoublenegation
35
+
36
+ Style/EndBlock:
37
+ Enabled: false
38
+ StyleGuide: https://relaxed.ruby.style/#styleendblock
39
+
40
+ Style/FormatString:
41
+ Enabled: false
42
+ StyleGuide: https://relaxed.ruby.style/#styleformatstring
43
+
44
+ Style/IfUnlessModifier:
45
+ Enabled: false
46
+ StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
47
+
48
+ Style/Lambda:
49
+ Enabled: false
50
+ StyleGuide: https://relaxed.ruby.style/#stylelambda
51
+
52
+ Style/ModuleFunction:
53
+ Enabled: false
54
+ StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
55
+
56
+ Style/MultilineBlockChain:
57
+ Enabled: false
58
+ StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
59
+
60
+ Style/NegatedIf:
61
+ Enabled: false
62
+ StyleGuide: https://relaxed.ruby.style/#stylenegatedif
63
+
64
+ Style/NegatedWhile:
65
+ Enabled: false
66
+ StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
67
+
68
+ Style/NumericPredicate:
69
+ Enabled: false
70
+ StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
71
+
72
+ Style/ParallelAssignment:
73
+ Enabled: false
74
+ StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
75
+
76
+ Style/PercentLiteralDelimiters:
77
+ Enabled: false
78
+ StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
79
+
80
+ Style/PerlBackrefs:
81
+ Enabled: false
82
+ StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
83
+
84
+ Style/Semicolon:
85
+ Enabled: false
86
+ StyleGuide: https://relaxed.ruby.style/#stylesemicolon
87
+
88
+ Style/SignalException:
89
+ Enabled: false
90
+ StyleGuide: https://relaxed.ruby.style/#stylesignalexception
91
+
92
+ Style/SingleLineBlockParams:
93
+ Enabled: false
94
+ StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
95
+
96
+ Style/SingleLineMethods:
97
+ Enabled: false
98
+ StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
99
+
100
+ Layout/SpaceBeforeBlockBraces:
101
+ Enabled: false
102
+ StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
103
+
104
+ Layout/SpaceInsideParens:
105
+ Enabled: false
106
+ StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
107
+
108
+ Style/SpecialGlobalVars:
109
+ Enabled: false
110
+ StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
111
+
112
+ Style/StringLiterals:
113
+ Enabled: false
114
+ StyleGuide: https://relaxed.ruby.style/#stylestringliterals
115
+
116
+ Style/TrailingCommaInArguments:
117
+ Enabled: false
118
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
119
+
120
+ Style/TrailingCommaInArrayLiteral:
121
+ Enabled: false
122
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
123
+
124
+ Style/TrailingCommaInHashLiteral:
125
+ Enabled: false
126
+ StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
127
+
128
+ Style/SymbolArray:
129
+ Enabled: false
130
+ StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
131
+
132
+ Style/WhileUntilModifier:
133
+ Enabled: false
134
+ StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
135
+
136
+ Style/WordArray:
137
+ Enabled: false
138
+ StyleGuide: https://relaxed.ruby.style/#stylewordarray
139
+
140
+ Lint/AmbiguousRegexpLiteral:
141
+ Enabled: false
142
+ StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
143
+
144
+ Lint/AssignmentInCondition:
145
+ Enabled: false
146
+ StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
147
+
148
+ Metrics/AbcSize:
149
+ Enabled: false
150
+
151
+ Metrics/BlockNesting:
152
+ Enabled: false
153
+
154
+ Metrics/ClassLength:
155
+ Enabled: false
156
+
157
+ Metrics/ModuleLength:
158
+ Enabled: false
159
+
160
+ Metrics/CyclomaticComplexity:
161
+ Enabled: false
162
+
163
+ Metrics/LineLength:
164
+ Enabled: false
165
+
166
+ Metrics/MethodLength:
167
+ Enabled: false
168
+
169
+ Metrics/ParameterLists:
170
+ Enabled: false
171
+
172
+ Metrics/PerceivedComplexity:
173
+ Enabled: false
174
+
175
+ # Our overrides after this point:
176
+
177
+ require:
178
+ - rubocop-rspec
179
+ - rubocop-rails
180
+ - rubocop-performance
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://relaxed.ruby.style/rubocop.yml
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in solidus_extension_dev_tools.gemspec
8
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Nebulab Srls
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,114 @@
1
+ # solidus_extension_dev_tools
2
+
3
+ This is a collection of tools for developing Solidus extensions.
4
+
5
+ ## Installation
6
+
7
+ Add this gem as a development dependency of your extension:
8
+
9
+ ```ruby
10
+ spec.add_development_dependency 'solidus_extension_dev_tools'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```console
16
+ $ bundle
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### RSpec helpers
22
+
23
+ This gem provides some useful helpers for RSpec to setup an extension's test environment easily.
24
+
25
+ Add this to your extension's `spec/spec_helper.rb`:
26
+
27
+ ```ruby
28
+ require 'solidus_extension_dev_tools/rspec/feature_helper'
29
+ ```
30
+
31
+ This helper loads configuration needed to run extension feature specs correctly, setting up Capybara
32
+ and configuring a Rails test application to precompile assets before the first feature spec.
33
+
34
+ `feature_helper` builds on top of `rails_helper`, which you can also use a standalone helper if you
35
+ want:
36
+
37
+ ```ruby
38
+ require 'solidus_extension_dev_tools/rspec/rails_helper'
39
+ ```
40
+
41
+ This will include the Rails and Solidus-related RSpec configuration, such as authorization helpers,
42
+ Solidus factories, URL helpers, and other helpers to easily work with Solidus.
43
+
44
+ `rails_helper`, in turn, builds on top of `spec_helper`, which is responsible for setting up a
45
+ basic RSpec environment:
46
+
47
+ ```ruby
48
+ require 'solidus_extension_dev_tools/rspec/spec_helper'
49
+ ```
50
+
51
+ ### Code coverage
52
+
53
+ The gem also includes a SimpleCov configuration that will send your test coverage information
54
+ directly to Codecov.io. Simply add this at the top of your `spec/spec_helper.rb`:
55
+
56
+ ```ruby
57
+ require 'solidus_extension_dev_tools/rspec/coverage'
58
+ ```
59
+
60
+ **Note: Make sure to add this at the VERY TOP of your spec_helper, otherwise you'll get skewed
61
+ coverage reports!**
62
+
63
+ If your extension is in a public repo and being tested on Travis or CircleCI, there's nothing else
64
+ you need to do! If your setup is more complex, look at the
65
+ [SimpleCov](https://github.com/colszowka/simplecov)
66
+ and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs.
67
+
68
+ ### RuboCop configuration
69
+
70
+ solidus_extension_dev_tools includes a default [RuboCop](https://github.com/rubocop-hq/rubocop) configuration
71
+ for Solidus extensions. Currently, this is based on [Relaxed Ruby Style](https://relaxed.ruby.style)
72
+ with a few customizations, but in the future we plan to provide custom cops to ensure your
73
+ extension follows established Solidus best practices.
74
+
75
+ We strongly recommend including the RuboCop configuration in your extension. All you have to do is
76
+ add this to your `.rubocop.yml`:
77
+
78
+ ```yaml
79
+ require:
80
+ - solidus_extension_dev_tools/rubocop
81
+
82
+ inherit_gem:
83
+ solidus_extension_dev_tools: .rubocop.extension.yml
84
+
85
+ AllCops:
86
+ Exclude:
87
+ - spec/dummy/**/*
88
+ ```
89
+
90
+ You can now run RuboCop with:
91
+
92
+ ```console
93
+ $ bundle exec rubocop
94
+ ```
95
+
96
+ ## Development
97
+
98
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
99
+ the tests. You can also run `bin/console` for an interactive prompt that will allow you to
100
+ experiment.
101
+
102
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new
103
+ version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
104
+ will create a git tag for the version, push git commits and tags, and push the `.gem` file to
105
+ [rubygems.org](https://rubygems.org).
106
+
107
+ ## Contributing
108
+
109
+ Bug reports and pull requests are welcome on GitHub at https://github.com/solidusio/solidus_extension_dev_tools.
110
+
111
+ ## License
112
+
113
+ The gem is available as open source under the terms of the
114
+ [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "solidus_extension_dev_tools"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "solidus_support"
4
+ require "solidus_extension_dev_tools/version"
5
+
6
+ module SolidusExtensionDevTools
7
+ class Error < StandardError; end
8
+
9
+ class << self
10
+ def reset_spree_preferences_deprecated?
11
+ first_version_without_reset = Gem::Requirement.new('>= 2.9')
12
+ first_version_without_reset.satisfied_by?(SolidusSupport.solidus_gem_version)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A SimpleCov and Codecov configuration to track code coverage in your extension
4
+ #
5
+ # Include it AT THE TOP of your spec/spec_helper.rb:
6
+ #
7
+ # require 'solidus_extension_dev_tools/extension/coverage'
8
+ #
9
+ # Note that things may not work properly if you don't include this at the very top!
10
+ #
11
+
12
+ require 'simplecov'
13
+ SimpleCov.start 'rails'
14
+
15
+ if ENV['CI']
16
+ require 'codecov'
17
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
18
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A basic feature_helper to be included as the starting point for extensions
4
+ #
5
+ # Can be required from an extension's spec/feature_helper.rb
6
+ #
7
+ # require 'solidus_extension_dev_tools/extension/feature_helper'
8
+ #
9
+
10
+ require 'solidus_extension_dev_tools/rspec/rails_helper'
11
+
12
+ require 'capybara-screenshot/rspec'
13
+ require 'selenium/webdriver'
14
+
15
+ Capybara.register_driver :selenium_chrome_headless do |app|
16
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
17
+ chromeOptions: { args: %w[headless start-maximized] }
18
+ )
19
+
20
+ Capybara::Selenium::Driver.new(
21
+ app,
22
+ browser: :chrome,
23
+ desired_capabilities: capabilities
24
+ )
25
+ end
26
+
27
+ Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
28
+ Capybara.default_max_wait_time = 10
29
+ Capybara.server = :webrick
30
+
31
+ require 'spree/testing_support/capybara_ext'
32
+
33
+ RSpec.configure do |config|
34
+ config.when_first_matching_example_defined(type: :feature) do
35
+ config.before :suite do
36
+ # Preload assets
37
+ if Rails.application.respond_to?(:precompiled_assets)
38
+ Rails.application.precompiled_assets
39
+ else
40
+ # For older sprockets 2.x
41
+ Rails.application.config.assets.precompile.each do |asset|
42
+ Rails.application.assets.find_asset(asset)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A basic rails_helper to be included as the starting point for extensions
4
+ #
5
+ # Can be required from an extension's spec/rails_helper.rb
6
+ #
7
+ # require 'solidus_extension_dev_tools/extension/rails_helper'
8
+ #
9
+
10
+ require 'solidus_extension_dev_tools/rspec/spec_helper'
11
+
12
+ require 'rspec/rails'
13
+ require 'database_cleaner'
14
+ require 'factory_bot_rails'
15
+ require 'ffaker'
16
+
17
+ require 'spree/testing_support/authorization_helpers'
18
+ require 'spree/testing_support/factories'
19
+ require 'spree/testing_support/url_helpers'
20
+ require 'spree/testing_support/preferences'
21
+ require 'spree/testing_support/controller_requests'
22
+ require 'solidus_extension_dev_tools/testing_support/preferences'
23
+
24
+ RSpec.configure do |config|
25
+ config.infer_spec_type_from_file_location!
26
+
27
+ config.include FactoryBot::Syntax::Methods
28
+
29
+ # visit spree.admin_path
30
+ # current_path.should eql(spree.products_path)
31
+ config.include Spree::TestingSupport::UrlHelpers
32
+
33
+ config.include Spree::TestingSupport::ControllerRequests, type: :controller
34
+
35
+ config.include Spree::TestingSupport::Preferences
36
+ config.include SolidusExtensionDevTools::TestingSupport::Preferences
37
+
38
+ config.before :suite do
39
+ DatabaseCleaner.clean_with :truncation
40
+ end
41
+
42
+ config.before do
43
+ ActiveJob::Base.queue_adapter = :test
44
+ end
45
+
46
+ # Around each spec check if it is a Javascript test and switch between using
47
+ # database transactions or not where necessary.
48
+ config.around(:each) do |example|
49
+ DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
50
+
51
+ DatabaseCleaner.cleaning do
52
+ reset_spree_preferences unless SolidusExtensionDevTools.reset_spree_preferences_deprecated?
53
+
54
+ example.run
55
+ end
56
+ end
57
+
58
+ config.include ActiveJob::TestHelper
59
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A basic spec_helper to be included as the starting point for extensions
4
+ #
5
+ # Can be required from an extension's spec/spec_helper.rb
6
+ #
7
+ # require 'solidus_extension_dev_tools/extension/spec_helper'
8
+ #
9
+
10
+ RSpec.configure do |config|
11
+ config.filter_run focus: true
12
+ config.run_all_when_everything_filtered = true
13
+
14
+ config.mock_with :rspec
15
+ config.color = true
16
+
17
+ config.fail_fast = ENV['FAIL_FAST'] || false
18
+ config.order = 'random'
19
+
20
+ config.raise_errors_for_deprecations!
21
+
22
+ config.example_status_persistence_file_path = "./spec/examples.txt"
23
+
24
+ Kernel.srand config.seed
25
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ # This file is provided to easily provide custom cops at some point in the future without requiring
3
+ # extensions to update their .rubocop.yml.
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusExtensionDevTools
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_extension_dev_tools/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 SolidusExtensionDevTools.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
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusExtensionDevTools
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'solidus_extension_dev_tools/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'solidus_extension_dev_tools'
9
+ spec.version = SolidusExtensionDevTools::VERSION
10
+ spec.authors = ['Alessandro Desantis']
11
+ spec.email = ['alessandrodesantis@nebulab.it']
12
+
13
+ spec.summary = 'Development tools for Solidus extensions.'
14
+ spec.homepage = 'https://github.com/solidusio/solidus_extension_dev_tools'
15
+ spec.license = 'MIT'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_extension_dev_tools'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_dependency 'capybara', '~> 3.29'
30
+ spec.add_dependency 'capybara-screenshot', '~> 1.0'
31
+ spec.add_dependency 'codecov', '~> 0.1.16'
32
+ spec.add_dependency 'database_cleaner', '~> 1.7'
33
+ spec.add_dependency 'factory_bot_rails', '~> 5.1'
34
+ spec.add_dependency 'ffaker', '~> 2.13'
35
+ spec.add_dependency 'rspec-rails', '~> 4.0.0.beta3'
36
+ spec.add_dependency 'rubocop', '~> 0.76.0'
37
+ spec.add_dependency 'rubocop-performance', '~> 1.5'
38
+ spec.add_dependency 'rubocop-rails', '~> 2.3'
39
+ spec.add_dependency 'rubocop-rspec', '~> 1.36'
40
+ spec.add_dependency 'selenium-webdriver', '~> 3.142'
41
+ spec.add_dependency 'solidus_core', ['>= 2.0', '< 3']
42
+ spec.add_dependency 'solidus_support', '~> 0.3.3'
43
+
44
+ spec.add_development_dependency 'bundler'
45
+ spec.add_development_dependency 'rake'
46
+ end
metadata ADDED
@@ -0,0 +1,295 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_extension_dev_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alessandro Desantis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capybara
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.29'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.29'
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara-screenshot
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.16
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.16
55
+ - !ruby/object:Gem::Dependency
56
+ name: database_cleaner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_bot_rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ffaker
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.13'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 4.0.0.beta3
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 4.0.0.beta3
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.76.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.76.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-performance
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.5'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.5'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.3'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.3'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.36'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.36'
167
+ - !ruby/object:Gem::Dependency
168
+ name: selenium-webdriver
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.142'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '3.142'
181
+ - !ruby/object:Gem::Dependency
182
+ name: solidus_core
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '2.0'
188
+ - - "<"
189
+ - !ruby/object:Gem::Version
190
+ version: '3'
191
+ type: :runtime
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: '2.0'
198
+ - - "<"
199
+ - !ruby/object:Gem::Version
200
+ version: '3'
201
+ - !ruby/object:Gem::Dependency
202
+ name: solidus_support
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: 0.3.3
208
+ type: :runtime
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: 0.3.3
215
+ - !ruby/object:Gem::Dependency
216
+ name: bundler
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ - !ruby/object:Gem::Dependency
230
+ name: rake
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
243
+ description:
244
+ email:
245
+ - alessandrodesantis@nebulab.it
246
+ executables: []
247
+ extensions: []
248
+ extra_rdoc_files: []
249
+ files:
250
+ - ".gitignore"
251
+ - ".rspec"
252
+ - ".rubocop-https---relaxed-ruby-style-rubocop-yml"
253
+ - ".rubocop.extension.yml"
254
+ - ".rubocop.yml"
255
+ - Gemfile
256
+ - LICENSE.txt
257
+ - README.md
258
+ - Rakefile
259
+ - bin/console
260
+ - bin/setup
261
+ - lib/solidus_extension_dev_tools.rb
262
+ - lib/solidus_extension_dev_tools/rspec/coverage.rb
263
+ - lib/solidus_extension_dev_tools/rspec/feature_helper.rb
264
+ - lib/solidus_extension_dev_tools/rspec/rails_helper.rb
265
+ - lib/solidus_extension_dev_tools/rspec/spec_helper.rb
266
+ - lib/solidus_extension_dev_tools/rubocop.rb
267
+ - lib/solidus_extension_dev_tools/testing_support/preferences.rb
268
+ - lib/solidus_extension_dev_tools/version.rb
269
+ - solidus_extension_dev_tools.gemspec
270
+ homepage: https://github.com/solidusio/solidus_extension_dev_tools
271
+ licenses:
272
+ - MIT
273
+ metadata:
274
+ homepage_uri: https://github.com/solidusio/solidus_extension_dev_tools
275
+ source_code_uri: https://github.com/solidusio/solidus_extension_dev_tools
276
+ post_install_message:
277
+ rdoc_options: []
278
+ require_paths:
279
+ - lib
280
+ required_ruby_version: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ version: '0'
285
+ required_rubygems_version: !ruby/object:Gem::Requirement
286
+ requirements:
287
+ - - ">="
288
+ - !ruby/object:Gem::Version
289
+ version: '0'
290
+ requirements: []
291
+ rubygems_version: 3.0.6
292
+ signing_key:
293
+ specification_version: 4
294
+ summary: Development tools for Solidus extensions.
295
+ test_files: []