mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #6987 from coopdevs/remove-delegation-specs
Remove unnecessary delegation specs
This commit is contained in:
@@ -189,15 +189,6 @@ describe Enterprise do
|
||||
end
|
||||
end
|
||||
|
||||
describe "delegations" do
|
||||
# subject { FactoryBot.create(:distributor_enterprise, :address => FactoryBot.create(:address)) }
|
||||
|
||||
it { is_expected.to delegate(:latitude).to(:address) }
|
||||
it { is_expected.to delegate(:longitude).to(:address) }
|
||||
it { is_expected.to delegate(:city).to(:address) }
|
||||
it { is_expected.to delegate(:state_name).to(:address) }
|
||||
end
|
||||
|
||||
describe "callbacks" do
|
||||
it "restores permalink to original value when it is changed and invalid" do
|
||||
e1 = create(:enterprise, permalink: "taken")
|
||||
|
||||
@@ -10,10 +10,6 @@ describe Spree::Address do
|
||||
it { is_expected.to have_one(:enterprise) }
|
||||
end
|
||||
|
||||
describe "delegation" do
|
||||
it { is_expected.to delegate(:name).to(:state).with_prefix }
|
||||
end
|
||||
|
||||
describe "destroy" do
|
||||
it "can be deleted" do
|
||||
expect { address.destroy }.to_not raise_error
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# RSpec matcher to spec delegations.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# describe Post do
|
||||
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
|
||||
# it { should delegate(:month).to(:created_at) }
|
||||
# it { should delegate(:year).to(:created_at) }
|
||||
# end
|
||||
|
||||
RSpec::Matchers.define :delegate do |method|
|
||||
match do |delegator|
|
||||
@method = @prefix ? :"#{@to}_#{method}" : method
|
||||
@delegator = delegator
|
||||
begin
|
||||
@delegator.send(@to)
|
||||
rescue NoMethodError
|
||||
raise "#{@delegator} does not respond to #{@to}!"
|
||||
end
|
||||
@delegator.stub(@to).and_return double('receiver')
|
||||
@delegator.send(@to).stub(method).and_return :called
|
||||
@delegator.send(@method) == :called
|
||||
end
|
||||
|
||||
description do
|
||||
"delegate :#{@method} to its #{@to}#{@prefix ? ' with prefix' : ''}"
|
||||
end
|
||||
|
||||
failure_message do |_text|
|
||||
"expected #{@delegator} to delegate :#{@method} to its #{@to}#{@prefix ? ' with prefix' : ''}"
|
||||
end
|
||||
|
||||
failure_message_when_negated do |_text|
|
||||
"expected #{@delegator} not to delegate :#{@method} to its #{@to}#{@prefix ? ' with prefix' : ''}"
|
||||
end
|
||||
|
||||
chain(:to) { |receiver| @to = receiver }
|
||||
chain(:with_prefix) { @prefix = true }
|
||||
end
|
||||
Reference in New Issue
Block a user