Skip to content

Commit

Permalink
Merge pull request #2234 from cbrunsdon/remove_rspec_monkeypatching
Browse files Browse the repository at this point in the history
Remove rspec monkeypatching
  • Loading branch information
cbrunsdon authored Sep 22, 2017
2 parents 031597e + 728466f commit 75708a6
Show file tree
Hide file tree
Showing 240 changed files with 275 additions and 274 deletions.
18 changes: 9 additions & 9 deletions core/lib/spree/testing_support/ability_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
shared_examples_for 'access granted' do
RSpec.shared_examples_for 'access granted' do
it 'should allow read' do
expect(ability).to be_able_to(:read, resource, token) if token
expect(ability).to be_able_to(:read, resource) unless token
Expand All @@ -15,7 +15,7 @@
end
end

shared_examples_for 'access denied' do
RSpec.shared_examples_for 'access denied' do
it 'should not allow read' do
expect(ability).to_not be_able_to(:read, resource)
end
Expand All @@ -29,32 +29,32 @@
end
end

shared_examples_for 'admin granted' do
RSpec.shared_examples_for 'admin granted' do
it 'should allow admin' do
expect(ability).to be_able_to(:admin, resource, token) if token
expect(ability).to be_able_to(:admin, resource) unless token
end
end

shared_examples_for 'admin denied' do
RSpec.shared_examples_for 'admin denied' do
it 'should not allow admin' do
expect(ability).to_not be_able_to(:admin, resource)
end
end

shared_examples_for 'index allowed' do
RSpec.shared_examples_for 'index allowed' do
it 'should allow index' do
expect(ability).to be_able_to(:index, resource)
end
end

shared_examples_for 'no index allowed' do
RSpec.shared_examples_for 'no index allowed' do
it 'should not allow index' do
expect(ability).to_not be_able_to(:index, resource)
end
end

shared_examples_for 'create only' do
RSpec.shared_examples_for 'create only' do
it 'should allow create' do
expect(ability).to be_able_to(:create, resource)
end
Expand All @@ -72,7 +72,7 @@
end
end

shared_examples_for 'read only' do
RSpec.shared_examples_for 'read only' do
it 'should not allow create' do
expect(ability).to_not be_able_to(:create, resource)
end
Expand All @@ -86,7 +86,7 @@
end
end

shared_examples_for 'update only' do
RSpec.shared_examples_for 'update only' do
it 'should not allow create' do
expect(ability).to_not be_able_to(:create, resource)
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/helpers/base_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::BaseHelper, type: :helper do
RSpec.describe Spree::BaseHelper, type: :helper do
include Spree::BaseHelper

let(:current_store){ create :store }
Expand Down
2 changes: 1 addition & 1 deletion core/spec/helpers/products_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rails_helper'

module Spree
describe ProductsHelper, type: :helper do
RSpec.describe ProductsHelper, type: :helper do
include ProductsHelper

