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
data/lib/youroom_api.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "object_extention"
|
3
|
+
require "oauth"
|
4
|
+
require 'uri'
|
5
|
+
require 'net/http'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
module Youroom
|
9
|
+
# base
|
10
|
+
autoload :VERSION, 'youroom_api/version'
|
11
|
+
autoload :BASE_URL, 'youroom_api/base_url'
|
12
|
+
autoload :Base, 'youroom_api/base'
|
13
|
+
autoload :OAuth, 'youroom_api/youroom'
|
14
|
+
autoload :Request, 'youroom_api/request'
|
15
|
+
|
16
|
+
autoload :VerifyCredentials, 'youroom_api/request/verify_credentials'
|
17
|
+
autoload :ShowAttachment, 'youroom_api/request/show_attachment'
|
18
|
+
|
19
|
+
# relation home
|
20
|
+
autoload :HomeTimeline, 'youroom_api/request/timeline'
|
21
|
+
autoload :UnreadTimeline, 'youroom_api/request/unread_timeline'
|
22
|
+
autoload :RoomTimeline, 'youroom_api/request/room_timeline'
|
23
|
+
autoload :MyGroup, 'youroom_api/request/my_group'
|
24
|
+
|
25
|
+
# relation entry
|
26
|
+
autoload :Entry, 'youroom_api/request/entry'
|
27
|
+
autoload :GetEntry, 'youroom_api/request/get_entry'
|
28
|
+
autoload :PostEntry, 'youroom_api/request/post_entry'
|
29
|
+
autoload :DestroyEntry, 'youroom_api/request/destroy_entry'
|
30
|
+
|
31
|
+
# relation room
|
32
|
+
autoload :AddRoom, 'youroom_api/request/add_room' # enterprise only
|
33
|
+
autoload :GetRoomList, 'youroom_api/request/get_room_list' # enterprise only
|
34
|
+
|
35
|
+
# relation user
|
36
|
+
autoload :AddUser, 'youroom_api/request/add_user' # enterprise only
|
37
|
+
autoload :GetUserList, 'youroom_api/request/get_user_list' # enterprise only
|
38
|
+
|
39
|
+
# relation participation
|
40
|
+
autoload :Participation, 'youroom_api/request/participation'
|
41
|
+
autoload :AddParticipation, 'youroom_api/request/add_participation' # enterprise only
|
42
|
+
autoload :DestroyParticipation, 'youroom_api/request/destroy_participation' # enterprise only
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class User
|
2
|
+
attr_accessor :name, :mail, :login
|
3
|
+
|
4
|
+
def initialize(name, mail, login)
|
5
|
+
@name, @mail, @login = name, mail, login
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Project
|
10
|
+
attr_accessor :room_id
|
11
|
+
|
12
|
+
def initialize(id=nil)
|
13
|
+
@room_id = id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class OAuthUser
|
18
|
+
attr_accessor :consumer_key, :consumer_secret, :access_token, :access_token_secret
|
19
|
+
|
20
|
+
def initialize(consumer_key, consumer_secret, access_token, access_token_secret)
|
21
|
+
@consumer_key = consumer_key
|
22
|
+
@consumer_secret = consumer_secret
|
23
|
+
@access_token = access_token
|
24
|
+
@access_token_secret = access_token_secret
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Entry
|
29
|
+
attr_accessor :id
|
30
|
+
|
31
|
+
def initialize(id)
|
32
|
+
@id = id
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
begin
|
5
|
+
require 'spec'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rspec'
|
8
|
+
end
|
9
|
+
require 'ww'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
|
13
|
+
$LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
|
14
|
+
|
15
|
+
require "youroom_api.rb"
|
16
|
+
|
17
|
+
|
18
|
+
load File.expand_path("setup_test_model.rb", File.dirname(__FILE__))
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
WW_URL = "http://localhost:8083/youroom/"
|
22
|
+
|
23
|
+
# ww config
|
24
|
+
WW::Server.handler = :webrick
|
25
|
+
|
26
|
+
WW::Server[:youroom] ||= WW::Server.build_double(8083) do
|
27
|
+
# sample spy
|
28
|
+
spy.get("/messages/:user.json") do |user|
|
29
|
+
content_type "application/json"
|
30
|
+
body = [ { :message => "hoge"} ].to_json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
WW::Server.start_once(:youroom)
|
35
|
+
|
36
|
+
def access_token
|
37
|
+
@access_token ||= OAuth::AccessToken.new(consumer, "hoge", "hoge")
|
38
|
+
end
|
39
|
+
|
40
|
+
def consumer
|
41
|
+
@consumer ||= OAuth::Consumer.new("a", "b")
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_room
|
45
|
+
@create_room ||= mock(Youroom::CreateRoom)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_user
|
49
|
+
@create_user ||= mock(Youroom::CreateUser)
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_participation
|
53
|
+
@create_participation ||= mock(Youroom::CreateParticipation)
|
54
|
+
end
|
55
|
+
|
56
|
+
def destroy_participation
|
57
|
+
@destroy_participation ||= mock(Youroom::DestroyParticipation)
|
58
|
+
end
|
59
|
+
|
60
|
+
def entry
|
61
|
+
@entry ||= mock(Youroom::GetEntry)
|
62
|
+
end
|
63
|
+
|
64
|
+
def verify_credentials
|
65
|
+
@verify_credentials ||= mock(Youroom::VerifyCredentials)
|
66
|
+
end
|
67
|
+
|
68
|
+
def show_attachment
|
69
|
+
@show_attachment ||= mock(Youroom::ShowAttachment)
|
70
|
+
end
|
71
|
+
|
72
|
+
def participation
|
73
|
+
@participation ||= mock(Youroom::Participation)
|
74
|
+
end
|
75
|
+
|
76
|
+
def timeline
|
77
|
+
@timeline ||= mock(Youroom::HomeTimeline)
|
78
|
+
end
|
79
|
+
|
80
|
+
def unread_timeline
|
81
|
+
@timeline ||= mock(Youroom::UnreadTimeline)
|
82
|
+
end
|
83
|
+
|
84
|
+
def room_timeline
|
85
|
+
@timeline ||= mock(Youroom::RoomTimeline)
|
86
|
+
end
|
87
|
+
|
88
|
+
def create_entry_request
|
89
|
+
@create_entry_request ||= mock(Youroom::PostEntry)
|
90
|
+
end
|
91
|
+
|
92
|
+
def create_my_group_request
|
93
|
+
@create_my_group_request ||= mock(Youroom::MyGroup)
|
94
|
+
end
|
95
|
+
|
96
|
+
def destroy_entry
|
97
|
+
@destroy_entry_request ||= mock(Youroom::DestroyEntry)
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_room_request
|
101
|
+
@add_room_request ||= mock(Youroom::AddRoom)
|
102
|
+
end
|
103
|
+
|
104
|
+
def room_list_request
|
105
|
+
@get_room_list ||= mock(Youroom::GetRoomList)
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_participation_request
|
109
|
+
@add_participation_request ||= mock(Youroom::AddParticipation)
|
110
|
+
end
|
111
|
+
|
112
|
+
def destroy_participation_request
|
113
|
+
@destroy_participation_request ||= mock(Youroom::DestroyParticipation)
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_user_request
|
117
|
+
@add_user_request ||= mock(Youroom::AddUser)
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_user_list_request
|
121
|
+
@get_user_list_request ||= mock(Youroom::GetUserList)
|
122
|
+
end
|
123
|
+
|
124
|
+
def user_params
|
125
|
+
{ :name => 'new user',
|
126
|
+
:email => 'pochi.black@gmail.com',
|
127
|
+
:password => 'hogehoge',
|
128
|
+
:password_confirmation => 'hogehoge' }
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Youroom::AddParticipation do
|
4
|
+
describe "#initialize" do
|
5
|
+
describe "when can create instance" do
|
6
|
+
subject { Youroom::AddParticipation.new(access_token, 3, 4, "pochi.black@gmail.com") }
|
7
|
+
it { should be_a(Youroom::AddParticipation) }
|
8
|
+
its(:url) { should == Youroom::BASE_URL }
|
9
|
+
its(:billing_id) { should == '3' }
|
10
|
+
its(:billing_group_id) { should == '4' }
|
11
|
+
its(:email) { should == "pochi.black@gmail.com" }
|
12
|
+
its(:access_token) { should == access_token }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "when can't create instance" do
|
16
|
+
describe "case1: argument size is wrong" do
|
17
|
+
it "should raise ArgumentError" do
|
18
|
+
lambda { Youroom::AddRoom.new(access_token, 100) }.should raise_exception(ArgumentError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "case2: billing_id structure is failed" do
|
23
|
+
it "should raise ArgumentError" do
|
24
|
+
lambda { Youroom::AddRoom.new(access_token, [100], 100, "pochi@gmail.com") }.should raise_exception(ArgumentError)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "case3: billing_group_id structure is failed" do
|
29
|
+
it "should raise ArgumentError" do
|
30
|
+
lambda { Youroom::AddRoom.new(access_token, 100, [100], "pochi@gmail.com") }.should raise_exception(ArgumentError)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "case4: email structure is failed" do
|
35
|
+
it "should raise ArgumentError" do
|
36
|
+
lambda { Youroom::AddRoom.new(access_token, 100, 100, 123) }.should raise_exception(ArgumentError)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#path" do
|
44
|
+
describe "when url is default" do
|
45
|
+
before do
|
46
|
+
@client = Youroom::AddParticipation.new(access_token, 3, 4, "pochi@gmail.com")
|
47
|
+
end
|
48
|
+
|
49
|
+
subject { @client.path }
|
50
|
+
it { should == File.join(::Youroom::BASE_URL, 'billings', '3', 'billing_groups', '4', 'participations', 'add?format=json') }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "when url is customized" do
|
54
|
+
before do
|
55
|
+
@client = Youroom::AddParticipation.new(access_token, 3, 4, "pochi@gmail.com", WW_URL)
|
56
|
+
end
|
57
|
+
|
58
|
+
subject { @client.path }
|
59
|
+
it { should == File.join(WW_URL, 'enterprise', 'billings', '3', 'billing_groups', '4', 'participations', 'add?format=json')}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#params" do
|
64
|
+
before do
|
65
|
+
@client = Youroom::AddParticipation.new(access_token, 3, 4, "pochi.black@gmail.com")
|
66
|
+
end
|
67
|
+
|
68
|
+
subject { @client.params }
|
69
|
+
it { should == {'email' => 'pochi.black@gmail.com' } }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#post" do
|
73
|
+
before do
|
74
|
+
@client = Youroom::AddParticipation.new(access_token, 3, 4, "pochi@gmail.com", WW_URL)
|
75
|
+
WW::Server.mock(:youroom).post("/youroom/enterprise/billings/3/billing_groups/4/participations/add") do
|
76
|
+
{ :status => "Created" }.to_json
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
WW::Server.verify(:youroom)
|
82
|
+
end
|
83
|
+
|
84
|
+
subject { @client.post }
|
85
|
+
it "should get request url" do
|
86
|
+
should be_a_instance_of(Hash)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Youroom::AddRoom do
|
4
|
+
describe "#initialize" do
|
5
|
+
describe "when can create instance" do
|
6
|
+
subject { Youroom::AddRoom.new(access_token, 3, "new room") }
|
7
|
+
it { should be_a(Youroom::AddRoom) }
|
8
|
+
its(:url) { should == Youroom::BASE_URL }
|
9
|
+
its(:billing_id) { should == '3' }
|
10
|
+
its(:name) { should == "new room" }
|
11
|
+
its(:access_token) { should == access_token }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when can't create instance" do
|
15
|
+
it "should raise ArgumentError" do
|
16
|
+
lambda { Youroom::AddRoom.new(access_token, 100) }.should raise_exception(ArgumentError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#path" do
|
22
|
+
describe "when url is default" do
|
23
|
+
before do
|
24
|
+
@client = Youroom::AddRoom.new(access_token, 3, "newroom")
|
25
|
+
end
|
26
|
+
|
27
|
+
subject { @client.path }
|
28
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_groups?format=json') }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when url is customized" do
|
32
|
+
before do
|
33
|
+
@client = Youroom::AddRoom.new(access_token, 3, "newroom", WW_URL)
|
34
|
+
end
|
35
|
+
|
36
|
+
subject { @client.path }
|
37
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_groups?format=json') }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#params" do
|
42
|
+
before do
|
43
|
+
@client = Youroom::AddRoom.new(access_token, 3, "newroom")
|
44
|
+
end
|
45
|
+
|
46
|
+
subject { @client.params }
|
47
|
+
it { should == {'billing_group[group_attributes][name]' => 'newroom' } }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#post" do
|
51
|
+
before do
|
52
|
+
@client = Youroom::AddRoom.new(access_token, 3, "hogehoge", WW_URL)
|
53
|
+
WW::Server.mock(:youroom).post("/youroom/billings/3/billing_groups") do
|
54
|
+
{ :status => "Created" }.to_json
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
after do
|
59
|
+
WW::Server.verify(:youroom)
|
60
|
+
end
|
61
|
+
|
62
|
+
subject { @client.post }
|
63
|
+
it "should call request url" do
|
64
|
+
should be_a_instance_of(Hash)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Youroom::AddUser do
|
4
|
+
describe "#initialize" do
|
5
|
+
describe "when can create instance" do
|
6
|
+
subject { Youroom::AddUser.new(access_token, 3, user_params) }
|
7
|
+
it { should be_a(Youroom::AddUser) }
|
8
|
+
its(:url) { should == Youroom::BASE_URL }
|
9
|
+
its(:name) { should == 'new user' }
|
10
|
+
its(:email) { should == 'pochi.black@gmail.com' }
|
11
|
+
its(:password) { should == 'hogehoge' }
|
12
|
+
its(:password_confirmation) { should == 'hogehoge' }
|
13
|
+
its(:billing_id) { should == '3' }
|
14
|
+
its(:access_token) { should == access_token }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "when can't create instance" do
|
18
|
+
it "should raise ArgumentError" do
|
19
|
+
lambda { Youroom::AddUser.new(access_token, 100) }.should raise_exception(ArgumentError)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#path" do
|
25
|
+
describe "when url is default" do
|
26
|
+
before do
|
27
|
+
@client = Youroom::AddUser.new(access_token, 3, user_params)
|
28
|
+
end
|
29
|
+
|
30
|
+
subject { @client.path }
|
31
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_users?format=json') }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "when url is customized" do
|
35
|
+
before do
|
36
|
+
@client = Youroom::AddUser.new(access_token, 3, user_params, WW_URL)
|
37
|
+
end
|
38
|
+
|
39
|
+
subject { @client.path }
|
40
|
+
it { should == File.join(@client.url, 'billings', '3', 'billing_users?format=json') }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#params" do
|
45
|
+
before do
|
46
|
+
@client = Youroom::AddUser.new(access_token, 3, user_params)
|
47
|
+
end
|
48
|
+
|
49
|
+
subject { @client.params }
|
50
|
+
it do
|
51
|
+
should == { 'billing_user[name]' => 'new user',
|
52
|
+
'billing_user[user_attributes][email]' => 'pochi.black@gmail.com',
|
53
|
+
'billing_user[user_attributes][password]' => 'hogehoge',
|
54
|
+
'billing_user[user_attributes][password_confirmation]' => 'hogehoge' }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#post" do
|
59
|
+
before do
|
60
|
+
@client = Youroom::AddUser.new(access_token, 3, user_params, WW_URL)
|
61
|
+
WW::Server.mock(:youroom).post("/youroom/billings/3/billing_users") do
|
62
|
+
{ :status => "Created" }.to_json
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
after do
|
67
|
+
WW::Server.verify(:youroom)
|
68
|
+
end
|
69
|
+
|
70
|
+
subject { @client.post }
|
71
|
+
it "should call request url" do
|
72
|
+
should be_a_instance_of(Hash)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Youroom::DestroyEntry do
|
5
|
+
describe "#initialize" do
|
6
|
+
describe "when can create instance" do
|
7
|
+
subject { Youroom::DestroyEntry.new(access_token, "room_id", 1111) }
|
8
|
+
it { should be_a(Youroom::DestroyEntry) }
|
9
|
+
its(:url) { should == Youroom::BASE_URL }
|
10
|
+
its(:room_id) { should == "room_id" }
|
11
|
+
its(:mutter_id) { should == 1111 }
|
12
|
+
its(:access_token) { should == access_token }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "room_idにFixnumを指定した場合" do
|
16
|
+
it "例外が発生しないこと" do
|
17
|
+
lambda { Youroom::DestroyEntry.new(access_token, 100, 1111) }.should_not raise_exception
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when can't create instance" do
|
22
|
+
describe "case1: mutter is not either String or Fixnum" do
|
23
|
+
it "should raise ArgumentError" do
|
24
|
+
lambda { Youroom::PostEntry.new(access_token, "room_id", [1111]) }.should raise_exception(ArgumentError)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#path" do
|
31
|
+
describe "when url is original" do
|
32
|
+
before do
|
33
|
+
@client = Youroom::DestroyEntry.new(access_token, "room_id", 1111)
|
34
|
+
end
|
35
|
+
|
36
|
+
subject { @client.path }
|
37
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'entries', '1111?format=json') }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "when url is not original" do
|
41
|
+
before do
|
42
|
+
@client = Youroom::DestroyEntry.new(access_token, "room_id", 1111, WW_URL)
|
43
|
+
end
|
44
|
+
|
45
|
+
subject { @client.path }
|
46
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'entries', '1111?format=json') }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#delete" do
|
51
|
+
before do
|
52
|
+
@client = Youroom::DestroyEntry.new(access_token, "room_id", 1111, WW_URL)
|
53
|
+
WW::Server.mock(:youroom).delete("/youroom/r/room_id/entries/1111") do
|
54
|
+
{ :status => "Destroy" }.to_json
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
after do
|
59
|
+
WW::Server.verify(:youroom)
|
60
|
+
end
|
61
|
+
|
62
|
+
subject { @client.delete }
|
63
|
+
it "should call request url" do
|
64
|
+
should be_a_instance_of(Hash)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Youroom::Participation do
|
4
|
+
describe "#initialize" do
|
5
|
+
describe "when can create instance" do
|
6
|
+
subject { Youroom::DestroyParticipation.new(access_token, 3, 4, "pochi.black@gmail.com") }
|
7
|
+
it { should be_a(Youroom::DestroyParticipation) }
|
8
|
+
its(:url) { should == Youroom::BASE_URL }
|
9
|
+
its(:billing_id) { should == '3' }
|
10
|
+
its(:billing_group_id) { should == '4' }
|
11
|
+
its(:email) { should == "pochi.black@gmail.com" }
|
12
|
+
its(:access_token) { should == access_token }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "when can't create instance" do
|
16
|
+
describe "case1: argument size is wrong" do
|
17
|
+
it "should raise ArgumentError" do
|
18
|
+
lambda { Youroom::AddRoom.new(access_token, 100) }.should raise_exception(ArgumentError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "case2: billing_id structure is failed" do
|
23
|
+
it "should raise ArgumentError" do
|
24
|
+
lambda { Youroom::AddRoom.new(access_token, [100], 100, "pochi@gmail.com") }.should raise_exception(ArgumentError)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "case3: billing_group_id structure is failed" do
|
29
|
+
it "should raise ArgumentError" do
|
30
|
+
lambda { Youroom::AddRoom.new(access_token, 100, [100], "pochi@gmail.com") }.should raise_exception(ArgumentError)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "case4: email structure is failed" do
|
35
|
+
it "should raise ArgumentError" do
|
36
|
+
lambda { Youroom::AddRoom.new(access_token, 100, 100, 123) }.should raise_exception(ArgumentError)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#path" do
|
44
|
+
describe "when url is default" do
|
45
|
+
before do
|
46
|
+
@client = Youroom::DestroyParticipation.new(access_token, 3, 4, "pochi@gmail.com")
|
47
|
+
end
|
48
|
+
|
49
|
+
subject { @client.path }
|
50
|
+
it { should == File.join(::Youroom::BASE_URL, 'billings', '3', 'billing_groups', '4', 'participations', 'remove?format=json') }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "when url is customized" do
|
54
|
+
before do
|
55
|
+
@client = Youroom::DestroyParticipation.new(access_token, 3, 4, "pochi@gmail.com", WW_URL)
|
56
|
+
end
|
57
|
+
|
58
|
+
subject { @client.path }
|
59
|
+
it { should == File.join(WW_URL, 'enterprise', 'billings', '3', 'billing_groups', '4', 'participations', 'remove?format=json') }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#params" do
|
64
|
+
before do
|
65
|
+
@client = Youroom::DestroyParticipation.new(access_token, 3, 4, "pochi.black@gmail.com")
|
66
|
+
end
|
67
|
+
|
68
|
+
subject { @client.params }
|
69
|
+
it { should == {'email' => 'pochi.black@gmail.com' } }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#post" do
|
73
|
+
before do
|
74
|
+
@client = Youroom::DestroyParticipation.new(access_token, 3, 4, "pochi@gmail.com", WW_URL)
|
75
|
+
WW::Server.mock(:youroom).post("/youroom/enterprise/billings/3/billing_groups/4/participations/remove") do
|
76
|
+
{ :status => "Deleted" }.to_json
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
WW::Server.verify(:youroom)
|
82
|
+
end
|
83
|
+
|
84
|
+
subject { @client.post }
|
85
|
+
it "should call request url" do
|
86
|
+
should be_a_instance_of(Hash)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Youroom::GetEntry do
|
5
|
+
describe "#initialize" do
|
6
|
+
describe "when mutter_id == nil" do
|
7
|
+
subject { Youroom::GetEntry.new(access_token, "room_id") }
|
8
|
+
it { should be_a(Youroom::GetEntry) }
|
9
|
+
its(:url) { should == Youroom::BASE_URL }
|
10
|
+
its(:room_id) { should == "room_id" }
|
11
|
+
its(:mutter_id) { should == nil }
|
12
|
+
its(:access_token) { should == access_token }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "when mutter_id != nil" do
|
16
|
+
subject { Youroom::GetEntry.new(access_token, "room_id", "mutter_id") }
|
17
|
+
it { should be_a(Youroom::GetEntry) }
|
18
|
+
its(:url) { should == Youroom::BASE_URL }
|
19
|
+
its(:room_id) { should == "room_id" }
|
20
|
+
its(:mutter_id) { should == "mutter_id" }
|
21
|
+
its(:access_token) { should == access_token }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "room_idにFixnumクラスを設定した場合" do
|
25
|
+
subject { Youroom::GetEntry.new(access_token, 1000, "mutter_id") }
|
26
|
+
it "room_idに1000が設定されること" do
|
27
|
+
subject.room_id.should == 1000
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when can't create instance" do
|
32
|
+
describe "case1: mutter_id is not either String or Symbol or Integer" do
|
33
|
+
it "should raise ArgumentError" do
|
34
|
+
lambda { Youroom::GetEntry.new(access_token, "room_id", [2]) }.should raise_exception(ArgumentError)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#path" do
|
41
|
+
describe "when url is original" do
|
42
|
+
describe "when mutter_id == nil" do
|
43
|
+
before do
|
44
|
+
@client = Youroom::GetEntry.new(access_token, "room_id")
|
45
|
+
end
|
46
|
+
|
47
|
+
subject { @client.path }
|
48
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'all?format=json') }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "when mutter_id != nil" do
|
52
|
+
before do
|
53
|
+
@client = Youroom::GetEntry.new(access_token, "room_id", 1111)
|
54
|
+
end
|
55
|
+
|
56
|
+
subject { @client.path }
|
57
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'entries', '1111.json') }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "when url is not original" do
|
62
|
+
describe "when mutter_id == nil" do
|
63
|
+
before do
|
64
|
+
@client = Youroom::GetEntry.new(access_token, "room_id", nil, WW_URL)
|
65
|
+
end
|
66
|
+
|
67
|
+
subject { @client.path }
|
68
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'all?format=json') }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "when mutter_id != nil" do
|
72
|
+
before do
|
73
|
+
@client = Youroom::GetEntry.new(access_token, "room_id", 1111, WW_URL)
|
74
|
+
end
|
75
|
+
|
76
|
+
subject { @client.path }
|
77
|
+
it { should == File.join(@client.url, 'r', 'room_id', 'entries', '1111.json')}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|