Sha256: 0593ac42fbe7b6ee8c181593f74111aae9ebcc9473358d6c0bfc2abd3c1eb2b4
Contents?: true
Size: 1.12 KB
Versions: 6
Compression:
Stored size: 1.12 KB
Contents
require "spec_helper" describe Mongoid::Publishable::Callback do subject { Mongoid::Publishable::Callback } describe "#initialize" do it "should accept a block" do callback = subject.new do |object| puts "Done something" end expect(callback).to respond_to :process end it "should accept a symbol" do callback = subject.new(:method_name) expect(callback).to respond_to :process end it "should not accept two arguments" do expect { subject.new(:one, :two) }.to raise_error(ArgumentError) end end describe "#process" do let(:object) { mock("instance", test: "123") } context "when given a method name" do it "should call the method on the given object" do callback = subject.new(:test) expect(callback.process(object)).to eq "123" end end context "when given a block" do it "should yield the block with the given object" do callback = subject.new do |object| object.test end expect(callback.process(object)).to eq "123" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems