[rspec-users] would I stub an existing class method out or use fixtures in this scenario?
mark at mwilden.com
Mon Oct 6 13:50:46 EDT 2008
On Sun, Oct 5, 2008 at 9:26 PM, Greg Hauptmann <
greg.hauptmann.ruby at gmail.com> wrote:
> So overall I'm pondering how to test my "populate_projections" method
> in a manner that minimises the amount of dynamically generated
> fixtures I have to create (currently I create recurring items &
> bank_accounts), and also the reliance on the BankAccount.balance?
> method (and it's correct operation). My specific question was about
> how to stub out the already existing BankAccount.balance? method using
In general, I do something like
bank_account = mock_model(BankAccount, :balance => 12)
Is that what you're talking about? As opposed to
bank_account = BankAcount.create!
Transaction.create!(:back_account_id => bank_account.id, :amount => 12)
Are you asking which one is better, or am I totally off on the wrong track?
:) Otherwise, I'd pick the first approach, because it's faster.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users