redditkit 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +22 -0
- data/README.md +155 -0
- data/Rakefile +8 -0
- data/lib/redditkit.rb +26 -0
- data/lib/redditkit/base.rb +60 -0
- data/lib/redditkit/client.rb +142 -0
- data/lib/redditkit/client/account.rb +73 -0
- data/lib/redditkit/client/apps.rb +63 -0
- data/lib/redditkit/client/captcha.rb +36 -0
- data/lib/redditkit/client/comments.rb +54 -0
- data/lib/redditkit/client/flair.rb +148 -0
- data/lib/redditkit/client/links.rb +134 -0
- data/lib/redditkit/client/miscellaneous.rb +50 -0
- data/lib/redditkit/client/moderation.rb +179 -0
- data/lib/redditkit/client/multireddits.rb +207 -0
- data/lib/redditkit/client/private_messages.rb +74 -0
- data/lib/redditkit/client/search.rb +25 -0
- data/lib/redditkit/client/subreddits.rb +120 -0
- data/lib/redditkit/client/users.rb +109 -0
- data/lib/redditkit/client/utilities.rb +137 -0
- data/lib/redditkit/client/voting.rb +41 -0
- data/lib/redditkit/client/wiki.rb +83 -0
- data/lib/redditkit/comment.rb +54 -0
- data/lib/redditkit/creatable.rb +17 -0
- data/lib/redditkit/error.rb +111 -0
- data/lib/redditkit/link.rb +140 -0
- data/lib/redditkit/moderator_action.rb +19 -0
- data/lib/redditkit/multireddit.rb +32 -0
- data/lib/redditkit/multireddit_description.rb +14 -0
- data/lib/redditkit/paginated_response.rb +22 -0
- data/lib/redditkit/private_message.rb +27 -0
- data/lib/redditkit/response/parse_json.rb +29 -0
- data/lib/redditkit/response/raise_error.rb +21 -0
- data/lib/redditkit/subreddit.rb +86 -0
- data/lib/redditkit/thing.rb +20 -0
- data/lib/redditkit/user.rb +30 -0
- data/lib/redditkit/version.rb +19 -0
- data/lib/redditkit/votable.rb +37 -0
- data/redditkit.gemspec +25 -0
- data/spec/cassettes/RedditKit_Client/should_raise_an_error_with_invalid_credentials.yml +39 -0
- data/spec/cassettes/RedditKit_Client_Account/_sign_in/signs_the_user_in.yml +132 -0
- data/spec/cassettes/RedditKit_Client_Account/_update_session/updates_the_current_session.yml +133 -0
- data/spec/cassettes/RedditKit_Client_Captcha/_captcha_url/returns_a_CAPTCHA_url_from_an_identifier.yml +38 -0
- data/spec/cassettes/RedditKit_Client_Captcha/_needs_captcha_/checks_if_the_current_account_needs_a_CAPTCHA.yml +44 -0
- data/spec/cassettes/RedditKit_Client_Captcha/_new_captcha_identifier/returns_a_new_CAPTCHA_identifier.yml +38 -0
- data/spec/cassettes/RedditKit_Client_Comments/_comment/requests_the_correct_resource.yml +47 -0
- data/spec/cassettes/RedditKit_Client_Comments/_comments/with_a_RedditKit_Link/returns_comments_on_a_link.yml +140 -0
- data/spec/cassettes/RedditKit_Client_Comments/_comments/with_a_link_identifier/returns_comments_on_a_link.yml +89 -0
- data/spec/cassettes/RedditKit_Client_Comments/_submit_comment/requests_the_correct_resource.yml +313 -0
- data/spec/cassettes/RedditKit_Client_Flair/_apply_flair_template/clears_flair_templates.yml +52 -0
- data/spec/cassettes/RedditKit_Client_Flair/_clear_flair_templates/clears_flair_templates.yml +49 -0
- data/spec/cassettes/RedditKit_Client_Flair/_create_flair_template/creates_a_flair_template.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Flair/_create_flair_template/raises_InvalidClassName.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Flair/_create_flair_template/raises_TooManyClassNames.yml +47 -0
- data/spec/cassettes/RedditKit_Client_Flair/_delete_user_flair/requests_the_correct_resource.yml +60 -0
- data/spec/cassettes/RedditKit_Client_Flair/_flair_list/returns_the_list_of_flair.yml +44 -0
- data/spec/cassettes/RedditKit_Client_Flair/_set_flair/requests_the_correct_resource.yml +49 -0
- data/spec/cassettes/RedditKit_Client_Flair/_set_flair_options/sets_flair_options.yml +49 -0
- data/spec/cassettes/RedditKit_Client_Flair/_set_flair_with_csv/requests_the_correct_resource.yml +51 -0
- data/spec/cassettes/RedditKit_Client_Flair/_toggle_flair/requests_the_correct_resource.yml +49 -0
- data/spec/cassettes/RedditKit_Client_Links/_front_page/requests_the_correct_category.yml +498 -0
- data/spec/cassettes/RedditKit_Client_Links/_front_page/requests_the_correct_resource.yml +603 -0
- data/spec/cassettes/RedditKit_Client_Links/_hide/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Links/_link/returns_a_link.yml +55 -0
- data/spec/cassettes/RedditKit_Client_Links/_links/contains_pagination_information.yml +402 -0
- data/spec/cassettes/RedditKit_Client_Links/_links/requests_a_certain_number_of_links.yml +186 -0
- data/spec/cassettes/RedditKit_Client_Links/_links/requests_front_page_links_if_no_subreddit_is_present.yml +603 -0
- data/spec/cassettes/RedditKit_Client_Links/_links/requests_links_with_the_correct_time_frame.yml +375 -0
- data/spec/cassettes/RedditKit_Client_Links/_links/requests_the_correct_subreddit_and_category.yml +402 -0
- data/spec/cassettes/RedditKit_Client_Links/_links_with_domain/returns_links_with_a_specific_domain.yml +99 -0
- data/spec/cassettes/RedditKit_Client_Links/_mark_nsfw/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Links/_random_link/returns_a_random_link.yml +91 -0
- data/spec/cassettes/RedditKit_Client_Links/_submit/raises_RedditKit_InvalidCaptcha_if_no_CAPTCHA_is_filled_out.yml +54 -0
- data/spec/cassettes/RedditKit_Client_Links/_unhide/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Links/_unmark_nsfw/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Miscellaneous/_delete/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Miscellaneous/_edit/requests_the_correct_resource.yml +52 -0
- data/spec/cassettes/RedditKit_Client_Miscellaneous/_save/saves_an_object.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Miscellaneous/_unsave/unsaves_an_object.yml +89 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_accept_moderator_invitation/requests_the_correct_resource.yml +53 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_ban/requests_the_correct_resource.yml +103 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_contributors_to_subreddit/requests_the_correct_resource.yml +47 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_ignore_reports/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_moderation_log/returns_RedditKit_ModeratorAction_objects.yml +153 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_moderators_of_subreddit/requests_the_correct_resource.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_reset_subreddit_header/requests_the_correct_resource.yml +55 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_set_contest_mode/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_set_sticky_post/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_unban/requests_the_correct_resource.yml +54 -0
- data/spec/cassettes/RedditKit_Client_Moderation/_unignore_reports/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_add_subreddit_to_multireddit/adds_a_subreddit_to_a_multireddit.yml +177 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_create_multireddit/creates_a_multireddit.yml +137 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_create_multireddit/raises_RedditKit_Conflict_when_using_an_existing_name.yml +133 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_delete_multireddit/deletes_a_multireddit.yml +134 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit/with_a_path/returns_a_multireddit.yml +39 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit/without_a_path/returns_a_multireddit.yml +39 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit_description/with_a_multireddit/returns_a_multireddit_description.yml +81 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_multireddit_description/with_a_username_and_multireddit_name/returns_a_multireddit_description.yml +45 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_my_multireddits/return_s_the_user_s_multireddits.yml +47 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_remove_subreddit_from_multireddit/removes_a_subreddit_from_a_multireddit.yml +175 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_rename_multireddit/renames_a_multireddit.yml +134 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_set_multireddit_description/returns_a_multireddit_description.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Multireddits/_update_multireddit/updates_a_multireddit.yml +184 -0
- data/spec/cassettes/RedditKit_Client_PrivateMessages/_block_author_of_message/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_PrivateMessages/_mark_as_read/requests_the_correct_resource.yml +51 -0
- data/spec/cassettes/RedditKit_Client_PrivateMessages/_mark_as_unread/requests_the_correct_resource.yml +51 -0
- data/spec/cassettes/RedditKit_Client_PrivateMessages/_messages/requests_the_correct_resource.yml +187 -0
- data/spec/cassettes/RedditKit_Client_PrivateMessages/_unblock/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Search/_search/restricts_searches_to_a_specific_subreddit.yml +878 -0
- data/spec/cassettes/RedditKit_Client_Search/_search/returns_a_specific_number_of_results.yml +130 -0
- data/spec/cassettes/RedditKit_Client_Search/_search/returns_search_results.yml +844 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_random_subreddit/returns_a_random_subreddit.yml +181 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_recommended_subreddits/returns_subreddit_names.yml +37 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_search_subreddits_by_name/returns_subreddit_names.yml +875 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subreddit/returns_a_specified_subreddit.yml +100 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subreddits/returns_a_specified_number_of_subreddits.yml +505 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subreddits/returns_subreddits_from_a_specific_category.yml +510 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subreddits_by_topic/returns_subreddit_names.yml +41 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subscribe/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subscribed_subreddits/returns_a_specified_number_of_subreddits.yml +415 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subscribed_subreddits/returns_subreddits_from_a_specific_category.yml +58 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_subscribed_subreddits/returns_the_user_s_subscribed_subreddits.yml +3469 -0
- data/spec/cassettes/RedditKit_Client_Subreddits/_unsubscribe/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Users/_friends/returns_the_user_s_friends.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Users/_my_content/returns_the_user_s_content.yml +60 -0
- data/spec/cassettes/RedditKit_Client_Users/_user/requests_the_correct_resource.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Users/_user/returns_a_specified_user.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Users/_user/returns_the_authenticated_user.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Users/_user_content/returns_the_user_s_content.yml +41 -0
- data/spec/cassettes/RedditKit_Client_Users/_username_available_/returns_false_for_an_unavailable_username.yml +36 -0
- data/spec/cassettes/RedditKit_Client_Users/_username_available_/returns_true_for_an_available_username.yml +36 -0
- data/spec/cassettes/RedditKit_Client_Voting/_downvote/with_a_comment_full_name_passed/downvotes_the_comment.yml +100 -0
- data/spec/cassettes/RedditKit_Client_Voting/_downvote/with_a_comment_passed/downvotes_the_comment.yml +154 -0
- data/spec/cassettes/RedditKit_Client_Voting/_downvote/with_a_link_full_name_passed/downvotes_the_link.yml +106 -0
- data/spec/cassettes/RedditKit_Client_Voting/_downvote/with_a_link_passed/downvotes_the_link.yml +166 -0
- data/spec/cassettes/RedditKit_Client_Voting/_upvote/with_a_comment_full_name_passed/upvotes_the_comment.yml +100 -0
- data/spec/cassettes/RedditKit_Client_Voting/_upvote/with_a_comment_passed/upvotes_the_comment.yml +154 -0
- data/spec/cassettes/RedditKit_Client_Voting/_upvote/with_a_link_full_name_passed/upvotes_the_link.yml +106 -0
- data/spec/cassettes/RedditKit_Client_Voting/_upvote/with_a_link_passed/upvotes_the_link.yml +166 -0
- data/spec/cassettes/RedditKit_Client_Voting/_withdraw_vote/with_a_comment_full_name_passed/withdraws_the_vote_on_the_comment.yml +154 -0
- data/spec/cassettes/RedditKit_Client_Voting/_withdraw_vote/with_a_comment_passed/withdraws_the_vote_on_the_comment.yml +208 -0
- data/spec/cassettes/RedditKit_Client_Voting/_withdraw_vote/with_a_link_full_name_passed/withdraws_the_vote_on_the_link.yml +166 -0
- data/spec/cassettes/RedditKit_Client_Voting/_withdraw_vote/with_a_link_passed/withdraws_the_vote_on_the_link.yml +226 -0
- data/spec/cassettes/RedditKit_Client_Wiki/_add_wiki_editor/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Wiki/_edit_wiki_page/requests_the_correct_resource.yml +48 -0
- data/spec/cassettes/RedditKit_Client_Wiki/_hide_wiki_revision/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Wiki/_remove_wiki_editor/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Client_Wiki/_revert_to_revision/requests_the_correct_resource.yml +46 -0
- data/spec/cassettes/RedditKit_Comment/should_not_be_deleted_if_neither_author_and_comment_attributes_are_set_to_deleted_.yml +90 -0
- data/spec/cassettes/RedditKit_Comment/should_return_replies.yml +90 -0
- data/spec/cassettes/authenticated_client.yml +87 -0
- data/spec/redditkit/base_spec.rb +45 -0
- data/spec/redditkit/client/account_spec.rb +50 -0
- data/spec/redditkit/client/apps_spec.rb +58 -0
- data/spec/redditkit/client/captcha_spec.rb +30 -0
- data/spec/redditkit/client/comments_spec.rb +40 -0
- data/spec/redditkit/client/flair_spec.rb +92 -0
- data/spec/redditkit/client/links_spec.rb +103 -0
- data/spec/redditkit/client/miscellaneous_spec.rb +40 -0
- data/spec/redditkit/client/moderation_spec.rb +141 -0
- data/spec/redditkit/client/multireddits_spec.rb +158 -0
- data/spec/redditkit/client/private_messages_spec.rb +51 -0
- data/spec/redditkit/client/search_spec.rb +25 -0
- data/spec/redditkit/client/subreddits_spec.rb +83 -0
- data/spec/redditkit/client/users_spec.rb +92 -0
- data/spec/redditkit/client/voting_spec.rb +99 -0
- data/spec/redditkit/client/wiki_spec.rb +40 -0
- data/spec/redditkit/client_spec.rb +46 -0
- data/spec/redditkit/comment_spec.rb +26 -0
- data/spec/redditkit/creatable_spec.rb +24 -0
- data/spec/redditkit/error_spec.rb +61 -0
- data/spec/redditkit/link_spec.rb +33 -0
- data/spec/redditkit/multireddit_spec.rb +27 -0
- data/spec/redditkit/paginated_response_spec.rb +23 -0
- data/spec/redditkit/thing_spec.rb +18 -0
- data/spec/redditkit/votable_spec.rb +52 -0
- data/spec/redditkit_spec.rb +21 -0
- data/spec/spec_helper.rb +124 -0
- metadata +390 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RedditKit::Client::Moderation, :vcr do
|
4
|
+
|
5
|
+
describe "#ban" do
|
6
|
+
it "requests the correct resource" do
|
7
|
+
authenticated_client.ban 'somefakeredditusername', redditkit_subreddit
|
8
|
+
expect(a_post('api/friend')).to have_been_made
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#unban" do
|
13
|
+
before do
|
14
|
+
stub_empty_post_request 'api/unfriend'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "requests the correct resource" do
|
18
|
+
authenticated_client.unban 'somefakeredditusername', redditkit_subreddit
|
19
|
+
expect(a_post('api/unfriend')).to have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#approve" do
|
24
|
+
before do
|
25
|
+
stub_empty_post_request 'api/approve'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "requests the correct resource" do
|
29
|
+
authenticated_client.approve test_link_full_name
|
30
|
+
expect(a_post('api/approve')).to have_been_made
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#approve" do
|
35
|
+
before do
|
36
|
+
stub_empty_post_request 'api/remove'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "requests the correct resource" do
|
40
|
+
authenticated_client.remove test_link_full_name
|
41
|
+
expect(a_post('api/remove')).to have_been_made
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#ignore_reports" do
|
46
|
+
it "requests the correct resource" do
|
47
|
+
authenticated_client.ignore_reports test_link_full_name
|
48
|
+
expect(a_post('api/ignore_reports')).to have_been_made
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#unignore_reports" do
|
53
|
+
it "requests the correct resource" do
|
54
|
+
authenticated_client.unignore_reports test_link_full_name
|
55
|
+
expect(a_post('api/unignore_reports')).to have_been_made
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#distinguish" do
|
60
|
+
before do
|
61
|
+
stub_empty_post_request 'api/distinguish/yes'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "requests the correct resource" do
|
65
|
+
authenticated_client.distinguish :comment => '12345'
|
66
|
+
expect(a_post('api/distinguish/yes')).to have_been_made
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#set_contest_mode" do
|
71
|
+
it "requests the correct resource" do
|
72
|
+
authenticated_client.set_contest_mode test_link_full_name
|
73
|
+
expect(a_post('api/set_contest_mode')).to have_been_made
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#set_sticky_post" do
|
78
|
+
it "requests the correct resource" do
|
79
|
+
authenticated_client.set_sticky_post test_link_full_name
|
80
|
+
expect(a_post('api/set_subreddit_sticky')).to have_been_made
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#moderators_of_subreddit" do
|
85
|
+
it "requests the correct resource" do
|
86
|
+
authenticated_client.moderators_of_subreddit redditkit_subreddit
|
87
|
+
expect(a_get("r/#{redditkit_subreddit}/about/moderators.json")).to have_been_made
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#contributors_to_subreddit" do
|
92
|
+
it "requests the correct resource" do
|
93
|
+
authenticated_client.contributors_to_subreddit redditkit_subreddit
|
94
|
+
expect(a_get("r/#{redditkit_subreddit}/about/contributors.json")).to have_been_made
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#accept_moderator_invitation" do
|
99
|
+
it "requests the correct resource" do
|
100
|
+
authenticated_client.accept_moderator_invitation redditkit_subreddit
|
101
|
+
expect(a_post('api/accept_moderator_invite')).to have_been_made
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#resign_as_contributor" do
|
106
|
+
before do
|
107
|
+
stub_empty_post_request('api/leavecontributor')
|
108
|
+
end
|
109
|
+
|
110
|
+
it "requests the correct resource" do
|
111
|
+
authenticated_client.resign_as_contributor '12345'
|
112
|
+
expect(a_post('api/leavecontributor')).to have_been_made
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#resign_as_moderator" do
|
117
|
+
before do
|
118
|
+
stub_empty_post_request('api/leavemoderator')
|
119
|
+
end
|
120
|
+
|
121
|
+
it "requests the correct resource" do
|
122
|
+
authenticated_client.resign_as_moderator '12345'
|
123
|
+
expect(a_post('api/leavemoderator')).to have_been_made
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#reset_subreddit_header" do
|
128
|
+
it "requests the correct resource" do
|
129
|
+
authenticated_client.reset_subreddit_header redditkit_subreddit
|
130
|
+
expect(a_post('api/delete_sr_header')).to have_been_made
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#moderation_log" do
|
135
|
+
it "returns RedditKit::ModeratorAction objects" do
|
136
|
+
moderator_actions = authenticated_client.moderation_log redditkit_subreddit
|
137
|
+
expect(moderator_actions).to_not be_nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RedditKit::Client::Multireddits, :vcr do
|
4
|
+
|
5
|
+
describe "#my_multireddits" do
|
6
|
+
it "return's the user's multireddits" do
|
7
|
+
multireddits = authenticated_client.my_multireddits
|
8
|
+
expect(multireddits).to_not be_nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#multireddit" do
|
13
|
+
context "with a path" do
|
14
|
+
it "returns a multireddit" do
|
15
|
+
multireddit = RedditKit.multireddit "/user/#{redditkit_username}/m/test"
|
16
|
+
expect(multireddit.name).to eq 'test'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "without a path" do
|
21
|
+
it "returns a multireddit" do
|
22
|
+
multireddit = RedditKit.multireddit 'RedditKitTester', 'test'
|
23
|
+
expect(multireddit.name).to eq 'test'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#multireddit_description" do
|
29
|
+
context "with a multireddit" do
|
30
|
+
it "returns a multireddit description" do
|
31
|
+
multireddit = RedditKit.multireddit 'RedditKitTester', 'test'
|
32
|
+
|
33
|
+
multireddit_description = authenticated_client.multireddit_description multireddit
|
34
|
+
expect(multireddit_description).to_not be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with a username and multireddit name" do
|
39
|
+
it "returns a multireddit description" do
|
40
|
+
multireddit_description = authenticated_client.multireddit_description 'RedditKitTester', 'test'
|
41
|
+
expect(multireddit_description).to_not be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#set_multireddit_description" do
|
47
|
+
it "returns a multireddit description" do
|
48
|
+
multireddit_description = authenticated_client.set_multireddit_description 'test', 'New description'
|
49
|
+
expect(multireddit_description.text).to eq 'New description'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#delete_multireddit" do
|
54
|
+
it "deletes a multireddit" do
|
55
|
+
multireddit_name = 'testmultireddit'
|
56
|
+
|
57
|
+
authenticated_client.create_multireddit multireddit_name, %w(ruby objectivec)
|
58
|
+
authenticated_client.delete_multireddit multireddit_name
|
59
|
+
|
60
|
+
multireddits = authenticated_client.my_multireddits
|
61
|
+
multireddit = multireddits.find { |multi| multi.name == multireddit_name }
|
62
|
+
|
63
|
+
expect(multireddit).to be_nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#create_multireddit" do
|
68
|
+
it "creates a multireddit" do
|
69
|
+
multireddit_name = 'testmultireddit'
|
70
|
+
authenticated_client.create_multireddit multireddit_name, %w(ruby objectivec)
|
71
|
+
|
72
|
+
multireddits = authenticated_client.my_multireddits
|
73
|
+
multireddit = multireddits.find { |multi| multi.name == multireddit_name }
|
74
|
+
|
75
|
+
expect(multireddit).to_not be_nil
|
76
|
+
|
77
|
+
authenticated_client.delete_multireddit multireddit_name
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises RedditKit::Conflict when using an existing name" do
|
81
|
+
authenticated_client.create_multireddit 'conflictedmultireddit'
|
82
|
+
|
83
|
+
expect { authenticated_client.create_multireddit 'conflictedmultireddit' }.to raise_error RedditKit::Conflict
|
84
|
+
|
85
|
+
authenticated_client.delete_multireddit 'conflictedmultireddit'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#update_multireddit" do
|
90
|
+
it "updates a multireddit" do
|
91
|
+
multireddit_name = 'testmultireddit'
|
92
|
+
authenticated_client.create_multireddit multireddit_name, %w(ruby objectivec)
|
93
|
+
authenticated_client.update_multireddit multireddit_name, %w(ruby objectivec haskell)
|
94
|
+
|
95
|
+
multireddits = authenticated_client.my_multireddits
|
96
|
+
multireddit = multireddits.find { |multi| multi.name == multireddit_name }
|
97
|
+
|
98
|
+
expect(multireddit.subreddits.include? 'haskell').to be_true
|
99
|
+
|
100
|
+
authenticated_client.delete_multireddit multireddit_name
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#copy_multireddit" do
|
105
|
+
before do
|
106
|
+
stub_empty_post_request 'api/multi/copy'
|
107
|
+
end
|
108
|
+
|
109
|
+
it "requests the correct resource" do
|
110
|
+
authenticated_client.copy_multireddit :user => 'somefakeusername', :multireddit => 'multireddit', :name => 'multireddit'
|
111
|
+
expect(a_post('api/multi/copy')).to have_been_made
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#rename_multireddit" do
|
116
|
+
it "renames a multireddit" do
|
117
|
+
old_name = 'multireddittorename'
|
118
|
+
new_name = 'renamedmultireddit'
|
119
|
+
|
120
|
+
authenticated_client.create_multireddit old_name
|
121
|
+
|
122
|
+
multireddit = authenticated_client.rename_multireddit old_name, new_name
|
123
|
+
expect(multireddit.name).to eq new_name
|
124
|
+
|
125
|
+
authenticated_client.delete_multireddit new_name
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#delete_multireddit" do
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#add_subreddit_to_multireddit" do
|
133
|
+
it "adds a subreddit to a multireddit" do
|
134
|
+
authenticated_client.create_multireddit 'addsubreddit', %w(ruby objectivec)
|
135
|
+
|
136
|
+
authenticated_client.add_subreddit_to_multireddit 'addsubreddit', 'haskell'
|
137
|
+
multireddit = authenticated_client.multireddit redditkit_username, 'addsubreddit'
|
138
|
+
|
139
|
+
expect(multireddit.subreddits.include? 'haskell').to be_true
|
140
|
+
|
141
|
+
authenticated_client.delete_multireddit 'addsubreddit'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#remove_subreddit_from_multireddit" do
|
146
|
+
it "removes a subreddit from a multireddit" do
|
147
|
+
authenticated_client.create_multireddit 'removesubreddit', %w(ruby objectivec haskell)
|
148
|
+
|
149
|
+
authenticated_client.remove_subreddit_from_multireddit 'removesubreddit', 'haskell'
|
150
|
+
multireddit = authenticated_client.multireddit redditkit_username, 'removesubreddit'
|
151
|
+
|
152
|
+
expect(multireddit.subreddits.include? 'haskell').to be_false
|
153
|
+
|
154
|
+
authenticated_client.delete_multireddit 'removesubreddit'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RedditKit::Client::PrivateMessages, :vcr do
|
4
|
+
|
5
|
+
describe "#messages" do
|
6
|
+
it "requests the correct resource" do
|
7
|
+
authenticated_client.messages
|
8
|
+
expect(a_get('message/inbox.json')).to have_been_made
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#send_message" do
|
13
|
+
before do
|
14
|
+
stub_empty_post_request 'api/compose'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "requests the correct resource" do
|
18
|
+
authenticated_client.send_message 'Test message', 'somefakeusername', :subject => 'Test subject'
|
19
|
+
expect(a_post('api/compose')).to have_been_made
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#mark_as_read" do
|
24
|
+
it "requests the correct resource" do
|
25
|
+
authenticated_client.mark_as_read '12345'
|
26
|
+
expect(a_post('api/read_message')).to have_been_made
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#mark_as_unread" do
|
31
|
+
it "requests the correct resource" do
|
32
|
+
authenticated_client.mark_as_unread '12345'
|
33
|
+
expect(a_post('api/unread_message')).to have_been_made
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#block_author_of_message" do
|
38
|
+
it "requests the correct resource" do
|
39
|
+
authenticated_client.block_author_of_message '12345'
|
40
|
+
expect(a_post('api/block')).to have_been_made
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#unblock" do
|
45
|
+
it "requests the correct resource" do
|
46
|
+
authenticated_client.unblock 'somefakeusername'
|
47
|
+
expect(a_post('api/unfriend')).to have_been_made
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RedditKit::Client::Search, :vcr do
|
4
|
+
|
5
|
+
describe "#search" do
|
6
|
+
it "returns search results" do
|
7
|
+
results = RedditKit.search 'ruby'
|
8
|
+
expect(results).to_not be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
it "restricts searches to a specific subreddit" do
|
12
|
+
results = RedditKit.search 'ruby', :subreddit => 'ruby', :restrict_to_subreddit => true
|
13
|
+
non_ruby_link = results.find { |link| link.subreddit != 'ruby' }
|
14
|
+
|
15
|
+
expect(results).to_not be_empty
|
16
|
+
expect(non_ruby_link).to be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns a specific number of results" do
|
20
|
+
results = RedditKit.search 'ruby', :subreddit => 'ruby', :restrict_to_subreddit => true, :limit => 3
|
21
|
+
expect(results.length).to eq 3
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RedditKit::Client::Subreddits, :vcr do
|
4
|
+
|
5
|
+
describe "#subreddits" do
|
6
|
+
it "returns a specified number of subreddits" do
|
7
|
+
subreddits = RedditKit.subreddits :limit => 3
|
8
|
+
expect(subreddits.length).to eq 3
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns subreddits from a specific category" do
|
12
|
+
RedditKit.subreddits :category => 'new'
|
13
|
+
expect(a_request(:get, "#{ RedditKit.api_endpoint }reddits/new.json")).to have_been_made
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#subscribed_subreddits" do
|
18
|
+
it "returns the user's subscribed subreddits" do
|
19
|
+
subreddits = authenticated_client.subscribed_subreddits
|
20
|
+
expect(subreddits).to_not be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a specified number of subreddits" do
|
24
|
+
subreddits = authenticated_client.subscribed_subreddits :limit => 3
|
25
|
+
expect(subreddits.length).to eq 3
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns subreddits from a specific category" do
|
29
|
+
authenticated_client.subscribed_subreddits :category => 'contributor'
|
30
|
+
expect(a_request(:get, "#{ RedditKit.api_endpoint }subreddits/mine/contributor.json")).to have_been_made
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#subreddit" do
|
35
|
+
it "returns a specified subreddit" do
|
36
|
+
subreddit = RedditKit.subreddit "programming"
|
37
|
+
expect(subreddit.display_name).to eq "programming"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#subscribe" do
|
42
|
+
it "requests the correct resource" do
|
43
|
+
authenticated_client.subscribe "programming"
|
44
|
+
expect(a_request(:post, "#{ RedditKit.api_endpoint }api/subscribe")).to have_been_made
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#unsubscribe" do
|
49
|
+
it "requests the correct resource" do
|
50
|
+
authenticated_client.unsubscribe "programming"
|
51
|
+
expect(a_request(:post, "#{ RedditKit.api_endpoint }api/subscribe")).to have_been_made
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#random_subreddit" do
|
56
|
+
it "returns a random subreddit" do
|
57
|
+
subreddit = RedditKit.random_subreddit
|
58
|
+
expect(subreddit).to_not be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#search_subreddits_by_name" do
|
63
|
+
it "returns subreddit names" do
|
64
|
+
subreddits = RedditKit.search_subreddits_by_name 'ruby'
|
65
|
+
expect(subreddits).to_not be_empty
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#subreddits_by_topic" do
|
70
|
+
it "returns subreddit names" do
|
71
|
+
subreddits = RedditKit.subreddits_by_topic 'ruby'
|
72
|
+
expect(subreddits).to_not be_empty
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#recommended_subreddits" do
|
77
|
+
it "returns subreddit names" do
|
78
|
+
subreddits = RedditKit.recommended_subreddits %w(programming)
|
79
|
+
expect(subreddits).to_not be_empty
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|