Created
November 23, 2014 13:12
-
-
Save robyurkowski/56202e8e1806e6f89272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def confirm_failure(error) | |
self.error = error | |
run_failure_callbacks | |
end | |
private def run_failure_callbacks | |
# This line fails because on_failure responds_to #call ?! | |
on_failure.call(self) if on_failure.respond_to?(:call) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "when on_failure is callable" do | |
it "calls the on_failure callback with itself" do | |
expect(on_failure).to receive(:call).with(command) | |
command.call | |
end | |
end | |
context "when on_failure is not callable" do | |
let(:nil_callback) { double("nil_callback") } | |
let(:command) { Command.new(on_failure: nil_callback) } | |
it "does not call on_failure" do | |
expect(nil_callback).not_to receive(:call) | |
command.call | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment