youroom_api 0.0.10
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/History.txt +6 -0
- data/Manifest.txt +19 -0
- data/README.txt +106 -0
- data/Rakefile +12 -0
- data/lib/object_extention.rb +52 -0
- data/lib/youroom_api/base.rb +17 -0
- data/lib/youroom_api/base_url.rb +6 -0
- data/lib/youroom_api/request/add_participation.rb +24 -0
- data/lib/youroom_api/request/add_room.rb +20 -0
- data/lib/youroom_api/request/add_user.rb +28 -0
- data/lib/youroom_api/request/destroy_entry.rb +16 -0
- data/lib/youroom_api/request/destroy_participation.rb +24 -0
- data/lib/youroom_api/request/entry.rb +4 -0
- data/lib/youroom_api/request/get_entry.rb +21 -0
- data/lib/youroom_api/request/get_room_list.rb +15 -0
- data/lib/youroom_api/request/get_user_list.rb +15 -0
- data/lib/youroom_api/request/my_group.rb +7 -0
- data/lib/youroom_api/request/participation.rb +15 -0
- data/lib/youroom_api/request/post_entry.rb +23 -0
- data/lib/youroom_api/request/room_timeline.rb +23 -0
- data/lib/youroom_api/request/show_attachment.rb +15 -0
- data/lib/youroom_api/request/timeline.rb +8 -0
- data/lib/youroom_api/request/unread_timeline.rb +12 -0
- data/lib/youroom_api/request/verify_credentials.rb +7 -0
- data/lib/youroom_api/request.rb +85 -0
- data/lib/youroom_api/version.rb +3 -0
- data/lib/youroom_api/youroom.rb +32 -0
- data/lib/youroom_api.rb +44 -0
- data/spec/setup_test_model.rb +34 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +130 -0
- data/spec/youroom_api/add_participation_spec.rb +89 -0
- data/spec/youroom_api/add_room_spec.rb +67 -0
- data/spec/youroom_api/add_user_spec.rb +75 -0
- data/spec/youroom_api/destroy_entry_spec.rb +68 -0
- data/spec/youroom_api/destroy_participation_spec.rb +89 -0
- data/spec/youroom_api/entry_spec.rb +5 -0
- data/spec/youroom_api/get_entry_spec.rb +82 -0
- data/spec/youroom_api/get_room_list_spec.rb +55 -0
- data/spec/youroom_api/get_user_list_spec.rb +55 -0
- data/spec/youroom_api/my_group_spec.rb +44 -0
- data/spec/youroom_api/object_extention_spec.rb +65 -0
- data/spec/youroom_api/participation_spec.rb +56 -0
- data/spec/youroom_api/post_entry_spec.rb +75 -0
- data/spec/youroom_api/request_spec.rb +145 -0
- data/spec/youroom_api/room_timeline_spec.rb +127 -0
- data/spec/youroom_api/show_attachment_spec.rb +30 -0
- data/spec/youroom_api/timeline_spec.rb +47 -0
- data/spec/youroom_api/unread_timeline_spec.rb +42 -0
- data/spec/youroom_api/verify_credentials_spec.rb +30 -0
- data/spec/youroom_api/youroom_spec.rb +92 -0
- metadata +125 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
describe Youroom::GetRoomList do
|
2
|
+
describe "#initialize" do
|
3
|
+
describe "when can create instance" do
|
4
|
+
subject { Youroom::GetRoomList.new(access_token, 3) }
|
5
|
+
it { should be_a(Youroom::GetRoomList) }
|
6
|
+
its(:url) { should == Youroom::BASE_URL }
|
7
|
+
its(:billing_id) { should == '3' }
|
8
|
+
its(:access_token) { should == access_token }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "when can't create instance" do
|
12
|
+
it "should raise ArgumentError" do
|
13
|
+
lambda { Youroom::GetRoomList.new(access_token, ["hoge"]) }.should raise_exception(ArgumentError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#path" do
|
19
|
+
describe "when url is default" do
|
20
|
+
before do
|
21
|
+
@client = Youroom::GetRoomList.new(access_token, 3)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { @client.path }
|
25
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_groups?format=json') }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when url is customized" do
|
29
|
+
before do
|
30
|
+
@client = Youroom::GetRoomList.new(access_token, 3, WW_URL)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { @client.path }
|
34
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_groups?format=json') }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#call" do
|
39
|
+
before do
|
40
|
+
@client = Youroom::GetRoomList.new(access_token, 3, WW_URL)
|
41
|
+
WW::Server.mock(:youroom).get("/youroom/billings/3/billing_groups") do
|
42
|
+
{ :status => "Created" }.to_json
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
WW::Server.verify(:youroom)
|
48
|
+
end
|
49
|
+
|
50
|
+
subject { @client.get }
|
51
|
+
it "should call request url" do
|
52
|
+
should be_a_instance_of(Hash)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe Youroom::GetUserList do
|
2
|
+
describe "#initialize" do
|
3
|
+
describe "when can create instance" do
|
4
|
+
subject { Youroom::GetUserList.new(access_token, 3) }
|
5
|
+
it { should be_a(Youroom::GetUserList) }
|
6
|
+
its(:url) { should == Youroom::BASE_URL }
|
7
|
+
its(:billing_id) { should == '3' }
|
8
|
+
its(:access_token) { should == access_token }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "when can't create instance" do
|
12
|
+
it "should raise ArgumentError" do
|
13
|
+
lambda { Youroom::GetUserList.new(access_token, ["hoge"]) }.should raise_exception(ArgumentError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#path" do
|
19
|
+
describe "when url is default" do
|
20
|
+
before do
|
21
|
+
@client = Youroom::GetUserList.new(access_token, 3)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { @client.path }
|
25
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_users?format=json') }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when url is customized" do
|
29
|
+
before do
|
30
|
+
@client = Youroom::GetUserList.new(access_token, 3, WW_URL)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { @client.path }
|
34
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_users?format=json') }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#call" do
|
39
|
+
before do
|
40
|
+
@client = Youroom::GetUserList.new(access_token, 3, WW_URL)
|
41
|
+
WW::Server.mock(:youroom).get("/youroom/billings/3/billing_users") do
|
42
|
+
{ :status => "Created" }.to_json
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
WW::Server.verify(:youroom)
|
48
|
+
end
|
49
|
+
|
50
|
+
subject { @client.get }
|
51
|
+
it "should call request url" do
|
52
|
+
should be_a_instance_of(Hash)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Youroom::MyGroup do
|
4
|
+
describe "#path" do
|
5
|
+
describe "when url is original" do
|
6
|
+
before do
|
7
|
+
@client = Youroom::MyGroup.new(access_token)
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { @client.path }
|
11
|
+
it { should == File.join(Youroom::BASE_URL, 'groups', 'my?format=json') }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when url is not original" do
|
15
|
+
before do
|
16
|
+
@client = Youroom::MyGroup.new(access_token, WW_URL)
|
17
|
+
end
|
18
|
+
|
19
|
+
subject { @client.path }
|
20
|
+
it { should == File.join(WW_URL, 'groups', 'my?format=json') }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#call" do
|
25
|
+
before do
|
26
|
+
@client = Youroom::MyGroup.new(access_token, WW_URL)
|
27
|
+
|
28
|
+
# NOTICE: WW not check params
|
29
|
+
WW::Server.mock(:youroom, { :format => "json"} ).get("/youroom/groups/my") do
|
30
|
+
{ :entry => "hogehoge" }.to_json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
after do
|
35
|
+
WW::Server.verify(:youroom)
|
36
|
+
end
|
37
|
+
|
38
|
+
subject { @client.get }
|
39
|
+
it "should call request url" do
|
40
|
+
should be_a_instance_of(Hash)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
describe "#optimize" do
|
5
|
+
describe "case1: no nest hash" do
|
6
|
+
before { @hash = { :a => "b"} }
|
7
|
+
subject { @hash.optimize }
|
8
|
+
it { should == {"a"=>"b"}}
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "case2: nested hash" do
|
12
|
+
before { @hash = {:a=> "b", :b => { :c => 3 } } }
|
13
|
+
subject { @hash.optimize }
|
14
|
+
it { should == {"a"=>"b", "b[c]"=>"3"}}
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "case3: nested hash and has many elements in hash" do
|
18
|
+
before { @hash = {:a=> "b", :b => { :c => 3, :d => 4 } } }
|
19
|
+
subject { @hash.optimize }
|
20
|
+
it { should == {"a"=>"b", "b[c]"=>"3", "b[d]"=>"4"}}
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "case4: nested level is 2" do
|
24
|
+
before { @hash = {:a=> { :b => { :c => 1 } } } }
|
25
|
+
subject { @hash.optimize }
|
26
|
+
it { should == { 'a[b][c]' => "1" } }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "case5: nested level is 2 and has many elements in hash" do
|
30
|
+
before do
|
31
|
+
@hash = {:a=> 1,
|
32
|
+
:b=> {:c => 2,
|
33
|
+
:d => {:e => 3,
|
34
|
+
:f => 4,
|
35
|
+
:g => 5 }}}
|
36
|
+
end
|
37
|
+
|
38
|
+
subject { @hash.optimize }
|
39
|
+
it do
|
40
|
+
should == {'a' => '1',
|
41
|
+
'b[c]' => '2',
|
42
|
+
'b[d][e]' => '3',
|
43
|
+
'b[d][f]' => '4',
|
44
|
+
'b[d][g]' => '5' }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "case6: nested level is 2 and has many elements in hash" do
|
49
|
+
before do
|
50
|
+
@hash = { :billing_user => { :name => "moge",
|
51
|
+
:user_attributes => { :email => "hoge@gmail.com",
|
52
|
+
:password => "hogehoge",
|
53
|
+
:password_confirmation => "hogehoge" }}}
|
54
|
+
end
|
55
|
+
|
56
|
+
subject { @hash.optimize }
|
57
|
+
it do
|
58
|
+
should == {'billing_user[name]' => 'moge',
|
59
|
+
'billing_user[user_attributes][email]' => 'hoge@gmail.com',
|
60
|
+
'billing_user[user_attributes][password]' => 'hogehoge',
|
61
|
+
'billing_user[user_attributes][password_confirmation]' => 'hogehoge' }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Youroom::Participation do
|
5
|
+
describe "#initialize" do
|
6
|
+
describe "when can not create instanse" do
|
7
|
+
before do
|
8
|
+
@error_data1 = ["hoge", nil]
|
9
|
+
@error_data2 = [nil, "hoge"]
|
10
|
+
end
|
11
|
+
|
12
|
+
it do
|
13
|
+
lambda { Youroom::Participation.new(*@error_data1) }.should raise_exception(ArgumentError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it do
|
17
|
+
lambda { Youroom::Participation.new(*@error_data2) }.should raise_exception(ArgumentError)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "when can create user instance" do
|
23
|
+
context "room_idに文字列を渡した場合" do
|
24
|
+
subject { Youroom::Participation.new(access_token, "room_id", "participation_id") }
|
25
|
+
it { should be_a(Youroom::Participation) }
|
26
|
+
its(:url) { should == Youroom::BASE_URL }
|
27
|
+
its(:room_id) { should == "room_id" }
|
28
|
+
its(:participation_id) { should == "participation_id" }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "room_idに数字を渡した場合" do
|
32
|
+
subject { Youroom::Participation.new(access_token, 1000, "participation_id") }
|
33
|
+
its(:url) { should == Youroom::BASE_URL }
|
34
|
+
its(:room_id) { should == 1000 }
|
35
|
+
its(:participation_id) { should == "participation_id" }
|
36
|
+
end
|
37
|
+
|
38
|
+
context "participation_idに数字を渡した場合" do
|
39
|
+
subject { Youroom::Participation.new(access_token, 1000, 2000) }
|
40
|
+
its(:url) { should == Youroom::BASE_URL }
|
41
|
+
its(:room_id) { should == 1000 }
|
42
|
+
its(:participation_id) { should == 2000 }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#path" do
|
48
|
+
before do
|
49
|
+
@participation = Youroom::Participation.new(access_token, "room_id", "participation_id", WW_URL)
|
50
|
+
end
|
51
|
+
|
52
|
+
subject { @participation.path }
|
53
|
+
it { should == File.join(WW_URL, 'group', 'room_id', 'participations', 'participation_id.json') }
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Youroom::PostEntry do
|
5
|
+
describe "#initialize" do
|
6
|
+
describe "when can create instance" do
|
7
|
+
subject { Youroom::PostEntry.new(access_token, "room_id", "hogehoge", nil) }
|
8
|
+
it { should be_a(Youroom::PostEntry) }
|
9
|
+
its(:url) { should == Youroom::BASE_URL }
|
10
|
+
its(:room_id) { should == "room_id" }
|
11
|
+
its(:content) { should == "hogehoge" }
|
12
|
+
its(:access_token) { should == access_token }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "room_idにFixunumオブジェクトが引数になった場合" do
|
16
|
+
it "例外が発生しないこと" do
|
17
|
+
lambda { Youroom::PostEntry.new(access_token, 100, "test") }.should_not raise_exception
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "contentにFixunumオブジェクトが引数になった場合" do
|
22
|
+
it "例外が発生しないこと" do
|
23
|
+
lambda { Youroom::PostEntry.new(access_token, 100, 1000) }.should_not raise_exception
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#path" do
|
29
|
+
describe "when url is original" do
|
30
|
+
before do
|
31
|
+
@client = Youroom::PostEntry.new(access_token, "room_id", "hogehoge", nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { @client.path }
|
35
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'entries?format=json') }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "when url is not original" do
|
39
|
+
before do
|
40
|
+
@client = Youroom::PostEntry.new(access_token, "room_id", "hogehoge", WW_URL)
|
41
|
+
end
|
42
|
+
|
43
|
+
subject { @client.path }
|
44
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'entries?format=json') }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#post" do
|
49
|
+
before do
|
50
|
+
@client = Youroom::PostEntry.new(access_token, "room_id", "hogehoge", nil, WW_URL)
|
51
|
+
WW::Server.mock(:youroom).post("/youroom/r/room_id/entries") do
|
52
|
+
{ :status => "Created" }.to_json
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
WW::Server.verify(:youroom)
|
58
|
+
end
|
59
|
+
|
60
|
+
subject { @client.post }
|
61
|
+
it "should call request url" do
|
62
|
+
should be_a_instance_of(Hash)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#params" do
|
67
|
+
before do
|
68
|
+
@client = Youroom::PostEntry.new(access_token, "room_id", "hogehoge", nil, WW_URL)
|
69
|
+
end
|
70
|
+
|
71
|
+
subject { @client.params }
|
72
|
+
it { should == { 'entry[content]' => 'hogehoge', 'insert_mention' => '' } }
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Youroom::Request do
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
subject { Youroom::Request.new(access_token, "http://www.yahoo.co.jp") }
|
8
|
+
it { should be_a(Youroom::Request) }
|
9
|
+
its(:url) { should == "http://www.yahoo.co.jp"}
|
10
|
+
its(:access_token) { should == access_token }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#get_entry(room_id)" do
|
14
|
+
it "should get GetEntry.new" do
|
15
|
+
Youroom::GetEntry.should_receive(:new).with(access_token, "room_id", nil, Youroom::BASE_URL).
|
16
|
+
and_return(entry)
|
17
|
+
entry.should_receive(:get)
|
18
|
+
Youroom::Request.new(access_token).get_entry("room_id")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#get_verify_credentials" do
|
23
|
+
it "should get VerifyCredentials.new" do
|
24
|
+
Youroom::VerifyCredentials.should_receive(:new).with(access_token, Youroom::BASE_URL).
|
25
|
+
and_return(verify_credentials)
|
26
|
+
verify_credentials.should_receive(:get)
|
27
|
+
Youroom::Request.new(access_token).get_verify_credentials
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#get_attachment" do
|
32
|
+
it "should get ShowAttachment.new" do
|
33
|
+
Youroom::ShowAttachment.should_receive(:new).with(access_token, "room_id", "mutter_id", Youroom::BASE_URL).
|
34
|
+
and_return(show_attachment)
|
35
|
+
show_attachment.should_receive(:get)
|
36
|
+
Youroom::Request.new(access_token).get_attachment("room_id", "mutter_id")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#get_entry(room_id, mutter_id)" do
|
41
|
+
it "should get GetEntry.new" do
|
42
|
+
Youroom::GetEntry.should_receive(:new).with(access_token, "room_id", "mutter_id", Youroom::BASE_URL).
|
43
|
+
and_return(entry)
|
44
|
+
entry.should_receive(:get)
|
45
|
+
Youroom::Request.new(access_token).get_entry("room_id", "mutter_id")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#destroy_entry(room_id, mutter_id" do
|
50
|
+
it "should get DestroyEntry.new" do
|
51
|
+
Youroom::DestroyEntry.should_receive(:new).and_return(destroy_entry)
|
52
|
+
destroy_entry.should_receive(:delete)
|
53
|
+
Youroom::Request.new(access_token).destroy_entry("room_id", "mutter_id")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#get_all_timeline" do
|
58
|
+
it "should get Youroom:TimeLine.new" do
|
59
|
+
Youroom::HomeTimeline.should_receive(:new).and_return(timeline)
|
60
|
+
timeline.should_receive(:get)
|
61
|
+
Youroom::Request.new(access_token).get_all_timeline
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#get_unread_timeline" do
|
66
|
+
it "should get Youroom:TimeLine.new" do
|
67
|
+
Youroom::UnreadTimeline.should_receive(:new).and_return(unread_timeline)
|
68
|
+
unread_timeline.should_receive(:get)
|
69
|
+
Youroom::Request.new(access_token).get_unread_timeline
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#get_room_timeline" do
|
74
|
+
it "should get Youroom:RoomTimeline.new" do
|
75
|
+
Youroom::RoomTimeline.should_receive(:new).and_return(room_timeline)
|
76
|
+
room_timeline.should_receive(:get)
|
77
|
+
Youroom::Request.new(access_token).get_room_timeline("room_id", {})
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#create_entry(room_id, content)" do
|
82
|
+
it "should get Youroom:TimeLine.new" do
|
83
|
+
Youroom::PostEntry.should_receive(:new).and_return(create_entry_request)
|
84
|
+
create_entry_request.should_receive(:post)
|
85
|
+
Youroom::Request.new(access_token).create_entry("room_id", "hogehoge")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#get_my_group" do
|
90
|
+
it "should get Youroom:MyGroup.new" do
|
91
|
+
Youroom::MyGroup.should_receive(:new).and_return(create_my_group_request)
|
92
|
+
create_my_group_request.should_receive(:get)
|
93
|
+
Youroom::Request.new(access_token).get_my_group
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#create_room" do
|
98
|
+
it "should get Youroom:AddRoom.new" do
|
99
|
+
Youroom::AddRoom.should_receive(:new).and_return(add_room_request)
|
100
|
+
add_room_request.should_receive(:post)
|
101
|
+
Youroom::Request.new(access_token).create_room(3, "new room")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#get_room_list" do
|
106
|
+
it "should get Youroom:GetRoomList.new" do
|
107
|
+
Youroom::GetRoomList.should_receive(:new).and_return(room_list_request)
|
108
|
+
room_list_request.should_receive(:get)
|
109
|
+
Youroom::Request.new(access_token).get_room_list("3")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#create_participation" do
|
114
|
+
it "should get Youroom:AddParticipation.new" do
|
115
|
+
Youroom::AddParticipation.should_receive(:new).and_return(add_participation_request)
|
116
|
+
add_participation_request.should_receive(:post)
|
117
|
+
Youroom::Request.new(access_token).create_participation("3", "4", "pochi.black@gmail.com")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#destoy_participation" do
|
122
|
+
it "should get Youroom:DestroyParticipation.new" do
|
123
|
+
Youroom::DestroyParticipation.should_receive(:new).and_return(destroy_participation_request)
|
124
|
+
destroy_participation_request.should_receive(:delete)
|
125
|
+
Youroom::Request.new(access_token).destroy_participation("3", "4", "pochi.black@gmail.com")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#create_user" do
|
130
|
+
it "should get Youroom::AddUser.new" do
|
131
|
+
Youroom::AddUser.should_receive(:new).and_return(add_user_request)
|
132
|
+
add_user_request.should_receive(:post)
|
133
|
+
Youroom::Request.new(access_token).create_user("3", user_params)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "#get_user_list" do
|
138
|
+
it "should get Youroom::GetUserList" do
|
139
|
+
Youroom::GetUserList.should_receive(:new).and_return(get_user_list_request)
|
140
|
+
get_user_list_request.should_receive(:get)
|
141
|
+
Youroom::Request.new(access_token).get_user_list("3")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
describe Youroom::RoomTimeline do
|
6
|
+
describe "#path" do
|
7
|
+
context "本家のURLを利用する場合" do
|
8
|
+
before do
|
9
|
+
@client = Youroom::RoomTimeline.new(access_token, 500)
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { @client.path }
|
13
|
+
|
14
|
+
it "正しいURLが設定されていること" do
|
15
|
+
should == File.join(@client.url, 'r', '500', '?format=json')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "本家を利用しない場合" do
|
20
|
+
before do
|
21
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { }, WW_URL)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { @client.path }
|
25
|
+
it "正しいURLが設定されていること" do
|
26
|
+
should == File.join(@client.url, 'r', '500', '?format=json')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "パラメータを設定する場合" do
|
31
|
+
context "sinceを設定する場合" do
|
32
|
+
before do
|
33
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { :since => "hogehoge" })
|
34
|
+
end
|
35
|
+
|
36
|
+
subject { @client.path }
|
37
|
+
|
38
|
+
it "Queryパラメータにsinceが設定されていること" do
|
39
|
+
should == File.join(@client.url, 'r', '500', '?format=json&since=hogehoge')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "serach_queryを設定する場合" do
|
44
|
+
before do
|
45
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { :search_query => "hogehoge" })
|
46
|
+
end
|
47
|
+
|
48
|
+
subject { @client.path }
|
49
|
+
|
50
|
+
it "Queryパラメータにsearch_queryが設定されていること" do
|
51
|
+
should == File.join(@client.url, 'r', '500', '?format=json&search_query=hogehoge')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "flatを設定する場合" do
|
56
|
+
before do
|
57
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { :flat => "true" })
|
58
|
+
end
|
59
|
+
|
60
|
+
subject { @client.path }
|
61
|
+
|
62
|
+
it "Queryパラメータにflatが設定されていること" do
|
63
|
+
should == File.join(@client.url, 'r', '500', '?format=json&flat=true')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "pageを設定する場合" do
|
68
|
+
before do
|
69
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { :page => 3 })
|
70
|
+
end
|
71
|
+
|
72
|
+
subject { @client.path }
|
73
|
+
|
74
|
+
it "Queryパラメータにpageが設定されていること" do
|
75
|
+
should == File.join(@client.url, 'r', '500', '?format=json&page=3')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "read_stateを設定する場合" do
|
80
|
+
before do
|
81
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { :read_state => "unread" })
|
82
|
+
end
|
83
|
+
|
84
|
+
subject { @client.path }
|
85
|
+
|
86
|
+
it "Queryパラメータにread_stateが設定されていること" do
|
87
|
+
should == File.join(@client.url, 'r', '500', '?format=json&read_state=unread')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "複合オプションを設定した場合" do
|
92
|
+
before do
|
93
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { :read_state => "unread", :page => 3, :flat => "true" })
|
94
|
+
end
|
95
|
+
|
96
|
+
subject { @client.path }
|
97
|
+
|
98
|
+
it "Queryパラメータに複合パラメータが設定されていること" do
|
99
|
+
should == File.join(@client.url, 'r', '500', '?format=json&page=3&flat=true&read_state=unread')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#call" do
|
106
|
+
before do
|
107
|
+
@client = Youroom::RoomTimeline.new(access_token, 500, { }, WW_URL)
|
108
|
+
# dammy ww url
|
109
|
+
@client.should_receive(:path).at_least(1).and_return("http://localhost:8083/r/500/?format=json")
|
110
|
+
|
111
|
+
# NOTICE: WW not check params
|
112
|
+
WW::Server.mock(:youroom, { :format => "json"} ).get("/r/500/") do
|
113
|
+
{ :entry => "hogehoge" }.to_json
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
after do
|
118
|
+
WW::Server.verify(:youroom)
|
119
|
+
end
|
120
|
+
|
121
|
+
subject { @client.get }
|
122
|
+
it "should call request url" do
|
123
|
+
should be_a_instance_of(Hash)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
describe Youroom::ShowAttachment, :current => true do
|
6
|
+
describe "#path" do
|
7
|
+
context "本家のURLを利用する場合" do
|
8
|
+
before do
|
9
|
+
@client = Youroom::ShowAttachment.new(access_token, "room_id", "entry_id")
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { @client.path }
|
13
|
+
|
14
|
+
it "正しいURLが設定されていること" do
|
15
|
+
should == File.join(@client.url, 'r', 'room_id', 'entries', 'entry_id', 'attachment', '?format=json')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "本家を利用しない場合" do
|
20
|
+
before do
|
21
|
+
@client = Youroom::ShowAttachment.new(access_token, "room_id", "entry_id", WW_URL)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { @client.path }
|
25
|
+
it "正しいURLが設定されていること" do
|
26
|
+
should == File.join(@client.url, 'r', 'room_id', 'entries', 'entry_id', 'attachment', '?format=json')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|