Created
February 5, 2011 04:56
-
-
Save garybernhardt/812217 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
# Braintree has a cutesy search query API: | |
class Sweeper | |
def self.sweep! | |
Braintree::Subscription.search do |s| | |
s.status.is Braintree::Subscription::Status::Canceled | |
end | |
end | |
end | |
# Putting expectations on it sucks, but less than I expected: | |
describe Sweeper do | |
it 'searches for canceled subscriptions' do | |
Braintree::Subscription.stub(:search) do |block| | |
searcher = stub(:status => stub) | |
searcher.status.should_receive(:is). | |
with(Braintree::Subscription::Status::Canceled) | |
block.call(searcher) | |
end | |
Sweeper.sweep! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also use rspec's and_yield for this.