From c39947bebcec6a5073e33b64053fbe9589da11ee Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 25 Mar 2021 12:20:16 -0500 Subject: Fix remaining rubocop violations in spec --- .rubocop_todo.yml | 66 ---------------------- .../spree/admin/subscriptions_controller_spec.rb | 36 ++++++------ .../spree/api/line_items_controller_spec.rb | 10 ++-- .../spree/api/orders_controller_spec.rb | 2 +- .../controllers/spree/api/users_controller_spec.rb | 4 +- .../create_subscription_line_items_spec.rb | 12 ++-- .../order/finalize_creates_subscriptions_spec.rb | 6 +- .../spree/user/have_many_subscriptions_spec.rb | 4 +- .../features/admin_users_subscription_tabs_spec.rb | 7 ++- spec/lib/solidus_subscriptions/checkout_spec.rb | 4 +- .../installment_detail_spec.rb | 4 +- .../solidus_subscriptions/installment_spec.rb | 32 +++++------ .../models/solidus_subscriptions/line_item_spec.rb | 4 +- .../solidus_subscriptions/subscription_spec.rb | 18 +++--- spec/models/spree/variant_spec.rb | 6 +- 15 files changed, 77 insertions(+), 138 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4edc2f5..195ab44 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,12 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -Lint/AmbiguousBlockAssociation: - Exclude: - - 'spec/controllers/spree/admin/subscriptions_controller_spec.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - # Offense count: 1 Lint/MissingSuper: Exclude: @@ -24,69 +18,10 @@ Naming/MemoizedInstanceVariableName: Exclude: - 'lib/solidus_subscriptions/processor.rb' -# Offense count: 1 -RSpec/AnyInstance: - Exclude: - - 'spec/jobs/solidus_subscriptions/process_installments_job_spec.rb' - -# Offense count: 46 -# Configuration parameters: Prefixes. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb' - - 'spec/controllers/spree/admin/subscriptions_controller_spec.rb' - - 'spec/lib/solidus_subscriptions/ability_spec.rb' - - 'spec/lib/solidus_subscriptions/processor_spec.rb' - - 'spec/models/solidus_subscriptions/installment_detail_spec.rb' - - 'spec/models/solidus_subscriptions/installment_spec.rb' - - 'spec/models/solidus_subscriptions/line_item_spec.rb' - - 'spec/models/solidus_subscriptions/subscription_spec.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - - 'spec/services/solidus_subscriptions/line_item_builder_spec.rb' - - 'spec/services/solidus_subscriptions/order_builder_spec.rb' - -# Offense count: 2 -# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly. -RSpec/FilePath: - Exclude: - - 'spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb' - - 'spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb' - -# Offense count: 1 -# Configuration parameters: AssignmentOnly. -RSpec/InstanceVariable: - Exclude: - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - -# Offense count: 18 -RSpec/LetSetup: - Exclude: - - 'spec/controllers/solidus_subscriptions/api/v1/subscriptions_controller_spec.rb' - - 'spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb' - - 'spec/lib/solidus_subscriptions/processor_spec.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - - 'spec/services/solidus_subscriptions/line_item_builder_spec.rb' - -# Offense count: 8 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - Exclude: - - 'spec/services/solidus_subscriptions/failure_dispatcher_spec.rb' - - 'spec/services/solidus_subscriptions/out_of_stock_dispatcher_spec.rb' - - 'spec/services/solidus_subscriptions/payment_failed_dispatcher_spec.rb' - - 'spec/services/solidus_subscriptions/success_dispatcher_spec.rb' - # Offense count: 2 RSpec/MultipleExpectations: Max: 2 -# Offense count: 27 -# Configuration parameters: AllowSubject. -RSpec/MultipleMemoizedHelpers: - Max: 14 - # Offense count: 90 # Configuration parameters: IgnoreSharedExamples. RSpec/NamedSubject: @@ -120,7 +55,6 @@ Rails/SkipsModelValidations: - 'app/services/solidus_subscriptions/failure_dispatcher.rb' - 'app/services/solidus_subscriptions/order_builder.rb' - 'app/services/solidus_subscriptions/payment_failed_dispatcher.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' # Offense count: 1 # Cop supports --auto-correct. diff --git a/spec/controllers/spree/admin/subscriptions_controller_spec.rb b/spec/controllers/spree/admin/subscriptions_controller_spec.rb index c12c0f7..a2fc8e6 100644 --- a/spec/controllers/spree/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/spree/admin/subscriptions_controller_spec.rb @@ -112,75 +112,75 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :request do end describe 'POST cancel' do - subject { delete spree.cancel_admin_subscription_path(subscription) } + subject(:delete_subscription) { delete spree.cancel_admin_subscription_path(subscription) } - context 'the subscription can be canceled' do + context 'when the subscription can be canceled' do let(:subscription) { create :subscription, :actionable } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + delete_subscription expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.to change { subscription.reload.state }.from('active').to('canceled') + expect { delete_subscription }.to change { subscription.reload.state }.from('active').to('canceled') end end - context 'the subscription cannot be canceled' do + context 'when the subscription cannot be canceled' do let(:subscription) { create :subscription, :canceled } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + delete_subscription expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.not_to change { subscription.reload.state } + expect { delete_subscription }.not_to(change { subscription.reload.state }) end end end describe 'POST activate' do - subject { post spree.activate_admin_subscription_path(subscription) } + subject(:activate) { post spree.activate_admin_subscription_path(subscription) } - context 'the subscription can be activated' do + context 'when the subscription can be activated' do let(:subscription) { create :subscription, :canceled, :with_line_item } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + activate expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.to change { subscription.reload.state }.from('canceled').to('active') + expect { activate }.to change { subscription.reload.state }.from('canceled').to('active') end end - context 'the subscription cannot be activated' do + context 'when the subscription cannot be activated' do let(:subscription) { create :subscription, :actionable, :with_line_item } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + activate expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.not_to change { subscription.reload.state } + expect { activate }.not_to(change{ subscription.reload.state }) end end end describe 'POST skip' do - subject { post spree.skip_admin_subscription_path(subscription) } + subject(:skip) { post spree.skip_admin_subscription_path(subscription) } let(:subscription) { create :subscription, :actionable, :with_line_item } let!(:expected_date) { subscription.next_actionable_date } @@ -188,12 +188,12 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :request do it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + skip expect(flash[:notice]).to be_present end - it 'advances the actioanble_date' do - expect { subject }. + it 'advances the actionable_date' do + expect { skip }. to change { subscription.reload.actionable_date }. from(subscription.actionable_date).to(expected_date) end diff --git a/spec/controllers/spree/api/line_items_controller_spec.rb b/spec/controllers/spree/api/line_items_controller_spec.rb index 8903ebe..8dc6390 100644 --- a/spec/controllers/spree/api/line_items_controller_spec.rb +++ b/spec/controllers/spree/api/line_items_controller_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do routes { Spree::Core::Engine.routes } describe 'POST :create' do - subject { post :create, params: params } + subject(:post_create) { post :create, params: params } let(:params) { line_item_params } let!(:variant) { create :variant } @@ -30,7 +30,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do it { is_expected.to be_created } it 'creates a line item' do - expect { subject }. + expect { post_create }. to change { Spree::LineItem.count }. from(0).to(1) end @@ -53,7 +53,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do it_behaves_like 'a new line item' it 'creates a new subscription line item' do - expect { subject }. + expect { post_create }. to change { SolidusSubscriptions::LineItem.count }. from(0).to(1) end @@ -65,7 +65,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do end describe 'patch :update' do - subject { patch :create, params: params } + subject(:patch_create) { patch :create, params: params } let(:params) { line_item_params } let!(:variant) { create :variant } @@ -95,7 +95,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do it { is_expected.to be_successful } it 'creates a new subscription line item' do - expect { subject }. + expect { patch_create }. to change { SolidusSubscriptions::LineItem.count }. from(0).to(1) end diff --git a/spec/controllers/spree/api/orders_controller_spec.rb b/spec/controllers/spree/api/orders_controller_spec.rb index 1b65ed6..5f32a56 100644 --- a/spec/controllers/spree/api/orders_controller_spec.rb +++ b/spec/controllers/spree/api/orders_controller_spec.rb @@ -45,7 +45,7 @@ RSpec.describe Spree::Api::OrdersController, type: :controller do end it 'is a successful response' do - subject + subscription_line_items expect(response).to be_successful end diff --git a/spec/controllers/spree/api/users_controller_spec.rb b/spec/controllers/spree/api/users_controller_spec.rb index 21d5185..5b1bb42 100644 --- a/spec/controllers/spree/api/users_controller_spec.rb +++ b/spec/controllers/spree/api/users_controller_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Spree::Api::UsersController, type: :controller do let!(:subscription) { create :subscription, :with_line_item, user: user } describe 'patch /update' do - subject { patch :update, params: params } + subject(:update_user) { patch :update, params: params } let(:params) do { @@ -39,7 +39,7 @@ RSpec.describe Spree::Api::UsersController, type: :controller do end it 'updates the subscription line items' do - subject + update_user line_item = subscription.line_items.reload.first expect(line_item).to have_attributes(line_item_attributes) diff --git a/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb b/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb index 38a0cc9..d3c3ce9 100644 --- a/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb +++ b/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb @@ -7,14 +7,14 @@ RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscription routes { Spree::Core::Engine.routes } let!(:user) { create :user } - let!(:store) { create :store } before do allow(controller).to receive_messages(try_spree_current_user: user) + create :store end describe 'POST /orders/populate' do - subject { post :populate, params: params } + subject(:populate) { post :populate, params: params } let!(:variant) { create :variant } let(:params) { line_item_params } @@ -29,13 +29,13 @@ RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscription it { is_expected.to redirect_to cart_path } it 'creates an order' do - expect { subject }. + expect { populate }. to change { Spree::Order.count }. from(0).to(1) end it 'creates a line item' do - expect { subject }. + expect { populate }. to change { Spree::LineItem.count }. from(0).to(1) end @@ -58,13 +58,13 @@ RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscription it_behaves_like 'a new order line item' it 'creates a new subscription line item' do - expect { subject }. + expect { populate }. to change { SolidusSubscriptions::LineItem.count }. from(0).to(1) end it 'creates a subscription line item with the correct values' do - subject + populate subscription_line_item = SolidusSubscriptions::LineItem.last expect(subscription_line_item).to have_attributes( diff --git a/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb index 3aa1cc4..121afbf 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions do describe '#finalize!' do - subject { order.finalize! } + subject(:finalize) { order.finalize! } let(:order) { create :order, :with_subscription_line_items } let(:subscription_line_item) { order.subscription_line_items.last } @@ -13,13 +13,13 @@ RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions around { |e| Timecop.freeze { e.run } } it 'creates new subscriptions' do - expect { subject }. + expect { finalize }. to change { SolidusSubscriptions::Subscription.count }. by(order.subscription_line_items.count) end it 'creates a subscription with the correct values' do - subject + finalize subscription = SolidusSubscriptions::Subscription.last expect(subscription).to have_attributes( diff --git a/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb index f15afbe..4047b01 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: :model do - subject { Spree::User.new } + subject(:user) { Spree::User.new } it { is_expected.to have_many :subscriptions } it { is_expected.to accept_nested_attributes_for :subscriptions } @@ -12,7 +12,7 @@ RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: : it 'throws a deprecation warning' do allow(::Spree::Deprecation).to receive(:warn) - subject.subscriptions_attributes = [{ interval_length: 2 }] + user.subscriptions_attributes = [{ interval_length: 2 }] expect(::Spree::Deprecation) .to have_received(:warn) diff --git a/spec/features/admin_users_subscription_tabs_spec.rb b/spec/features/admin_users_subscription_tabs_spec.rb index 6317a09..50bd93f 100644 --- a/spec/features/admin_users_subscription_tabs_spec.rb +++ b/spec/features/admin_users_subscription_tabs_spec.rb @@ -29,10 +29,15 @@ RSpec.describe 'User subscriptions tab', type: :feature do within('.tabs') { click_link 'Subscriptions' } end - it 'lists user subscriptions' do + it 'lists user subscriptions date' do subscriptions_table = page.find('#subscriptions-table') expect(subscriptions_table).to have_content('2020-10-21') + end + + it 'lists user subscriptions days' do + subscriptions_table = page.find('#subscriptions-table') + expect(subscriptions_table).to have_content('10 days') end diff --git a/spec/lib/solidus_subscriptions/checkout_spec.rb b/spec/lib/solidus_subscriptions/checkout_spec.rb index b43b6f2..25cbcf4 100644 --- a/spec/lib/solidus_subscriptions/checkout_spec.rb +++ b/spec/lib/solidus_subscriptions/checkout_spec.rb @@ -2,6 +2,7 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do context 'when the order can be created and paid' do + # rubocop:disable RSpec/MultipleExpectations it 'creates and finalizes a new order for the installment' do stub_spree_preferences(auto_capture: true) installment = create(:installment, :actionable) @@ -12,7 +13,6 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do expect(order).to be_paid end - # rubocop:disable RSpec/MultipleExpectations it 'copies basic information from the subscription' do stub_spree_preferences(auto_capture: true) installment = create(:installment, :actionable) @@ -28,7 +28,6 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do expect(order.user).to eq(subscription.user) expect(order.email).to eq(subscription.user.email) end - # rubocop:enable RSpec/MultipleExpectations it 'marks the order as a subscription order' do stub_spree_preferences(auto_capture: true) @@ -40,6 +39,7 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do expect(order.subscription).to eq(subscription) expect(order.subscription_order).to eq(true) end + # rubocop:enable RSpec/MultipleExpectations it 'matches the total on the subscription' do stub_spree_preferences(auto_capture: true) diff --git a/spec/models/solidus_subscriptions/installment_detail_spec.rb b/spec/models/solidus_subscriptions/installment_detail_spec.rb index 5866260..8c03f4d 100644 --- a/spec/models/solidus_subscriptions/installment_detail_spec.rb +++ b/spec/models/solidus_subscriptions/installment_detail_spec.rb @@ -8,13 +8,13 @@ RSpec.describe SolidusSubscriptions::InstallmentDetail, type: :model do describe '#failed?' do subject { build(:installment_detail, success: success).failed? } - context 'the detail was successful' do + context 'when the detail was successful' do let(:success) { true } it { is_expected.to be_falsy } end - context 'the detail was not successfuly' do + context 'when the detail was not successfuly' do let(:success) { false } it { is_expected.to be_truthy } diff --git a/spec/models/solidus_subscriptions/installment_spec.rb b/spec/models/solidus_subscriptions/installment_spec.rb index daaedb7..289bf8a 100644 --- a/spec/models/solidus_subscriptions/installment_spec.rb +++ b/spec/models/solidus_subscriptions/installment_spec.rb @@ -8,7 +8,7 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do it { is_expected.to validate_presence_of :subscription } describe '#out_of_stock' do - subject { installment.out_of_stock } + subject(:out_of_stock) { installment.out_of_stock } let(:expected_date) do Time.zone.today + SolidusSubscriptions.configuration.reprocessing_interval @@ -18,20 +18,20 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do it { is_expected.not_to be_successful } it 'has the correct message' do - expect(subject).to have_attributes( + expect(out_of_stock).to have_attributes( message: I18n.t('solidus_subscriptions.installment_details.out_of_stock') ) end it 'advances the installment actionable_date' do - subject + out_of_stock actionable_date = installment.reload.actionable_date expect(actionable_date).to eq expected_date end end describe '#success!' do - subject { installment.success!(order) } + subject(:success) { installment.success!(order) } let(:order) { create :order } @@ -39,19 +39,19 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do let(:actionable_date) { 1.month.from_now.to_date } it 'removes any actionable date if any' do - expect { subject }. + expect { success }. to change(installment, :actionable_date). from(actionable_date).to(nil) end it 'creates a new installment detail' do - expect { subject }. + expect { success }. to change { SolidusSubscriptions::InstallmentDetail.count }. by(1) end it 'creates a successful installment detail' do - subject + success expect(installment.details.last).to be_successful && have_attributes( order: order, message: I18n.t('solidus_subscriptions.installment_details.success') @@ -60,7 +60,7 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do end describe '#failed!' do - subject { installment.failed!(order) } + subject(:failed) { installment.failed!(order) } let(:order) { create :order } @@ -72,23 +72,23 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do it { is_expected.not_to be_successful } it 'has the correct message' do - expect(subject).to have_attributes( + expect(failed).to have_attributes( message: I18n.t('solidus_subscriptions.installment_details.failed'), order: order ) end it 'advances the installment actionable_date' do - subject + failed actionable_date = installment.reload.actionable_date expect(actionable_date).to eq expected_date end - context 'the reprocessing interval is set to nil' do + context 'when the reprocessing interval is set to nil' do before { stub_config(reprocessing_interval: nil) } it 'does not advance the installment actionable_date' do - subject + failed actionable_date = installment.reload.actionable_date expect(actionable_date).to be_nil end @@ -100,13 +100,13 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do let(:installment) { create(:installment, details: details) } - context 'the installment has an associated successful detail' do + context 'when the installment has an associated successful detail' do let(:details) { create_list :installment_detail, 1, success: true } it { is_expected.to be_falsy } end - context 'the installment has no associated successful detail' do + context 'when the installment has no associated successful detail' do let(:details) { create_list :installment_detail, 1 } it { is_expected.to be_truthy } @@ -118,13 +118,13 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do let(:installment) { create(:installment, details: details) } - context 'the installment has an associated completed order' do + context 'when the installment has an associated completed order' do let(:details) { create_list :installment_detail, 1, success: true } it { is_expected.to be_truthy } end - context 'the installment has no associated completed order' do + context 'when the installment has no associated completed order' do let(:details) { create_list :installment_detail, 1 } it { is_expected.to be_falsy } diff --git a/spec/models/solidus_subscriptions/line_item_spec.rb b/spec/models/solidus_subscriptions/line_item_spec.rb index d9301a6..d7c1bdb 100644 --- a/spec/models/solidus_subscriptions/line_item_spec.rb +++ b/spec/models/solidus_subscriptions/line_item_spec.rb @@ -9,7 +9,7 @@ RSpec.describe SolidusSubscriptions::LineItem, type: :model do it { is_expected.to validate_numericality_of(:interval_length).is_greater_than(0) } describe "#interval" do - subject { line_item.interval } + subject(:interval) { line_item.interval } let(:line_item) { create :subscription_line_item, :with_subscription } @@ -23,7 +23,7 @@ RSpec.describe SolidusSubscriptions::LineItem, type: :model do it { is_expected.to be_a ActiveSupport::Duration } it "calculates the duration correctly" do - expect(subject.from_now).to eq Date.parse("2016-10-22") + expect(interval.from_now).to eq Date.parse("2016-10-22") end end end diff --git a/spec/models/solidus_subscriptions/subscription_spec.rb b/spec/models/solidus_subscriptions/subscription_spec.rb index 4f7d05d..145cc44 100644 --- a/spec/models/solidus_subscriptions/subscription_spec.rb +++ b/spec/models/solidus_subscriptions/subscription_spec.rb @@ -104,7 +104,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do allow(SolidusSubscriptions.configuration).to receive(:minimum_cancellation_notice) { minimum_cancellation_notice } end - context 'the subscription can be canceled' do + context 'when the subscription can be canceled' do let(:actionable_date) { 1.month.from_now } let(:minimum_cancellation_notice) { 1.day } @@ -119,7 +119,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription cannot be canceled' do + context 'when the subscription cannot be canceled' do let(:actionable_date) { Date.current } let(:minimum_cancellation_notice) { 1.day } @@ -213,7 +213,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription can be deactivated' do + context 'when the subscription can be deactivated' do let(:attributes) do { end_date: Date.current.ago(2.days) } end @@ -229,7 +229,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription cannot be deactivated' do + context 'when the subscription cannot be deactivated' do it { is_expected.to be_falsy } it 'does not create an event' do @@ -263,7 +263,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription cannot be activated' do + context 'when the subscription cannot be activated' do it 'returns false' do subscription = create(:subscription, actionable_date: Time.zone.today) @@ -402,25 +402,25 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do let!(:failed_subs) { create_list(:installment, 2, :failed).map(&:subscription) } let!(:success_subs) { create_list(:installment, 2, :success).map(&:subscription) } - context 'successfull subscriptions' do + context 'with successfull subscriptions' do let(:state) { :success } it { is_expected.to match_array success_subs } end - context 'failed subscriptions' do + context 'with failed subscriptions' do let(:state) { :failed } it { is_expected.to match_array failed_subs } end - context 'new subscriptions' do + context 'with new subscriptions' do let(:state) { :pending } it { is_expected.to match_array new_subs } end - context 'unknown state' do + context 'with unknown state' do let(:state) { :foo } it 'raises an error' do diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 255b46b..3627fc7 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -6,11 +6,11 @@ RSpec.describe Spree::Variant, type: :model do let(:variant) { build_stubbed :variant } describe "#pretty_name" do - subject { variant.pretty_name } + subject(:pretty_name) { variant.pretty_name } it 'includes the product and options', :aggregate_failures do - expect(subject).to match variant.name - expect(subject).to match variant.options_text + expect(pretty_name).to match variant.name + expect(pretty_name).to match variant.options_text end end end -- cgit v1.2.3