ruby_reddit_api-h 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +27 -0
- data/features/api.feature +10 -0
- data/features/base.feature +15 -0
- data/features/comment.feature +40 -0
- data/features/message.feature +19 -0
- data/features/message_group.feature +14 -0
- data/features/reddit.yml +5 -0
- data/features/search.feature +6 -0
- data/features/step_definitions/api_steps.rb +22 -0
- data/features/step_definitions/base_steps.rb +49 -0
- data/features/step_definitions/comment_steps.rb +59 -0
- data/features/step_definitions/message_group_steps.rb +30 -0
- data/features/step_definitions/message_steps.rb +68 -0
- data/features/step_definitions/search_steps.rb +12 -0
- data/features/step_definitions/submission_steps.rb +118 -0
- data/features/step_definitions/user_steps.rb +27 -0
- data/features/submission.feature +58 -0
- data/features/support/base_helpers.rb +17 -0
- data/features/user.feature +11 -0
- data/lib/ruby_reddit_api/api.rb +87 -0
- data/lib/ruby_reddit_api/base.rb +133 -0
- data/lib/ruby_reddit_api/comment.rb +125 -0
- data/lib/ruby_reddit_api/json_listing.rb +46 -0
- data/lib/ruby_reddit_api/message.rb +63 -0
- data/lib/ruby_reddit_api/message_group.rb +39 -0
- data/lib/ruby_reddit_api/submission.rb +73 -0
- data/lib/ruby_reddit_api/thing.rb +38 -0
- data/lib/ruby_reddit_api/user.rb +42 -0
- data/lib/ruby_reddit_api/version.rb +6 -0
- data/lib/ruby_reddit_api/vote.rb +39 -0
- data/lib/ruby_reddit_api/voteable.rb +22 -0
- data/lib/ruby_reddit_api.rb +20 -0
- metadata +145 -0
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
== Ruby Reddit Client v0.2.6
|
2
|
+
Tested with ruby 1.8.7 & 1.9.2
|
3
|
+
|
4
|
+
== Usage
|
5
|
+
require "ruby_reddit_api"
|
6
|
+
r = Reddit::Api.new "user", "password"
|
7
|
+
results = r.browse "ruby"
|
8
|
+
results[0].upvote
|
9
|
+
|
10
|
+
== Features
|
11
|
+
* Authentication
|
12
|
+
* Browse subreddits
|
13
|
+
* Searching
|
14
|
+
* Read & reply to comments
|
15
|
+
* Friend & unfriend redditors
|
16
|
+
* Comment & submission voting
|
17
|
+
|
18
|
+
|
19
|
+
== Running Tests
|
20
|
+
1. Set up the reddit VM (http://blog.reddit.com/2010/05/admins-never-do-what-you-want-now-it-is.html)
|
21
|
+
2. Ensure your hosts file has reddit.local pointing to the VM
|
22
|
+
3. gem install bundler
|
23
|
+
4. bundle install
|
24
|
+
5. rake
|
25
|
+
|
26
|
+
== License
|
27
|
+
Ruby Reddit API is released under the MIT License.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Browsing
|
2
|
+
I want to be able to browse submissions
|
3
|
+
|
4
|
+
Scenario: Valid subreddit
|
5
|
+
Given I submit a valid subreddit
|
6
|
+
Then I should get back a listing of submissions
|
7
|
+
|
8
|
+
Scenario: Invalid subreddit
|
9
|
+
Given I submit a invalid subreddit
|
10
|
+
Then I should get back some error
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Authentication
|
2
|
+
In order perform things like voting and commenting
|
3
|
+
As a Redditor
|
4
|
+
I want to be able to login in my step definitions
|
5
|
+
|
6
|
+
Scenario: Valid user and password
|
7
|
+
Given I have a valid user
|
8
|
+
And I send my user and password to the login API
|
9
|
+
Then I should have a valid cookie
|
10
|
+
And the stored headers should refer to the cookie
|
11
|
+
|
12
|
+
Scenario: Invalid user and password
|
13
|
+
Given I have a invalid user
|
14
|
+
And I send my user and password to the login API
|
15
|
+
Then I should not have a valid cookie
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: Comments
|
2
|
+
I want to be able to comment on a comment
|
3
|
+
I want to be able to delete my comments
|
4
|
+
|
5
|
+
Scenario: Valid comment text
|
6
|
+
Given I enter some text
|
7
|
+
Then I should be able to add a comment
|
8
|
+
|
9
|
+
Scenario: I want to hide a comment
|
10
|
+
Given I have a comment
|
11
|
+
Then I should be able to hide the comment
|
12
|
+
|
13
|
+
Scenario: I want to remove a comment
|
14
|
+
Given I have a comment
|
15
|
+
Then I should be able to remove the comment
|
16
|
+
|
17
|
+
Scenario: I want to approve a comment
|
18
|
+
Given I have a comment
|
19
|
+
Then I should be able to approve the comment
|
20
|
+
|
21
|
+
Scenario: I want to edit a comment
|
22
|
+
Given I have a comment
|
23
|
+
Then I should be able to edit the comment
|
24
|
+
|
25
|
+
Scenario: I want to comment on a comment
|
26
|
+
Given I have a comment
|
27
|
+
Then I should be able to reply to the comment
|
28
|
+
|
29
|
+
Scenario: I want to moderator distinguish a comment
|
30
|
+
Given I have a comment
|
31
|
+
Then I should be able to moderator distinguish the comment
|
32
|
+
|
33
|
+
Scenario: I want to indistinguish a comment
|
34
|
+
Given I have a comment
|
35
|
+
Then I should be able to indistinguish the comment
|
36
|
+
|
37
|
+
Scenario: I want to admin distinguish a comment
|
38
|
+
Given I have a comment
|
39
|
+
Then I should be able to admin distinguish the comment
|
40
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Messaging
|
2
|
+
|
3
|
+
Scenario: I want to be able to read my sent messages
|
4
|
+
Given I am logged in
|
5
|
+
When I go to the sent messages page
|
6
|
+
Then I should see a listing of messages
|
7
|
+
|
8
|
+
Scenario: I want to change message read status
|
9
|
+
Given I am logged in
|
10
|
+
And I have received messages
|
11
|
+
When I go to the received messages page
|
12
|
+
Then I should be able to mark them as unread
|
13
|
+
And I should be able to mark them as read
|
14
|
+
|
15
|
+
Scenario: I want to be able to read my unread messages
|
16
|
+
Given I am logged in
|
17
|
+
And I have unread messages
|
18
|
+
When I go to the unread messages page
|
19
|
+
Then I should see a listing of messages
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Message Group
|
2
|
+
I want to be able to mark multiple messages as read or unread
|
3
|
+
|
4
|
+
Scenario: Mark multiple messages read
|
5
|
+
Given I am logged in
|
6
|
+
And I have unread messages
|
7
|
+
When I mark all unread messages read
|
8
|
+
Then I should have no unread messages
|
9
|
+
|
10
|
+
Scenario: Mark multiple messages unread
|
11
|
+
Given I am logged in
|
12
|
+
And I have unread messages
|
13
|
+
When I mark all read messages unread
|
14
|
+
Then I should have no read messages
|
data/features/reddit.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Given /^I submit a valid subreddit$/ do
|
2
|
+
Reddit::Api.base_uri "reddit.local"
|
3
|
+
@api = Reddit::Api.new "reddit", "password"
|
4
|
+
@subreddit = "reddit_test0"
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^I should get back a listing of submissions$/ do
|
8
|
+
results = @api.browse(@subreddit)
|
9
|
+
results[0].class.should == Reddit::Submission
|
10
|
+
results[0].author.should_not == nil
|
11
|
+
end
|
12
|
+
|
13
|
+
Given /^I submit a invalid subreddit$/ do
|
14
|
+
Reddit::Api.base_uri "reddit.local"
|
15
|
+
@api = Reddit::Api.new "reddit", "password"
|
16
|
+
@subreddit = "invalid_subreddit"
|
17
|
+
end
|
18
|
+
|
19
|
+
Then /^I should get back some error$/ do
|
20
|
+
results = @api.browse(@subreddit)
|
21
|
+
results.should == false
|
22
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "..", "..", "lib", "ruby_reddit_api.rb")
|
2
|
+
Before do
|
3
|
+
Reddit::Base.instance_variable_set("@cookie", nil)
|
4
|
+
load_server_config
|
5
|
+
Reddit::Api.base_uri @address
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^I have a valid user$/ do
|
9
|
+
load_server_config
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^I have a invalid user$/ do
|
13
|
+
@user, @pass = "invalid", "user"
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /^I send my user and password to the login API$/ do
|
17
|
+
@api = Reddit::Api.new @user, @pass
|
18
|
+
@api.login
|
19
|
+
end
|
20
|
+
|
21
|
+
Given /I'm logged in$/ do
|
22
|
+
@api = Reddit::Api.new @user, @pass
|
23
|
+
@api.login
|
24
|
+
end
|
25
|
+
|
26
|
+
Given /I'm not logged in$/ do
|
27
|
+
@api.logout if @api
|
28
|
+
@api = Reddit::Api.new @user, "bad pass"
|
29
|
+
@api.logout
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I should have a valid cookie$/ do
|
33
|
+
@api.cookie.should_not == nil
|
34
|
+
@api.cookie.should =~ /reddit_session/
|
35
|
+
end
|
36
|
+
|
37
|
+
Then /^I should not have a valid cookie$/ do
|
38
|
+
@api.cookie.should_not == nil
|
39
|
+
@api.cookie.should =~ /reddit_first/
|
40
|
+
end
|
41
|
+
|
42
|
+
Then /^I should not have a cookie$/ do
|
43
|
+
@api.cookie.should == nil
|
44
|
+
end
|
45
|
+
|
46
|
+
Then /^the stored headers should refer to the cookie$/ do
|
47
|
+
@api.base_headers["Cookie"].should == @api.cookie
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Before do
|
2
|
+
load_server_config
|
3
|
+
Reddit::Api.base_uri @address
|
4
|
+
Reddit::Submission.base_uri @address
|
5
|
+
Reddit::Comment.base_uri @address
|
6
|
+
@api = Reddit::Api.new @user, @pass
|
7
|
+
@api.login
|
8
|
+
@submission ||= @api.browse("reddit_test0")[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
Given /^I enter some text$/ do
|
12
|
+
@text = "SOME COMMENT"
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^I should be able to add a comment$/ do
|
16
|
+
@submission.add_comment(@text).should be true
|
17
|
+
end
|
18
|
+
|
19
|
+
Given /^I have a comment$/ do
|
20
|
+
@submission.add_comment("a comment")
|
21
|
+
@comment = @submission.comments.last
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^I should be able to hide the comment$/ do
|
25
|
+
@comment.hide
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^I should be able to remove the comment$/ do
|
29
|
+
@comment.remove
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I should be able to approve the comment$/ do
|
33
|
+
@comment.approve
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^I should not be able to edit the comment$/ do
|
37
|
+
@comment.edit( "1234" ).should be false
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^I should be able to edit the comment$/ do
|
41
|
+
@comment.edit( "1234" ).should be true
|
42
|
+
end
|
43
|
+
|
44
|
+
Then /^I should be able to moderator distinguish the comment$/ do
|
45
|
+
pending #@comment.moderator_distinguish
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^I should be able to indistinguish the comment$/ do
|
49
|
+
pending #@comment.indistinguish
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^I should be able to admin distinguish the comment$/ do
|
53
|
+
pending #@comment.admin_distinguish
|
54
|
+
end
|
55
|
+
|
56
|
+
Then /^I should be able to reply to the comment$/ do
|
57
|
+
pending #@comment.reply("a reply").should be true
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Before do
|
2
|
+
load_server_config
|
3
|
+
Reddit::Api.base_uri @address
|
4
|
+
Reddit::MessageGroup.base_uri @address
|
5
|
+
Reddit::Base.instance_variable_set("@throttle_duration", 0)
|
6
|
+
@api = Reddit::Api.new @user, @pass
|
7
|
+
@api.login
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I mark all unread messages read$/ do
|
11
|
+
group = Reddit::MessageGroup.new
|
12
|
+
messages = @api.unread_messages
|
13
|
+
result = group.mark_read messages
|
14
|
+
result.should be true
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^I mark all read messages unread$/ do
|
18
|
+
group = Reddit::MessageGroup.new
|
19
|
+
messages = @api.received_messages
|
20
|
+
result = group.mark_unread messages
|
21
|
+
result.should be true
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^I should have no unread messages$/ do
|
25
|
+
@api.unread_messages.should == []
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^I should have no read messages$/ do
|
29
|
+
@api.received_messages.select{|m| !m.was_comment}.map(&:read?).uniq.should == [false]
|
30
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Before do
|
2
|
+
load_server_config
|
3
|
+
Reddit::Api.base_uri @address
|
4
|
+
Reddit::Message.base_uri @address
|
5
|
+
Reddit::Base.instance_variable_set("@throttle_duration", 0)
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^I am logged in$/ do
|
9
|
+
@api = Reddit::Api.new @user, @pass
|
10
|
+
@api.login
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I go to the sent messages page$/ do
|
14
|
+
@result = @api.sent_messages
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^I go to the unread messages page$/ do
|
18
|
+
@result = @api.unread_messages
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^I go to the received messages page$/ do
|
22
|
+
@result = @api.received_messages
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^I should see a listing of messages$/ do
|
26
|
+
@result.any?{|r| r.is_a?(Reddit::Message) == false}.should be false
|
27
|
+
end
|
28
|
+
|
29
|
+
Given /^I have received messages$/ do
|
30
|
+
@api.received_messages.size.should be > 0
|
31
|
+
end
|
32
|
+
|
33
|
+
Given /^I have unread messages$/ do
|
34
|
+
unread = @api.unread_messages
|
35
|
+
unless unread.size > 0
|
36
|
+
@api.received_messages[0].mark_unread
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^I should be able to mark them as unread/ do
|
41
|
+
unread = @api.unread_messages
|
42
|
+
unread.each do |m|
|
43
|
+
m.mark_read
|
44
|
+
end
|
45
|
+
|
46
|
+
received = @api.received_messages
|
47
|
+
received[0].mark_unread
|
48
|
+
|
49
|
+
r = @api.unread_messages
|
50
|
+
r.size.should == 1
|
51
|
+
end
|
52
|
+
|
53
|
+
Then /^I should be able to mark them as read$/ do
|
54
|
+
received = @api.received_messages
|
55
|
+
received.each do |m|
|
56
|
+
m.mark_unread
|
57
|
+
end
|
58
|
+
unread = @api.unread_messages
|
59
|
+
|
60
|
+
unread.size.should be > 0
|
61
|
+
|
62
|
+
unread.each do |m|
|
63
|
+
m.mark_read
|
64
|
+
end
|
65
|
+
|
66
|
+
r = @api.unread_messages
|
67
|
+
r.size.should == 0
|
68
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Given /^I search '([^']+)' with '([^']+)'$/ do |subreddit, terms|
|
2
|
+
Reddit::Base.base_uri "reddit.com"
|
3
|
+
Reddit::Api.base_uri "reddit.com"
|
4
|
+
@api = Reddit::Api.new
|
5
|
+
@subreddit = subreddit
|
6
|
+
@terms = terms
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should get back search results$/ do
|
10
|
+
results = @api.search(@terms, :in => @subreddit)
|
11
|
+
results[0].class.should == Reddit::Submission
|
12
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
Given /^I have a submission$/ do
|
2
|
+
load_server_config
|
3
|
+
Reddit::Api.base_uri @address
|
4
|
+
Reddit::Submission.base_uri @address
|
5
|
+
Reddit::Comment.base_uri @address
|
6
|
+
@api = Reddit::Api.new @user, @pass
|
7
|
+
@api.login
|
8
|
+
@submission = @api.browse("reddit_test0")[0]
|
9
|
+
if @api.logged_in?
|
10
|
+
@submission.add_comment("STOP REPOSTING!!1") if @submission
|
11
|
+
else
|
12
|
+
raise "Can't run test. Submit failed.."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^I should be able to see the author$/ do
|
17
|
+
@submission.author.should_not == nil
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^I should be able to see the title$/ do
|
21
|
+
@submission.title.should_not == nil
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^I should be able to see the selftext$/ do
|
25
|
+
@submission.selftext.should_not == nil
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^I should be able to see the url$/ do
|
29
|
+
@submission.url.should_not == nil
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I should be able to see the up votes$/ do
|
33
|
+
@submission.ups.should_not == nil
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^I should be able to see the down votes$/ do
|
37
|
+
@submission.downs.should_not == nil
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^I should not be able to upvote it$/ do
|
41
|
+
@submission.upvote.should be false
|
42
|
+
end
|
43
|
+
|
44
|
+
Then /^I should not be able to downvote it$/ do
|
45
|
+
@submission.downvote.should be false
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^I should be able to upvote it$/ do
|
49
|
+
@submission.upvote.should be true
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^I should be able to downvote it$/ do
|
53
|
+
@submission.downvote.should be true
|
54
|
+
end
|
55
|
+
|
56
|
+
Then /^I should not be able to save the submission$/ do
|
57
|
+
@submission.save.should be false
|
58
|
+
end
|
59
|
+
|
60
|
+
Then /^I should not be able to unsave the submission$/ do
|
61
|
+
@submission.unsave.should be false
|
62
|
+
end
|
63
|
+
|
64
|
+
Then /^I should not be able to hide the submission$/ do
|
65
|
+
@submission.hide.should be false
|
66
|
+
end
|
67
|
+
|
68
|
+
Then /^I should not be able to unhide the submission$/ do
|
69
|
+
@submission.unhide.should be false
|
70
|
+
end
|
71
|
+
|
72
|
+
Then /^I should be able to save the submission$/ do
|
73
|
+
@submission.save.should be true
|
74
|
+
end
|
75
|
+
|
76
|
+
Then /^I should be able to unsave the submission$/ do
|
77
|
+
@submission.unsave.should be true
|
78
|
+
end
|
79
|
+
|
80
|
+
Then /^I should be able to hide the submission$/ do
|
81
|
+
result = @submission.hide
|
82
|
+
@submission.unhide if result
|
83
|
+
result.should be true
|
84
|
+
end
|
85
|
+
|
86
|
+
Then /^I should be able to unhide the submission$/ do
|
87
|
+
@submission.unhide.should be true
|
88
|
+
end
|
89
|
+
|
90
|
+
Then /^I should be able to report the submission$/ do
|
91
|
+
@submission.report.should be true
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /^I should not be able to report the submission$/ do
|
95
|
+
@submission.report.should be false
|
96
|
+
end
|
97
|
+
|
98
|
+
Then /^I should be able to see more comments if needed$/ do
|
99
|
+
pending
|
100
|
+
end
|
101
|
+
|
102
|
+
Then /^I should be able to moderator distinguish the submission$/ do
|
103
|
+
@submission.moderator_distinguish
|
104
|
+
end
|
105
|
+
|
106
|
+
Then /^I should be able to admin distinguish the submission$/ do
|
107
|
+
@submission.admin_distinguish
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^I should be able to indistinguish the submission$/ do
|
111
|
+
@submission.indistinguish
|
112
|
+
end
|
113
|
+
|
114
|
+
Then /^I should be able to see the comments$/ do
|
115
|
+
@submission.instance_variable_set("@last_action", Time.now - 60) if @submission
|
116
|
+
comments = @submission.comments
|
117
|
+
comments.size.should > 0
|
118
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Before do
|
2
|
+
load_server_config
|
3
|
+
Reddit::Base.base_uri @address
|
4
|
+
Reddit::Api.base_uri @address
|
5
|
+
Reddit::Thing.base_uri @address
|
6
|
+
Reddit::Submission.base_uri @address
|
7
|
+
Reddit::Comment.base_uri @address
|
8
|
+
Reddit::User.base_uri @address
|
9
|
+
@api = Reddit::Api.new @user, @pass
|
10
|
+
@api.login
|
11
|
+
end
|
12
|
+
|
13
|
+
Given /^I select a redditor$/ do
|
14
|
+
@submission = @api.browse("reddit_test1")[0]
|
15
|
+
@user = @submission.author
|
16
|
+
end
|
17
|
+
|
18
|
+
Then /^I should be able to friend them$/ do
|
19
|
+
@user.friend.should be true
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^I should be able to unfriend them$/ do
|
23
|
+
@user.unfriend.should be true
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Feature: Submissions
|
2
|
+
I want to be able to peruse the submission details
|
3
|
+
And I want to be able to up vote the submission
|
4
|
+
And I want to be able to down vote the submission
|
5
|
+
And I want to be able to save submissions I like
|
6
|
+
And I want to be able to unsave submissions
|
7
|
+
|
8
|
+
|
9
|
+
Scenario: Viewing a submission
|
10
|
+
Scenario: When not logged in
|
11
|
+
Given I have a submission
|
12
|
+
And I'm not logged in
|
13
|
+
Then I should be able to see the author
|
14
|
+
And I should be able to see the title
|
15
|
+
And I should be able to see the selftext
|
16
|
+
And I should be able to see the url
|
17
|
+
And I should be able to see the up votes
|
18
|
+
And I should be able to see the down votes
|
19
|
+
And I should be able to see the comments
|
20
|
+
But I should not be able to upvote it
|
21
|
+
But I should not be able to downvote it
|
22
|
+
But I should not be able to save the submission
|
23
|
+
But I should not be able to unsave the submission
|
24
|
+
But I should not be able to hide the submission
|
25
|
+
But I should not be able to unhide the submission
|
26
|
+
But I should not be able to report the submission
|
27
|
+
And I should be able to see more comments if needed
|
28
|
+
|
29
|
+
Scenario: When logged in
|
30
|
+
Given I have a submission
|
31
|
+
And I'm logged in
|
32
|
+
Then I should be able to see the author
|
33
|
+
And I should be able to see the title
|
34
|
+
And I should be able to see the selftext
|
35
|
+
And I should be able to see the url
|
36
|
+
And I should be able to see the up votes
|
37
|
+
And I should be able to see the down votes
|
38
|
+
And I should be able to see the comments
|
39
|
+
And I should be able to upvote it
|
40
|
+
And I should be able to downvote it
|
41
|
+
And I should be able to save the submission
|
42
|
+
And I should be able to unsave the submission
|
43
|
+
And I should be able to hide the submission
|
44
|
+
And I should be able to unhide the submission
|
45
|
+
And I should be able to report the submission
|
46
|
+
And I should be able to see more comments if needed
|
47
|
+
|
48
|
+
Scenario: I want to moderator distinguish a submission
|
49
|
+
Given I have a submission
|
50
|
+
Then I should be able to moderator distinguish the submission
|
51
|
+
|
52
|
+
Scenario: I want to admin distinguish a submission
|
53
|
+
Given I have a submission
|
54
|
+
Then I should be able to admin distinguish the submission
|
55
|
+
|
56
|
+
Scenario: I want to indistinguish a submission
|
57
|
+
Given I have a submission
|
58
|
+
Then I should be able to indistinguish the submission
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BaseHelpers
|
2
|
+
def load_server_config
|
3
|
+
@address, @post, @user, @pass = parse_config.compact
|
4
|
+
end
|
5
|
+
|
6
|
+
protected
|
7
|
+
def parse_config
|
8
|
+
file = File.exist?("features/reddit.yml") ? YAML.load_file("features/reddit.yml") : {}
|
9
|
+
server = file.fetch("server"){ server_defaults }
|
10
|
+
return [ server["address"], server["port"], server["test_user"], server["test_pass"] ]
|
11
|
+
end
|
12
|
+
|
13
|
+
def server_defaults
|
14
|
+
{"address" => "reddit.local", "port" => "80", "test_user" => "reddit", "test_pass" => "password"}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
World(BaseHelpers)
|