Skip to content

Instantly share code, notes, and snippets.

@Electron-libre
Created August 5, 2011 12:25
Show Gist options
  • Select an option

  • Save Electron-libre/1127422 to your computer and use it in GitHub Desktop.

Select an option

Save Electron-libre/1127422 to your computer and use it in GitHub Desktop.
funny
describe 'for prepaid account' do
before(:each) do
history = {
'_3_days_ago' => {'debit' => 0.0, 'credit' => 0.0, 'balance' => 100.0},
'_2_days_ago' => {'debit' => 0.5, 'credit' => 10.0, 'balance' => 109.5},
'_1_days_ago' => {'debit' => 2.0, 'credit' => 0.0, 'balance' => 107.5},
'_0_days_ago' => {'debit' => 0.0, 'credit' => 2.5, 'balance' => 110.0}
}
@in_account = Fabricate(:in_account, :current_amount => 100.0)
history.each do |day, line|
instance_variable_set(
"@#{day}_balance".to_sym,
Fabricate.build(
:balance,
:date => Time.now.utc - (day.split('_')[0].to_i).days,
:amount => line['balance']
)
)
@in_account.balances << instance_variable_get("@#{day}_balance".to_sym)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment