[rspec-users] Stubbing through multiple layers
trusted08 at clipperadams.com
Sat Jan 9 22:38:39 EST 2010
> window = stub('window', :title => "programming_ruby_1.9.pdf")
> preview = stub('preview', :front_window => window)
Perfect - so easy! Thanks.
> If you have good high level specs with something like Cucumber or FitNesse,
> this risk is diminished. You'll still have to change the example when the
> internal structure of Preview changes, but you're less likely to get burned
> by deploying code that passes its tests but doesn't work.
This is something I've been going back and forth with a lot lately -
how much implementation detail to allow to leak out into the examples/
features. If I start using software other than Preview to read my
eBooks, obviously all these examples will require reworking. The
problem is magnified because I do have Cucumber tests that use the
Then /^I should see the pickaxe book$/ do
front_preview_window = Appscript::app('System Events').processes
front_preview_window.name.get.should =~ /programming_ruby_1.9.*
Now details about Preview appear in Cucumber and Rspec! I'm tempted
to put an EBookViewer role in right off the bat (similar to what Matt
sugested), and use it in both the features and examples, but I don't
want to add too much complexity.
I'm very interested in how other people handle external dependencies
More information about the rspec-users