youroom_api 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
data/lib/youroom_api/request.rb
CHANGED
@@ -2,14 +2,18 @@ module Youroom
|
|
2
2
|
class Picture < Request
|
3
3
|
attr_reader :room_id, :participation_id
|
4
4
|
|
5
|
-
def initialize(access_token, room_id, participation_id, url=BASE_URL)
|
6
|
-
|
5
|
+
def initialize(access_token, room_id, participation_id=nil, url=BASE_URL)
|
6
|
+
required_structure(room_id, String, Integer)
|
7
7
|
@room_id, @participation_id = room_id, participation_id
|
8
8
|
super(access_token, url)
|
9
9
|
end
|
10
10
|
|
11
11
|
def path
|
12
|
-
|
12
|
+
if participation_id
|
13
|
+
File.join(url, "r", room_id, "participations", participation_id, "picture.image")
|
14
|
+
else
|
15
|
+
File.join(url, "r", room_id, "picture.image")
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/lib/youroom_api/version.rb
CHANGED
@@ -4,18 +4,12 @@ describe Youroom::Picture do
|
|
4
4
|
describe "#initialize" do
|
5
5
|
context "when can not create instanse" do
|
6
6
|
before do
|
7
|
-
@
|
8
|
-
@error_data2 = [nil, "hoge"]
|
7
|
+
@error_data = [nil, "hoge"]
|
9
8
|
end
|
10
9
|
|
11
10
|
it do
|
12
|
-
lambda { Youroom::Picture.new(*@
|
11
|
+
lambda { Youroom::Picture.new(*@error_data) }.should raise_exception(ArgumentError)
|
13
12
|
end
|
14
|
-
|
15
|
-
it do
|
16
|
-
lambda { Youroom::Picture.new(*@error_data2) }.should raise_exception(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
13
|
end
|
20
14
|
|
21
15
|
context "when can create user instance" do
|
@@ -25,14 +19,33 @@ describe Youroom::Picture do
|
|
25
19
|
its(:room_id) { should == "room_id" }
|
26
20
|
its(:participation_id) { should == "participation_id" }
|
27
21
|
end
|
22
|
+
|
23
|
+
context "when participation_id is nil" do
|
24
|
+
subject { Youroom::Picture.new(access_token, "room_id") }
|
25
|
+
it { should be_a(Youroom::Picture) }
|
26
|
+
its(:url) { should == Youroom::BASE_URL }
|
27
|
+
its(:room_id) { should == "room_id" }
|
28
|
+
its(:participation_id) { should == nil }
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
describe "#path" do
|
31
|
-
|
32
|
-
|
33
|
+
context "when instance has participation_id" do
|
34
|
+
before do
|
35
|
+
@picture = Youroom::Picture.new(access_token, "room_id", "participation_id", WW_URL)
|
36
|
+
end
|
37
|
+
|
38
|
+
subject { @picture.path }
|
39
|
+
it { should == File.join(WW_URL, 'r', 'room_id', 'participations', 'participation_id', 'picture.image') }
|
33
40
|
end
|
34
41
|
|
35
|
-
|
36
|
-
|
42
|
+
context "when instance has not participation_id" do
|
43
|
+
before do
|
44
|
+
@picture = Youroom::Picture.new(access_token, "room_id", nil, WW_URL)
|
45
|
+
end
|
46
|
+
|
47
|
+
subject { @picture.path }
|
48
|
+
it { should == File.join(WW_URL, 'r', 'room_id', 'picture.image') }
|
49
|
+
end
|
37
50
|
end
|
38
51
|
end
|
data/youroom_api.gemspec
CHANGED