-
-
Save craigw/320096 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# how to test that this works? | |
# or would you even bother? | |
... | |
begin | |
require 'system_timer' | |
rescue LoadError | |
require 'timeout' | |
SystemTimer = Timeout | |
end | |
... |
This file contains hidden or 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
before(:all) do | |
Object.remove_const(SystemTimer) | |
end | |
after(:each) do | |
Object.remove_const(SystemTimer) | |
end | |
after(:all) do | |
load "something" | |
end | |
it "should require 'system_timer'" do | |
Object.expects(:require).once.with('system_timer') | |
load "something" | |
end | |
it "should use Timer as SystemTimer if system_timer could not be loaded" | |
def Object.require # you should alias the old one first so you can alias it back later. | |
raise LoadError, "..." | |
end | |
load "something" | |
Time.should eql(SystemTimer) | |
end |
This file contains hidden or 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
$LOAD_PATH.unshift(File.dirname(__FILE__)) | |
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | |
require 'rubygems' | |
require 'spec' | |
require 'webmock/rspec' | |
require 'something' # <--- it's already loaded here | |
require 'faker' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment