Skip to content

Commit 6f25400

Browse files
committed
outer loop complete. Inner loop time.
1 parent 311d19b commit 6f25400

3 files changed

Lines changed: 61 additions & 2 deletions

File tree

spec/acceptance/programs_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
page.should have_content "Program created"
1717
page.should have_content "Hello world"
18-
page.should have_content "By steve"
18+
page.should have_content "By #{@hacker.username}"
1919
page.should have_content "puts"
2020

2121
end
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
require File.dirname(__FILE__) + '/acceptance_helper'
2+
3+
feature "Subscriptions" do
4+
5+
scenario "Subscribing to a thread" do
6+
7+
# Given I've commented in a thread
8+
thread = Factory(:discussion)
9+
me = Factory(:hacker)
10+
reply = Factory(:reply, :author => me.username, :author_email => me.email)
11+
thread.replies << reply
12+
13+
Pony.should_receive(:deliver) do |mail|
14+
mail.to.should == [ me.email ]
15+
mail.body.to_s.should =~ /\/forums\/#{thread.forum}\/#{thread.slug}/
16+
end
17+
18+
# When someone else makes a comment
19+
somebody = Factory(:hacker)
20+
log_in somebody
21+
visit "/forums/#{thread.forum}/#{thread.slug}"
22+
click_link "Reply"
23+
fill_in "Body", :with => "Here's my take on things: Dream big!"
24+
click_button "Create Reply"
25+
26+
# Then I should receive an email
27+
# (see pony block above)
28+
29+
# And it should have a link to that thread
30+
# (see pony block above)
31+
32+
end
33+
34+
# Scenario: Unsubscribing from a thread
35+
# Given I've subscribed to a thread
36+
# And I'm on the page for that thread
37+
# When I click the unsubscribe link
38+
# And someone makes a comment
39+
# Then I should not receive an email
40+
41+
# Scenario: Subscribing to a forum
42+
# Given I'm on the index page for a forum
43+
# When I click the subscription link
44+
# And someone makes a new thread in that forum
45+
# Then I should receive an email
46+
# And it should have a link to that forum
47+
48+
# Scenario: Unsubscribing from a forum
49+
# Given I've subscribed to a forum
50+
# And I'm on the index page for that forum
51+
# When I click the unsubscribe link
52+
# And someone makes a new thread in that forum
53+
# Then I should not receive an email
54+
55+
end

spec/factories.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
"user#{n}@example.com"
77
end
88

9+
Factory.sequence :username do |n|
10+
"user#{n}"
11+
end
12+
913
#this factory defines a hacker
1014
Factory.define :hacker do |u|
11-
u.username "steve"
15+
u.username { Factory.next(:username)}
1216
u.email { Factory.next(:email) }
1317
u.password "foobar"
1418
#we need to set the password_confirmation to the same value as the password

0 commit comments

Comments
 (0)