Skip to content

Commit

Permalink
Adds out of stock check as helper
Browse files Browse the repository at this point in the history
As shared examoples, in guest_spec.rb
  • Loading branch information
filipefurtad0 committed Apr 30, 2024
1 parent 0f80aca commit 0d4bd68
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/system/consumer/checkout/guest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,30 @@
end
end
end

shared_examples "when a line item is out of stock" do |session, step|
context "as a #{session} user" do
let(:user) { create(:user) }
before do
variant.on_demand = false
variant.on_hand = 0
variant.save!

Check warning on line 303 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: spec/system/consumer/checkout/guest_spec.rb:303:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.
if session == "logged"
login_as(user)
end
end
it "returns me to the cart with an error message" do
out_of_stock_check(step)
end
end
end

it_behaves_like "when a line item is out of stock", "guest", "#{:details}"

Check warning on line 314 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Prefer `to_s` over string interpolation. Raw Output: spec/system/consumer/checkout/guest_spec.rb:314:64: C: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.

Check warning on line 314 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Literal interpolation detected. Raw Output: spec/system/consumer/checkout/guest_spec.rb:314:67: W: Lint/LiteralInInterpolation: Literal interpolation detected.
it_behaves_like "when a line item is out of stock", "guest", "#{:payment}"

Check warning on line 315 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Prefer `to_s` over string interpolation. Raw Output: spec/system/consumer/checkout/guest_spec.rb:315:64: C: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.

Check warning on line 315 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Literal interpolation detected. Raw Output: spec/system/consumer/checkout/guest_spec.rb:315:67: W: Lint/LiteralInInterpolation: Literal interpolation detected.
it_behaves_like "when a line item is out of stock", "guest", "#{:summary}"

Check warning on line 316 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Prefer `to_s` over string interpolation. Raw Output: spec/system/consumer/checkout/guest_spec.rb:316:64: C: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.

Check warning on line 316 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Literal interpolation detected. Raw Output: spec/system/consumer/checkout/guest_spec.rb:316:67: W: Lint/LiteralInInterpolation: Literal interpolation detected.

it_behaves_like "when a line item is out of stock", "logged", "#{:details}"

Check warning on line 318 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Prefer `to_s` over string interpolation. Raw Output: spec/system/consumer/checkout/guest_spec.rb:318:65: C: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.

Check warning on line 318 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Literal interpolation detected. Raw Output: spec/system/consumer/checkout/guest_spec.rb:318:68: W: Lint/LiteralInInterpolation: Literal interpolation detected.
it_behaves_like "when a line item is out of stock", "logged", "#{:payment}"

Check warning on line 319 in spec/system/consumer/checkout/guest_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Prefer `to_s` over string interpolation. Raw Output: spec/system/consumer/checkout/guest_spec.rb:319:65: C: Style/RedundantInterpolation: Prefer `to_s` over string interpolation.
it_behaves_like "when a line item is out of stock", "logged", "#{:summary}"
end

0 comments on commit 0d4bd68

Please sign in to comment.