Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created February 5, 2011 04:56
Show Gist options
  • Save garybernhardt/812217 to your computer and use it in GitHub Desktop.
Save garybernhardt/812217 to your computer and use it in GitHub Desktop.
# 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
@tcrayford
Copy link

You could also use rspec's and_yield for this.

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