Skip to content

Instantly share code, notes, and snippets.

@schoblaska
Created July 24, 2012 19:13
Show Gist options
  • Select an option

  • Save schoblaska/3171990 to your computer and use it in GitHub Desktop.

Select an option

Save schoblaska/3171990 to your computer and use it in GitHub Desktop.
diff --git a/spec/urbanairship_spec.rb b/spec/urbanairship_spec.rb
index 224591e..2fa550f 100644
--- a/spec/urbanairship_spec.rb
+++ b/spec/urbanairship_spec.rb
@@ -454,9 +454,12 @@ describe Urbanairship do
end
it "does not attempt to log if logger is not set" do
+ Urbanairship::Timer.should_receive(:timeout).with(5.0).and_raise(Timeout::Error)
Urbanairship.logger = nil
- @logger.should_not_receive(:error).with(/Urbanairship request timed out/)
- Urbanairship.register_device('new_device_token')
+
+ lambda {
+ Urbanairship.register_device('new_device_token')
+ }.should_not raise_exception(NoMethodError)
end
it "uses a default request_timeout value of five seconds" do
@schoblaska
Copy link
Author

In the original test, the should_not_receive expectation was placed on the mock logger, but Urbanairship.logger was set to nil, so the mock would have never received any method calls in the code anyway. Also, without stubbing Urbanairship::Timer.timeout, no timeout error was being raised and the code path that involved the change being tested was never run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment