Skip to content

Commit

Permalink
Added a test case for receiving an email at midnight having added a t…
Browse files Browse the repository at this point in the history
…ransaction and other minor fixes
  • Loading branch information
winton committed Jul 19, 2009
1 parent fda2bd3 commit 36a2f7a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 0 additions & 1 deletion features/read_email.feature
Expand Up @@ -10,7 +10,6 @@ Feature: Read email
| savings | income | bills |
| 1000 | 5000 | 2500 |
# income - bills - savings = 1500 (spending money)
And it is not midnight
And my email queue is empty

Scenario: I see some static information every day
Expand Down
12 changes: 11 additions & 1 deletion features/receive_email.feature
Expand Up @@ -25,4 +25,14 @@ Feature: Receive email
Given I have created an account
And it is midnight
When the background job runs
Then I should receive an email
Then I should receive an email

Scenario: I receive a budget email at midnight having added a transaction today
Given I have created an account
And today I have spent $1.00
And the background job ran
And my email queue is empty
And it is midnight
When the background job runs
Then I should receive an email
And spent today should be zero
15 changes: 5 additions & 10 deletions features/step_definitions/given.rb
Expand Up @@ -18,15 +18,6 @@
Time.stub!(:now).and_return(today_at_12)
end

Given /^it is not midnight$/ do
now = Time.now.utc
today_at_1 = DateTime.strptime(
now.strftime("%m/%d/%Y 01:00 AM %Z"),
"%m/%d/%Y %I:%M %p %Z"
).to_time
Time.stub!(:now).and_return(today_at_1)
end

Given /^I have created an account with these attributes:$/ do |table|
$db.migrate_reset
When "I visit the front page"
Expand All @@ -47,7 +38,7 @@
user = find_user
# Email already sent today
user.update_attribute(:send_at, user.send_at + day.days)
Time.stub!(:now).and_return(user.reset_at - 1.month + day.days - 1.day)
Time.stub!(:now).and_return(user.reset_at - 1.month + (day - 1).days)
end

Given /^today I have spent \$(.+)$/ do |amount|
Expand All @@ -62,4 +53,8 @@

Given /^I have deposited \$(.+)$/ do |amount|
IncomingMail.receive(generate_email(:subject => "+#{amount}"))
end

Given /^the background job ran$/ do
When "the background job runs"
end
4 changes: 4 additions & 0 deletions features/step_definitions/then.rb
Expand Up @@ -25,4 +25,8 @@
within ".validation" do
assert_contain error
end
end

Then /^spent today should be zero$/ do
find_user.spent_today.should == 0
end

0 comments on commit 36a2f7a

Please sign in to comment.