Sha256: bf8ca496bb03a5d66f76a062aa94f40bfb1d314780b570867deb01efbbe3d5b4
Contents?: true
Size: 1.75 KB
Versions: 8
Compression:
Stored size: 1.75 KB
Contents
shared_examples "it has callbacks" do subject { described_class.new(MagicLamp::Configuration.new) } context "attr_accessor" do it { is_expected.to attr_accessorize(:configuration) } end describe "#initialize" do it "sets configuration to the given argument" do configuration = double subject = described_class.new(configuration) expect(subject.configuration).to eq(configuration) end end [:after, :before].each do |type| describe "#execute_before_each_callback" do it "calls the type each callback" do dummy = double expect(dummy).to receive(:call) subject.configuration.send("#{type}_each_proc=", dummy) subject.send("execute_#{type}_each_callback") end context "no callback" do it "does not raise an error" do subject.configuration.send("#{type}_each_proc=", nil) expect do subject.send("execute_#{type}_each_callback") end.to_not raise_error end end end end describe "#execute_callbacks_around" do it "raises an error without a block" do expect do subject.execute_callbacks_around end.to raise_error(MagicLamp::ArgumentError, "#{described_class.name}#execute_callbacks_around requires a block") end it "calls the callbacks around the block" do def subject.foo; end expect(subject).to receive(:execute_before_each_callback).ordered expect(subject).to receive(:foo).ordered expect(subject).to receive(:execute_after_each_callback).ordered subject.execute_callbacks_around { subject.foo } end it "returns the return value of the block" do spy = double expect(subject.execute_callbacks_around { spy }).to eq(spy) end end end
Version data entries
8 entries across 8 versions & 1 rubygems