forked from RookieOne/StackOverflow-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_overflow_spec.rb
More file actions
97 lines (84 loc) · 2.33 KB
/
stack_overflow_spec.rb
File metadata and controls
97 lines (84 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'spec_helper'
describe StackOverflow do
before(:each) do
StackOverflow.API_KEY = ENV["SO_API_KEY"]
end
describe "get all users" do
context "all users" do
before(:each) do
@result = StackOverflow.get_all_users
end
it { @result.should_not be_nil }
end
context "second page" do
before(:each) do
@result = StackOverflow.get_all_users(:page => 2)
end
it { @result.should_not be_nil }
end
context "50 per page" do
before(:each) do
@result = StackOverflow.get_all_users(:pagesize => 50)
end
it { @result["users"].count.should == 50 }
end
end
describe "get user" do
context "60336" do
before(:each) do
@user = StackOverflow.get_user(60336)
end
it { @user.should_not be_nil }
it { @user["display_name"].should == "JB."}
end
context "Jared314" do
before(:each) do
@user = StackOverflow.get_user("Jared314")
end
it { @user.should be_nil }
end
end
describe "get users" do
before(:each) do
@users = StackOverflow.get_users([60336, 3381])
end
it { @users.should_not be_nil }
it { @users.select{|u| u["display_name"] == "JB"}.should_not be_nil }
it { @users.select{|u| u["display_name"] == "Ben Scheirman"}.should_not be_nil }
end
describe "get user tags" do
before(:each) do
@tags = StackOverflow.get_user_tags(60336)
end
it { @tags.should_not be_nil }
it { @tags["tags"].count.should > 0 }
end
describe "get tags" do
before(:each) do
@tags = StackOverflow.get_tags
end
it { @tags.should_not be_nil }
it { @tags["tags"].count.should > 0 }
end
describe "get tags synonyms" do
before(:each) do
@tags_synonyms = StackOverflow.get_tags_synonyms
end
it { @tags_synonyms.should_not be_nil }
it { @tags_synonyms["tag_synonyms"].count.should > 0 }
end
describe "get users answers" do
before(:each) do
@answers = StackOverflow.get_user_answers(363881)
end
it { @answers.should_not be_nil }
it { @answers.count.should > 0 }
end
describe "get users questions" do
before(:each) do
@questions = StackOverflow.get_user_questions(363881)
end
it { @questions.should_not be_nil }
it { @questions.count.should > 0 }
end
end