Created
March 1, 2012 04:54
-
-
Save pat/1947369 to your computer and use it in GitHub Desktop.
Using rspec-fire?
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
# My normal approach: | |
require './path/to/my_class' | |
class OtherClass; end | |
describe MyClass do | |
let(:my_class) { MyClass.new } | |
describe '#add_widget' do | |
it "makes a widget using OtherClass" do | |
OtherClass.should_receive(:make_widget!) | |
my_class.add_widget | |
end | |
end | |
end | |
# Declaring the OtherClass constant so the test runs by itself. If running in a | |
# suite, the original OtherClass declaration is picked up, and our one changes | |
# nothing. But declaring a constant will confuse rspec-fire, right? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@freelancing-god -- I forked this and wrote up how I would do it with rspec-fire with the feature added by my pull request:
https://gist.github.com/1975201
Note that the API (
fire_replaced_class_double
) is probably not what we'll wind up with, but the basic approach will probably stay. It'd be good to get more input into what the API should be. Please comment on the Pull Request:xaviershay/rspec-fire#3 (comment)
/cc @xaviershay