spree_dev_tools 0.2.12 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 204ba6f996aed467d0b0f034be6d626f9db1562820e65b40445eaf218a0190f6
4
- data.tar.gz: cca073c169a3f11c1b320a7b77faffc66341150cab426cdb761e86e9034b259a
3
+ metadata.gz: 6c054c07d9a9571600219e9e46dfbc50df3cb3e1a702e832bb2562c69cec5001
4
+ data.tar.gz: f49364c6dac2d1d41b1ced17ae45aad5192b5be9dafae540f30a15e05116b967
5
5
  SHA512:
6
- metadata.gz: 7153d4a0f532ff13889d22ae26c670f30dac467f8bdcefe448f5cb8d3f46a53ccafd04cbd21d57d9f104f4f46d5b8403b2d302d34df0bec125e4a8eb3c409745
7
- data.tar.gz: d062621a094c8127250e8a580953984bba6ac9f15b366d7b42c77cbc04cc467396140113648210637db43555e3e7138d877fa681c33e9442a07f103052bd1e46
6
+ metadata.gz: 3370af1969820173a0d6c5ec6d4a787f361aadf2ca6f45c2084504b4a57a25898a6339a4e06f111b3eb83ed50907fbe76277b5f5986f529be77461e27fe4fa12
7
+ data.tar.gz: e90aaaa38825bb151732eee71af2530629328cdcb191de2ec078f1302c0fe3ead0e866c509a309f2519db213e9539dd6880b9d73eee5d35c5c16baba63af2b7c
@@ -1,49 +1,98 @@
1
- # Run Coverage report
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+
2
5
  require 'rspec/rails'
3
- require 'rspec/active_model/mocks'
4
- require 'rspec/retry'
6
+ require 'database_cleaner/active_record'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
5
12
  require 'ffaker'
6
13
  require 'pry'
14
+
7
15
  require 'webdrivers/chromedriver'
16
+ require 'spree/testing_support/authorization_helpers'
17
+ require 'spree/testing_support/factories'
18
+ require 'spree/api/testing_support/factories'
19
+ require 'spree/testing_support/preferences'
20
+ require 'spree/testing_support/jobs'
21
+ require 'spree/testing_support/store'
22
+ require 'spree/testing_support/controller_requests'
23
+ require 'spree/testing_support/url_helpers'
24
+ require 'spree/testing_support/order_walkthrough'
25
+ require 'spree/admin/testing_support/capybara_utils'
26
+ require 'spree/admin/testing_support/tom_select'
27
+ require 'spree/testing_support/capybara_config'
28
+ require 'spree/testing_support/rspec_retry_config'
29
+ require 'spree/testing_support/image_helpers'
8
30
 
9
- require 'action_text/system_test_helper'
31
+ require 'jsonapi/rspec'
32
+ require 'spree/api/testing_support/v2/base'
33
+ require 'spree/api/testing_support/matchers/webhooks'
34
+ require 'spree/api/testing_support/factories'
35
+ require 'spree/api/testing_support/v2/current_order'
36
+ require 'spree/api/testing_support/v2/platform_contexts'
37
+ require 'spree/api/testing_support/v2/serializers_params'
10
38
 
11
- # Requires supporting ruby files with custom matchers and macros, etc,
12
- # in spec/support/ and its subdirectories.
13
- Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
39
+ require 'spree/core/controller_helpers/strong_parameters'
14
40
 
15
- RSpec.configure do |config|
16
- # Infer an example group's spec type from the file location.
17
- config.infer_spec_type_from_file_location!
41
+ require 'action_text/system_test_helper'
18
42
 
19
- # == Mock Framework
20
- #
21
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
22
- #
23
- # config.mock_with :mocha
24
- # config.mock_with :flexmock
25
- # config.mock_with :rr
26
- config.mock_with :rspec
43
+ RSpec.configure do |config|
27
44
  config.color = true
28
45
  config.default_formatter = 'doc'
46
+ config.fail_fast = ENV['FAIL_FAST'] || false
47
+ config.infer_spec_type_from_file_location!
48
+ config.mock_with :rspec
49
+ config.raise_errors_for_deprecations!
29
50
 
30
- # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
31
- # to cleanup after each test instead. Without transactional fixtures set to false the records created
32
- # to setup a test will be unavailable to the browser, which runs under a separate server instance.
33
- config.use_transactional_fixtures = false
51
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
52
+ # examples within a transaction, comment the following line or assign false
53
+ # instead of true.
54
+ config.use_transactional_fixtures = true
34
55
 
35
- config.fail_fast = ENV['FAIL_FAST'] || false
36
- config.order = 'random'
56
+ config.before(:suite) do
57
+ Capybara.match = :smart
58
+ Capybara.javascript_driver = :selenium_chrome_headless
59
+ Capybara.default_max_wait_time = 10
60
+ Capybara.raise_server_errors = false
61
+ # Clean out the database state before the tests run
62
+ DatabaseCleaner.strategy = :transaction
63
+ DatabaseCleaner.clean_with(:truncation)
64
+ end
37
65
 
38
- # show retry status in spec process
39
- config.verbose_retry = true
40
- # show exception that triggers a retry if verbose_retry is set to true
41
- config.display_try_failure_messages = true
66
+ config.around(:each) do |example|
67
+ DatabaseCleaner.cleaning do
68
+ example.run
69
+ end
70
+ end
42
71
 
43
- config.around :each, :js do |ex|
44
- ex.run_with_retry retry: 3
72
+ config.before(:each) do
73
+ Spree::Webhooks.disabled = true
74
+ reset_spree_preferences
45
75
  end
46
76
 
77
+ config.include FactoryBot::Syntax::Methods
78
+
79
+ config.include Spree::Admin::TestingSupport::CapybaraUtils
80
+ config.include Spree::Admin::TestingSupport::TomSelect
81
+ config.include Spree::TestingSupport::Preferences
82
+ config.include Spree::TestingSupport::UrlHelpers
83
+ config.include Spree::TestingSupport::ControllerRequests, type: :controller
84
+ config.include Spree::TestingSupport::ImageHelpers
85
+
86
+ config.include Spree::Core::ControllerHelpers::StrongParameters, type: :controller
87
+
47
88
  config.include ActionText::SystemTestHelper, type: :feature
48
- config.include ActiveJob::TestHelper
89
+
90
+ config.include JSONAPI::RSpec, type: :request # required for API v2 request specs
91
+ config.include Spree::TestingSupport::ApiHelpers, type: :request
92
+
93
+ config.order = :random
94
+ Kernel.srand config.seed
95
+
96
+ config.filter_run_including focus: true unless ENV['CI']
97
+ config.run_all_when_everything_filtered = true
49
98
  end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ module TestingSupport
3
+ module ApiHelpers
4
+ def json_response
5
+ case body = JSON.parse(response.body)
6
+ when Hash
7
+ body.with_indifferent_access
8
+ when Array
9
+ body
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  module SpreeDevTools
2
- VERSION = '0.2.12'
2
+ VERSION = '0.3.1'
3
3
 
4
4
  # Returns the version of the currently loaded SpreeDevTools as a
5
5
  # <tt>Gem::Version</tt>.
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
47
47
  s.add_dependency 'sass-rails'
48
48
  s.add_dependency 'selenium-webdriver', '>= 4.10'
49
49
  s.add_dependency 'simplecov'
50
- s.add_dependency 'spree'
50
+ s.add_dependency 'spree', '>= 5.0'
51
51
  s.add_dependency 'timecop'
52
52
  s.add_dependency 'webdrivers'
53
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_dev_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spark Solutions
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-31 00:00:00.000000000 Z
11
+ date: 2025-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -380,14 +380,14 @@ dependencies:
380
380
  requirements:
381
381
  - - ">="
382
382
  - !ruby/object:Gem::Version
383
- version: '0'
383
+ version: '5.0'
384
384
  type: :runtime
385
385
  prerelease: false
386
386
  version_requirements: !ruby/object:Gem::Requirement
387
387
  requirements:
388
388
  - - ">="
389
389
  - !ruby/object:Gem::Version
390
- version: '0'
390
+ version: '5.0'
391
391
  - !ruby/object:Gem::Dependency
392
392
  name: timecop
393
393
  requirement: !ruby/object:Gem::Requirement
@@ -428,19 +428,13 @@ files:
428
428
  - Gemfile
429
429
  - LICENSE
430
430
  - README.md
431
- - lib/spree/testing_support/auth_helpers.rb
432
- - lib/spree/testing_support/checkout_helpers.rb
433
431
  - lib/spree_dev_tools.rb
434
432
  - lib/spree_dev_tools/rspec/spec_helper.rb
435
433
  - lib/spree_dev_tools/rspec/support/active_job.rb
436
- - lib/spree_dev_tools/rspec/support/authentication_helpers.rb
437
- - lib/spree_dev_tools/rspec/support/capybara.rb
438
- - lib/spree_dev_tools/rspec/support/database_cleaner.rb
439
434
  - lib/spree_dev_tools/rspec/support/devise.rb
440
435
  - lib/spree_dev_tools/rspec/support/factory_bot.rb
441
436
  - lib/spree_dev_tools/rspec/support/simplecov.rb
442
- - lib/spree_dev_tools/rspec/support/spree.rb
443
- - lib/spree_dev_tools/rspec/support/spree_cart.rb
437
+ - lib/spree_dev_tools/rspec/support/spree_api_helpers.rb
444
438
  - lib/spree_dev_tools/version.rb
445
439
  - spree_dev_tools.gemspec
446
440
  homepage: https://github.com/spree/spree_dev_tools
@@ -1,36 +0,0 @@
1
- module Spree
2
- module TestingSupport
3
- module AuthHelpers
4
- def log_in(email:, password:, remember_me: true)
5
- visit spree.login_path
6
-
7
- fill_in 'Email', with: email
8
- fill_in 'Password', with: password
9
-
10
- # Regression test for #1257
11
- first('label', text: 'Remember me').click if remember_me
12
- click_button 'Log in'
13
-
14
- expect(page).to have_content 'Logged in successfully'
15
- end
16
-
17
- def log_out
18
- show_user_menu
19
- click_link 'LOG OUT'
20
-
21
- expect(page).to have_content 'Signed out successfully'
22
- end
23
-
24
- def show_user_menu
25
- find("button[aria-label='Show user menu']").click
26
- end
27
-
28
- def show_user_account
29
- within '#nav-bar' do
30
- show_user_menu
31
- click_link 'MY ACCOUNT'
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,24 +0,0 @@
1
- module Spree
2
- module TestingSupport
3
- module CheckoutHelpers
4
- def fill_in_address
5
- address = 'order_bill_address_attributes'
6
- fill_in "#{address}_firstname", with: 'Ryan'
7
- fill_in "#{address}_lastname", with: 'Bigg'
8
- fill_in "#{address}_address1", with: '143 Swan Street'
9
- fill_in "#{address}_city", with: 'Richmond'
10
- select country.name, from: "#{address}_country_id"
11
- select state.name, from: "#{address}_state_id"
12
- fill_in "#{address}_zipcode", with: '12345'
13
- fill_in "#{address}_phone", with: '(555) 555-5555'
14
- end
15
-
16
- def fill_in_credit_card_info(invalid: false)
17
- fill_in 'name_on_card', with: 'Spree Commerce'
18
- fill_in 'card_number', with: invalid ? '123' : '4111 1111 1111 1111'
19
- fill_in 'card_expiry', with: '12 / 24'
20
- fill_in 'card_code', with: '123'
21
- end
22
- end
23
- end
24
- end
@@ -1,13 +0,0 @@
1
- module AuthenticationHelpers
2
- def sign_in_as!(user)
3
- visit '/login'
4
- fill_in 'Email', with: user.email
5
- fill_in 'Password', with: 'secret'
6
- click_button 'Log in'
7
- end
8
- end
9
-
10
- RSpec.configure do |config|
11
- config.include AuthenticationHelpers, type: :feature
12
- config.include Rack::Test::Methods, type: :feature
13
- end
@@ -1,31 +0,0 @@
1
- require 'capybara/rspec'
2
- require 'capybara-screenshot'
3
- require 'capybara-screenshot/rspec'
4
- require 'capybara/rails'
5
- require 'selenium-webdriver'
6
- require 'capybara-select-2'
7
-
8
- Capybara.configure do |config|
9
- config.save_path = ENV['CIRCLE_ARTIFACTS'] if ENV['CIRCLE_ARTIFACTS']
10
- config.server = :puma
11
- config.default_driver = :rack_test
12
- config.javascript_driver = :selenium_chrome_headless
13
- config.default_max_wait_time = ENV.fetch('CAPYBARA_MAX_WAIT_TIME', 45).to_i
14
- config.always_include_port = true
15
- config.match = :smart
16
- config.ignore_hidden_elements = true
17
- end
18
-
19
- if ENV['WEBDRIVER'] == 'accessible'
20
- require 'capybara/accessible'
21
- Capybara.javascript_driver = :accessible
22
- end
23
-
24
- RSpec.configure do |config|
25
- config.before(:each, js: true) do
26
- Capybara.page.driver.browser.manage.window.resize_to(1400, 900)
27
- end
28
-
29
- config.include CapybaraSelect2
30
- config.include CapybaraSelect2::Helpers
31
- end
@@ -1,25 +0,0 @@
1
- require 'database_cleaner'
2
-
3
- RSpec.configure do |config|
4
- config.before(:suite) do
5
- DatabaseCleaner.clean_with :truncation
6
- end
7
-
8
- config.before do
9
- DatabaseCleaner.strategy = :transaction
10
- end
11
-
12
- # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
13
- config.before(:each, :js) do
14
- DatabaseCleaner.strategy = :truncation
15
- end
16
-
17
- config.before do
18
- DatabaseCleaner.start
19
- end
20
-
21
- # After each spec clean the database.
22
- config.append_after do
23
- DatabaseCleaner.clean
24
- end
25
- end
@@ -1,67 +0,0 @@
1
- # Requires factories and other useful helpers defined in spree_core.
2
- require 'spree/testing_support/authorization_helpers'
3
- require 'spree/testing_support/capybara_ext'
4
- require 'spree/testing_support/factories'
5
- require 'spree/testing_support/preferences'
6
- require 'spree/testing_support/controller_requests'
7
- require 'spree/testing_support/flash'
8
- require 'spree/testing_support/url_helpers'
9
- require 'spree/testing_support/order_walkthrough'
10
- require 'spree/testing_support/auth_helpers'
11
- require 'spree/testing_support/checkout_helpers'
12
- require 'spree/testing_support/caching'
13
-
14
- # API v2 helpers
15
- if defined?(Spree::Api) && Spree.version.to_f >= 3.7
16
- require 'jsonapi/rspec'
17
- require 'spree/api/testing_support/v2/base'
18
- require 'spree/api/testing_support/matchers/webhooks'
19
- require 'spree/api/testing_support/factories'
20
- require 'spree/api/testing_support/v2/current_order'
21
- require 'spree/api/testing_support/v2/platform_contexts'
22
- require 'spree/api/testing_support/v2/serializers_params'
23
- end
24
-
25
- RSpec.configure do |config|
26
- # Infer an example group's spec type from the file location.
27
- config.infer_spec_type_from_file_location!
28
-
29
- # == URL Helpers
30
- #
31
- # Allows access to Spree's routes in specs:
32
- #
33
- # visit spree.admin_path
34
- # current_path.should eql(spree.products_path)
35
- config.include Spree::TestingSupport::UrlHelpers
36
-
37
- # == Requests support
38
- #
39
- # Adds convenient methods to request Spree's controllers
40
- # spree_get :index
41
- config.include Spree::TestingSupport::ControllerRequests, type: :controller
42
-
43
- config.include Spree::TestingSupport::Preferences
44
- config.include Spree::TestingSupport::Flash
45
-
46
- config.include Spree::TestingSupport::AuthHelpers, type: :feature
47
- config.include Spree::TestingSupport::CheckoutHelpers, type: :feature
48
-
49
- if Spree.version.to_f >= 3.7
50
- config.include JSONAPI::RSpec, type: :request # required for API v2 request specs
51
- end
52
-
53
- config.before :each do
54
- I18n.locale = :en
55
- Rails.cache.clear
56
-
57
- country = create(:country, name: 'United States of America', iso_name: 'UNITED STATES', iso: 'US', states_required: true)
58
-
59
- reset_spree_preferences
60
-
61
- if Spree.version.to_f >= 4.2
62
- create(:store, default: true, default_country: country)
63
- else
64
- create(:store, default: true)
65
- end
66
- end
67
- end
@@ -1,35 +0,0 @@
1
- def update_cart
2
- if Spree.version.to_f < 4.1
3
- click_button 'update-button'
4
- else
5
- page.execute_script("$('form#update-cart').submit()")
6
- end
7
- end
8
-
9
- def cart_container
10
- if Spree.version.to_f < 4.1
11
- find_all("#cart-detail tbody tr:first-child").first
12
- else
13
- find_all("#cart-detail .shopping-cart-item").first
14
- end
15
- end
16
-
17
- def add_to_cart(product)
18
- visit spree.product_path(product)
19
-
20
- expect(page).to have_selector('form#add-to-cart-form')
21
- expect(page).to have_selector(:button, id: 'add-to-cart-button', disabled: false)
22
-
23
- yield if block_given?
24
-
25
- click_button 'add-to-cart-button'
26
-
27
- if Spree.version.to_f < 4.1
28
- wait_for_condition do
29
- expect(page).to have_content(Spree.t(:cart))
30
- end
31
- else
32
- expect(page).to have_content(Spree.t(:added_to_cart))
33
- visit spree.cart_path
34
- end
35
- end