Sha256: 79a1790b951ce8831e4db92b745938888426a54972e17c00e2bb42f42352fd86

Contents?: true

Size: 775 Bytes

Versions: 2

Compression:

Stored size: 775 Bytes

Contents

shared_examples_for :it_has_a_dependency_accessor do |accessor_name|
  describe accessor_name.to_s do
    it "returns the #{accessor_name} object as assigned" do
      subject.send("#{accessor_name}=", :thing)
      expect(subject.send(accessor_name)).to eq :thing
    end

    context "when the #{accessor_name} object is not set" do
      it 'raises a StandardError' do
        expect{ subject.send(accessor_name) }.to raise_error(StandardError)
      end

      it "explains that the #{accessor_name} was not set on initialiation" do
        begin
          subject.send(accessor_name)
        rescue StandardError => e
          expect(e.message).to eq "No #{accessor_name} object was set on #{subject.class.name} initialization."
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kookaburra-3.0.1 spec/support/shared_examples/it_has_a_dependency_accessor.rb
kookaburra-3.0.0 spec/support/shared_examples/it_has_a_dependency_accessor.rb