let(:product) { create(:product, price: product_price) }
Expand Down
2 changes: 1 addition & 1 deletion core/spec/helpers/taxons_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::TaxonsHelper, type: :helper do
RSpec.describe Spree::TaxonsHelper, type: :helper do
# Regression test for https://github.com/spree/spree/issues/4382
it "#taxon_preview" do
taxon = create(:taxon)
Expand Down
2 changes: 1 addition & 1 deletion core/spec/jobs/promotion_code_batch_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rails_helper'
describe Spree::PromotionCodeBatchJob, type: :job do
RSpec.describe Spree::PromotionCodeBatchJob, type: :job do
let(:email) { "[email protected]" }
let(:promotion_code_batch) do
Spree::PromotionCodeBatch.create!(
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/calculated_adjustments_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::CalculatedAdjustments do
RSpec.describe Spree::CalculatedAdjustments do
let(:calculator_class) { Spree::Calculator::FlatRate }

with_model :Calculable, scope: :all do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'spree/i18n'
require 'spree/testing_support/i18n'

describe "i18n" do
RSpec.describe "i18n" do
before do
I18n.backend.store_translations(:en,
{
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/search/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::Core::Search::Base do
RSpec.describe Spree::Core::Search::Base do
before do
include Spree::Core::ProductFilters
@taxon = create(:taxon, name: "Ruby on Rails")
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/search/variant_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Spree
describe Core::Search::Variant do
RSpec.describe Core::Search::Variant do
def assert_found(query_string, variant)
expect(described_class.new(query_string).results).to include variant
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/class_constantizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.reload
end
end

describe Spree::Core::ClassConstantizer::Set do
RSpec.describe Spree::Core::ClassConstantizer::Set do
let(:set) { described_class.new }

describe "#concat" do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/controller_helpers/auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class FakesController < ApplicationController
def index; render plain: 'index'; end
end

describe Spree::Core::ControllerHelpers::Auth, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::Auth, type: :controller do
controller(FakesController) {}

describe '#current_ability' do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/controller_helpers/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FakesController < ApplicationController
include Spree::Core::ControllerHelpers::Order
end

describe Spree::Core::ControllerHelpers::Order, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::Order, type: :controller do
controller(FakesController) {}

let(:user) { create(:user) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::Core::ControllerHelpers::PaymentParameters, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::PaymentParameters, type: :controller do
controller(ApplicationController) do
include Spree::Core::ControllerHelpers::PaymentParameters
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FakesController < ApplicationController
include Spree::Core::ControllerHelpers::Pricing
end

describe Spree::Core::ControllerHelpers::Pricing, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::Pricing, type: :controller do
controller(FakesController) {}

before do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/controller_helpers/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FakesController < ApplicationController
include Spree::Core::ControllerHelpers::Search
end

describe Spree::Core::ControllerHelpers::Search, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::Search, type: :controller do
controller(FakesController) {}

describe '#build_searcher' do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/controller_helpers/store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FakesController < ApplicationController
include Spree::Core::ControllerHelpers::Store
end

describe Spree::Core::ControllerHelpers::Store, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::Store, type: :controller do
controller(FakesController) {}

describe '#current_store' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FakesController < ApplicationController
include Spree::Core::ControllerHelpers::StrongParameters
end

describe Spree::Core::ControllerHelpers::StrongParameters, type: :controller do
RSpec.describe Spree::Core::ControllerHelpers::StrongParameters, type: :controller do
controller(FakesController) {}

describe '#permitted_attributes' do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/current_store_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::Core::CurrentStore do
RSpec.describe Spree::Core::CurrentStore do
describe "#store" do
subject { Spree::Deprecation.silence { Spree::Core::CurrentStore.new(request).store } }

Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/environment_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class C1; end
class C2; end
class C3; end

describe Spree::Core::EnvironmentExtension do
RSpec.describe Spree::Core::EnvironmentExtension do
subject { DummyClass.new }

before { subject.add_class('random_name') }
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/importer/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Spree
module Core
describe Importer::Order do
RSpec.describe Importer::Order do
let!(:store) { create(:store) }
let!(:country) { create(:country) }
let!(:state) { country.states.first || create(:state, country: country) }
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/role_configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::RoleConfiguration do
RSpec.describe Spree::RoleConfiguration do
class DummyPermissionSet < Spree::PermissionSets::Base
def activate!
can :manage, :things
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'spree/testing_support/factories/order_factory'

shared_examples "shipping methods are assigned" do
RSpec.shared_examples "shipping methods are assigned" do
context "given a shipping method" do
let(:shipping_method) { create(:shipping_method) }

Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/validators/email_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'spree/core/validators/email'

describe EmailValidator do
RSpec.describe EmailValidator do
class Tester
include ActiveModel::Validations
attr_accessor :email_address
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/version_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe Spree do
RSpec.describe Spree do
describe '.solidus_version' do
it "returns a string" do
expect(Spree.solidus_version).to be_a(String)
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/localized_number_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'spree/localized_number'

describe Spree::LocalizedNumber do
RSpec.describe Spree::LocalizedNumber do
context ".parse" do
before do
I18n.enforce_available_locales = false
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/migrations_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

module Spree
describe Migrations do
RSpec.describe Migrations do
let(:app_migrations) { [".", "34_add_title.rb", "52_add_text.rb"] }
let(:engine_migrations) { [".", "334_create_orders.spree.rb", "777_create_products.spree.rb"] }

Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'
require 'spree/money'

describe Spree::Money do
RSpec.describe Spree::Money do
before do
configure_spree_preferences do |config|
config.currency = "USD"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::PermissionSets::DefaultCustomer do
RSpec.describe Spree::PermissionSets::DefaultCustomer do
context 'as Guest User' do
context 'for Order' do
context 'guest_token is empty string' do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/tasks/dummy_task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe 'dummy_task' do
RSpec.describe 'dummy_task' do
include_context(
'rake',
task_name: 'dummy_task',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe 'solidus:migrations:migrate_shipping_rate_taxes' do
RSpec.describe 'solidus:migrations:migrate_shipping_rate_taxes' do
describe 'up' do
include_context(
'rake',
Expand Down
2 changes: 1 addition & 1 deletion core/spec/mailers/carton_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'email_spec'

describe Spree::CartonMailer do
RSpec.describe Spree::CartonMailer do
include EmailSpec::Helpers
include EmailSpec::Matchers

Expand Down
2 changes: 1 addition & 1 deletion core/spec/mailers/order_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'email_spec'

describe Spree::OrderMailer, type: :mailer do
RSpec.describe Spree::OrderMailer, type: :mailer do
include EmailSpec::Helpers
include EmailSpec::Matchers

Expand Down
2 changes: 1 addition & 1 deletion core/spec/mailers/promotion_code_batch_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rails_helper'
describe Spree::PromotionCodeBatchMailer, type: :mailer do
RSpec.describe Spree::PromotionCodeBatchMailer, type: :mailer do
let(:promotion) { create(:promotion, name: "Promotion Test") }
let(:promotion_code_batch) do
Spree::PromotionCodeBatch.create!(
Expand Down
2 changes: 1 addition & 1 deletion core/spec/mailers/reimbursement_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'email_spec'

describe Spree::ReimbursementMailer, type: :mailer do
RSpec.describe Spree::ReimbursementMailer, type: :mailer do
include EmailSpec::Helpers
include EmailSpec::Matchers

Expand Down
2 changes: 1 addition & 1 deletion core/spec/mailers/test_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'
require 'email_spec'

describe Spree::TestMailer, type: :mailer do
RSpec.describe Spree::TestMailer, type: :mailer do
include EmailSpec::Helpers
include EmailSpec::Matchers

Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(_user)
end
end

describe Spree::Ability, type: :model do
RSpec.describe Spree::Ability, type: :model do
let(:user) { build(:user) }
let(:ability) { Spree::Ability.new(user) }
let(:token) { nil }
Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/address_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::Address, type: :model do
RSpec.describe Spree::Address, type: :model do
subject { Spree::Address }

context "aliased attributes" do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/adjustment_reason_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Spree::AdjustmentReason do
RSpec.describe Spree::AdjustmentReason do
describe 'creation' do
it 'is successful' do
create(:adjustment_reason)
Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require 'rails_helper'

describe Spree::Adjustment, type: :model do
RSpec.describe Spree::Adjustment, type: :model do
let!(:store) { create :store }
let(:order) { Spree::Order.new }
let(:line_item) { create :line_item, order: order }
Expand Down
Loading

0 comments on commit 75708a6

Please sign in to comment.