youroom_api 0.1.3 → 0.1.4

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.
@@ -77,7 +77,7 @@ module Youroom
77
77
  GetUserList.new(access_token, billing_id, url).get
78
78
  end
79
79
 
80
- def get_picture(room_id, participation_id)
80
+ def get_picture(room_id, participation_id=nil)
81
81
  Picture.new(access_token, room_id, participation_id, url).get(false)
82
82
  end
83
83
 
@@ -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
- [room_id, participation_id].each {|arg| required_structure(arg, String, Integer) }
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
- File.join(url, "r", room_id, "participations", participation_id, "picture.image")
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
@@ -1,4 +1,4 @@
1
1
  module Youroom
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
4
4
 
@@ -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
- @error_data1 = ["hoge", nil]
8
- @error_data2 = [nil, "hoge"]
7
+ @error_data = [nil, "hoge"]
9
8
  end
10
9
 
11
10
  it do
12
- lambda { Youroom::Picture.new(*@error_data1) }.should raise_exception(ArgumentError)
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
- before do
32
- @picture = Youroom::Picture.new(access_token, "room_id", "participation_id", WW_URL)
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
- subject { @picture.path }
36
- it { should == File.join(WW_URL, 'r', 'room_id', 'participations', 'participation_id', 'picture.image') }
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'youroom_api'
3
- s.version = '0.1.3'
3
+ s.version = '0.1.4'
4
4
 
5
5
  s.authors = ['pochi']
6
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - pochi