fleakr 0.6.3 → 0.7.0
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/README.rdoc +88 -57
- data/Rakefile +28 -9
- data/lib/fleakr.rb +25 -31
- data/lib/fleakr/api/option.rb +34 -34
- data/lib/fleakr/api/parameter_list.rb +23 -23
- data/lib/fleakr/objects.rb +4 -1
- data/lib/fleakr/objects/metadata.rb +35 -0
- data/lib/fleakr/objects/metadata_collection.rb +36 -0
- data/lib/fleakr/objects/photo.rb +15 -11
- data/lib/fleakr/objects/set.rb +17 -13
- data/lib/fleakr/objects/url.rb +83 -0
- data/lib/fleakr/objects/user.rb +8 -0
- data/lib/fleakr/support.rb +3 -1
- data/lib/fleakr/support/attribute.rb +2 -2
- data/lib/fleakr/support/object.rb +44 -29
- data/lib/fleakr/support/url_expander.rb +37 -0
- data/lib/fleakr/support/utility.rb +66 -0
- data/lib/fleakr/version.rb +5 -5
- data/test/fixtures/photos.getExif.xml +362 -0
- data/test/test_helper.rb +44 -47
- data/test/unit/fleakr/api/authentication_request_test.rb +12 -12
- data/test/unit/fleakr/api/file_parameter_test.rb +15 -15
- data/test/unit/fleakr/api/method_request_test.rb +1 -1
- data/test/unit/fleakr/api/option_test.rb +44 -44
- data/test/unit/fleakr/api/parameter_list_test.rb +40 -40
- data/test/unit/fleakr/api/response_test.rb +10 -10
- data/test/unit/fleakr/api/upload_request_test.rb +28 -28
- data/test/unit/fleakr/api/value_parameter_test.rb +10 -10
- data/test/unit/fleakr/core_ext/false_class_test.rb +5 -5
- data/test/unit/fleakr/core_ext/hash_test.rb +9 -9
- data/test/unit/fleakr/core_ext/true_class_test.rb +5 -5
- data/test/unit/fleakr/objects/authentication_token_test.rb +23 -23
- data/test/unit/fleakr/objects/collection_test.rb +23 -23
- data/test/unit/fleakr/objects/comment_test.rb +15 -15
- data/test/unit/fleakr/objects/contact_test.rb +11 -11
- data/test/unit/fleakr/objects/error_test.rb +8 -8
- data/test/unit/fleakr/objects/group_test.rb +13 -13
- data/test/unit/fleakr/objects/image_test.rb +4 -4
- data/test/unit/fleakr/objects/metadata_collection_test.rb +55 -0
- data/test/unit/fleakr/objects/metadata_test.rb +27 -0
- data/test/unit/fleakr/objects/photo_context_test.rb +23 -23
- data/test/unit/fleakr/objects/photo_test.rb +71 -64
- data/test/unit/fleakr/objects/search_test.rb +22 -22
- data/test/unit/fleakr/objects/set_test.rb +62 -40
- data/test/unit/fleakr/objects/tag_test.rb +32 -31
- data/test/unit/fleakr/objects/url_test.rb +185 -0
- data/test/unit/fleakr/objects/user_test.rb +43 -16
- data/test/unit/fleakr/support/attribute_test.rb +15 -15
- data/test/unit/fleakr/support/object_test.rb +77 -33
- data/test/unit/fleakr/support/request_test.rb +12 -12
- data/test/unit/fleakr/support/url_expander_test.rb +44 -0
- data/test/unit/fleakr/support/utility_test.rb +70 -0
- data/test/unit/fleakr_test.rb +48 -41
- metadata +43 -23
@@ -1,37 +1,37 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Api
|
4
4
|
class AuthenticationRequestTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
context "An instance of AuthenticationRequest" do
|
7
|
-
|
7
|
+
|
8
8
|
should "know the endpoint URL" do
|
9
9
|
request = AuthenticationRequest.new
|
10
10
|
request.endpoint_url.should == 'http://flickr.com/services/auth/'
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
should "be able to make a request" do
|
14
14
|
endpoint_uri = stub()
|
15
|
-
|
15
|
+
|
16
16
|
request = AuthenticationRequest.new
|
17
17
|
request.stubs(:endpoint_uri).with().returns(endpoint_uri)
|
18
|
-
|
18
|
+
|
19
19
|
Net::HTTP.expects(:get_response).with(endpoint_uri).returns('response')
|
20
|
-
|
20
|
+
|
21
21
|
request.response.should == 'response'
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
should "know the authorization_url for the authentication request" do
|
25
25
|
response_headers = {'Location' => 'http://example.com/auth'}
|
26
26
|
response = stub() {|r| r.stubs(:header).with().returns(response_headers) }
|
27
|
-
|
27
|
+
|
28
28
|
request = AuthenticationRequest.new
|
29
29
|
request.stubs(:response).with().returns(response)
|
30
|
-
|
30
|
+
|
31
31
|
request.authorization_url.should == 'http://example.com/auth'
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
end
|
37
37
|
end
|
@@ -1,40 +1,40 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Api
|
4
4
|
class FileParameterTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
context "An instance of the FileParameter class" do
|
7
|
-
|
7
|
+
|
8
8
|
setup do
|
9
9
|
@temp_dir = File.expand_path(create_temp_directory)
|
10
10
|
@filename = "#{@temp_dir}/image.jpg"
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
teardown do
|
14
14
|
FileUtils.rm_rf(@temp_dir)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
{'jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'}.each do |ext, mime_type|
|
18
18
|
should "know the correct MIME type for an extension of #{ext}" do
|
19
19
|
parameter = FileParameter.new('photo', "#{@temp_dir}/image.#{ext}")
|
20
20
|
parameter.mime_type.should == mime_type
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
should "retrieve the contents of the file when accessing the value" do
|
25
25
|
File.expects(:read).with(@filename).returns('bopbip')
|
26
|
-
|
26
|
+
|
27
27
|
parameter = FileParameter.new('photo', @filename)
|
28
28
|
parameter.value.should == 'bopbip'
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
should "cache the file contents after retrieving them" do
|
32
32
|
File.expects(:read).with(@filename).once.returns('bopbip')
|
33
|
-
|
33
|
+
|
34
34
|
parameter = FileParameter.new('photo', @filename)
|
35
35
|
2.times { parameter.value }
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
should "know how to generate a form representation of itself" do
|
39
39
|
filename = 'image.jpg'
|
40
40
|
mime_type = 'image/jpeg'
|
@@ -42,17 +42,17 @@ module Fleakr::Api
|
|
42
42
|
parameter = FileParameter.new('photo', filename)
|
43
43
|
parameter.stubs(:mime_type).with().returns(mime_type)
|
44
44
|
parameter.stubs(:value).with().returns('data')
|
45
|
-
|
46
|
-
expected =
|
45
|
+
|
46
|
+
expected =
|
47
47
|
"Content-Disposition: form-data; name=\"photo\"; filename=\"#{filename}\"\r\n" +
|
48
48
|
"Content-Type: image/jpeg\r\n" +
|
49
49
|
"\r\n" +
|
50
50
|
"data\r\n"
|
51
|
-
|
51
|
+
|
52
52
|
parameter.to_form.should == expected
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
end
|
58
58
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Api
|
4
|
-
|
4
|
+
|
5
5
|
class OptionTest < Test::Unit::TestCase
|
6
|
-
|
6
|
+
|
7
7
|
def self.should_know_the_class_for(type, options)
|
8
8
|
should "know the class for the :#{type} type" do
|
9
9
|
Option.class_for(type).should == options[:is]
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
context "The Option class" do
|
14
14
|
should_know_the_class_for :title, :is => Fleakr::Api::SimpleOption
|
15
15
|
should_know_the_class_for :description, :is => Fleakr::Api::SimpleOption
|
@@ -18,64 +18,64 @@ module Fleakr::Api
|
|
18
18
|
should_know_the_class_for :level, :is => Fleakr::Api::LevelOption
|
19
19
|
should_know_the_class_for :type, :is => Fleakr::Api::TypeOption
|
20
20
|
should_know_the_class_for :hide?, :is => Fleakr::Api::HiddenOption
|
21
|
-
|
21
|
+
|
22
22
|
should "be able to create an option for a type" do
|
23
23
|
option = stub()
|
24
|
-
|
24
|
+
|
25
25
|
Option.expects(:class_for).with(:title).returns(Fleakr::Api::SimpleOption)
|
26
26
|
Fleakr::Api::SimpleOption.expects(:new).with(:title, 'blip').returns(option)
|
27
|
-
|
27
|
+
|
28
28
|
Option.for(:title, 'blip').should == option
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
class SimpleOptionTest < Test::Unit::TestCase
|
35
|
-
|
35
|
+
|
36
36
|
context "An instance of the SimpleOption class" do
|
37
37
|
should "have a type" do
|
38
38
|
so = SimpleOption.new(:title, 'blip')
|
39
39
|
so.type.should == :title
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
should "have a value" do
|
43
43
|
so = SimpleOption.new(:title, 'blip')
|
44
44
|
so.value.should == 'blip'
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
should "be able to generate a hash representation of itself" do
|
48
48
|
so = SimpleOption.new(:title, 'blip')
|
49
49
|
so.to_hash.should == {:title => 'blip'}
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
end
|
54
54
|
|
55
55
|
class TagOptionTest < Test::Unit::TestCase
|
56
|
-
|
56
|
+
|
57
57
|
context "An instance of the TagOption class" do
|
58
|
-
|
58
|
+
|
59
59
|
should "normalize the input value to an array" do
|
60
60
|
to = TagOption.new(:tags, 'blip')
|
61
61
|
to.value.should == ['blip']
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
should "be able to generate a hash representation of itself with tags joined on spaces" do
|
65
65
|
to = TagOption.new(:tags, %w(bop bip))
|
66
66
|
to.to_hash.should == {:tags => '"bop" "bip"'}
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
should "quote tag values with spaces" do
|
70
70
|
to = TagOption.new(:tags, ['tag', 'one with spaces'])
|
71
71
|
to.to_hash.should == {:tags => '"tag" "one with spaces"'}
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
class ViewOptionTest < Test::Unit::TestCase
|
78
|
-
|
78
|
+
|
79
79
|
context "An instance of the ViewOption class" do
|
80
80
|
should "be able to generate a hash representation for viewing by :everyone" do
|
81
81
|
vo = ViewOption.new(:viewable_by, :everyone)
|
@@ -86,94 +86,94 @@ module Fleakr::Api
|
|
86
86
|
vo = ViewOption.new(:viewable_by, :family)
|
87
87
|
vo.to_hash.should == {:is_public => 0, :is_family => 1, :is_friend => 0}
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
should "be able to generate a hash representation for viewing by :friends" do
|
91
91
|
vo = ViewOption.new(:viewable_by, :friends)
|
92
92
|
vo.to_hash.should == {:is_public => 0, :is_family => 0, :is_friend => 1}
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
should "know the visibility is public if value is set to :everyone" do
|
96
96
|
vo = ViewOption.new(:viewable_by, :everyone)
|
97
97
|
vo.public?.should be(true)
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
should "know the visibility is not public if :everyone is not the only value" do
|
101
101
|
vo = ViewOption.new(:viewable_by, [:everyone, :family])
|
102
102
|
vo.public?.should be(false)
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
should "know that its visible to friends and family if specified as such" do
|
106
106
|
vo = ViewOption.new(:viewable_by, [:friends, :family])
|
107
107
|
vo.friends?.should be(true)
|
108
108
|
vo.family?.should be(true)
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
end
|
114
114
|
|
115
115
|
class LevelOptionTest < Test::Unit::TestCase
|
116
|
-
|
116
|
+
|
117
117
|
context "An instance of the LevelOption class" do
|
118
|
-
|
118
|
+
|
119
119
|
should "be able to generate a hash representation for the :safe level" do
|
120
120
|
lo = LevelOption.new(:level, :safe)
|
121
121
|
lo.to_hash.should == {:safety_level => 1}
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
should "be able to generate a hash representation for the :moderate level" do
|
125
125
|
lo = LevelOption.new(:level, :moderate)
|
126
126
|
lo.to_hash.should == {:safety_level => 2}
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
should "be able to generate a hash representation for the :restricted level" do
|
130
130
|
lo = LevelOption.new(:level, :restricted)
|
131
131
|
lo.to_hash.should == {:safety_level => 3}
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
end
|
137
137
|
|
138
138
|
class TypeOptionTest < Test::Unit::TestCase
|
139
|
-
|
139
|
+
|
140
140
|
context "An instance of the TypeOption class" do
|
141
|
-
|
141
|
+
|
142
142
|
should "be able to generate a hash representation for the :photo type" do
|
143
143
|
to = TypeOption.new(:type, :photo)
|
144
144
|
to.to_hash.should == {:content_type => 1}
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
should "be able to generate a hash representation for the :screenshot type" do
|
148
148
|
to = TypeOption.new(:type, :screenshot)
|
149
149
|
to.to_hash.should == {:content_type => 2}
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
should "be able to generate a hash representation for the :other type" do
|
153
153
|
to = TypeOption.new(:type, :other)
|
154
154
|
to.to_hash.should == {:content_type => 3}
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
class HiddenOptionTest < Test::Unit::TestCase
|
162
|
-
|
162
|
+
|
163
163
|
context "An instance of the HiddenOption class" do
|
164
|
-
|
164
|
+
|
165
165
|
should "be able to generate a hash representation when set to true" do
|
166
166
|
ho = HiddenOption.new(:hide?, true)
|
167
167
|
ho.to_hash.should == {:hidden => 2}
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
should "be able to generate a hash representation when set to false" do
|
171
171
|
ho = HiddenOption.new(:hide?, false)
|
172
172
|
ho.to_hash.should == {:hidden => 1}
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
end
|
178
178
|
|
179
179
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Api
|
4
4
|
class ParameterListTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
context "An instance of the ParameterList class with an available API key" do
|
7
7
|
setup do
|
8
8
|
@api_key_value = 'api_key_value'
|
9
9
|
Fleakr.stubs(:api_key).with().returns(@api_key_value)
|
10
|
-
|
10
|
+
|
11
11
|
@parameter_list = ParameterList.new
|
12
12
|
end
|
13
13
|
|
@@ -15,146 +15,146 @@ module Fleakr::Api
|
|
15
15
|
@parameter_list.stubs(:authentication_token).with().returns('toke')
|
16
16
|
@parameter_list.send_authentication_token?.should be(true)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
should "know not to send the authentication token" do
|
20
20
|
pl = ParameterList.new({}, false)
|
21
21
|
pl.stubs(:authentication_token).with().returns('toke')
|
22
|
-
|
22
|
+
|
23
23
|
pl.send_authentication_token?.should be(false)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
should "know not to send the authentication token if it's not available from the global value" do
|
27
27
|
@parameter_list.stubs(:authentication_token).with().returns(nil)
|
28
28
|
@parameter_list.send_authentication_token?.should be(false)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
should "have a default list of options" do
|
32
32
|
@parameter_list.default_options.should == {:api_key => @api_key_value}
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
should "use the authentication_token in the options if we're to authenticate" do
|
36
36
|
@parameter_list.stubs(:send_authentication_token?).with().returns(true)
|
37
37
|
@parameter_list.stubs(:authentication_token).with().returns('toke')
|
38
38
|
@parameter_list.stubs(:default_options).with().returns({})
|
39
|
-
|
39
|
+
|
40
40
|
@parameter_list.options.should == {:auth_token => 'toke'}
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
should "add additional options from the constructor" do
|
44
44
|
pl = ParameterList.new(:foo => 'bar')
|
45
45
|
pl.options.should == {:foo => 'bar', :api_key => @api_key_value}
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
should "know that it doesn't need to sign the request by default" do
|
49
49
|
@parameter_list.sign?.should be(false)
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
should "know that it needs to sign the request when a shared secret is available" do
|
53
53
|
Fleakr.expects(:shared_secret).with().returns('secrit')
|
54
54
|
@parameter_list.sign?.should be(true)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
should "be able to add an option to the list" do
|
58
58
|
@parameter_list.stubs(:default_options).with().returns({})
|
59
|
-
|
59
|
+
|
60
60
|
@parameter_list.add_option(:foo, 'bar')
|
61
61
|
@parameter_list.options.should == {:foo => 'bar'}
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
should "have an empty list of upload options by default" do
|
65
65
|
@parameter_list.upload_options.should == {}
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
should "be able to add an upload option to the list" do
|
69
69
|
@parameter_list.add_upload_option(:file, '/path/to/foo')
|
70
70
|
@parameter_list.upload_options.should == {:file => '/path/to/foo'}
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
should "be able to generate the list of parameters without a signature" do
|
74
74
|
@parameter_list.stubs(:options).with().returns({:foo => 'bar', :api_sig => '1234'})
|
75
75
|
@parameter_list.options_without_signature.should == {:foo => 'bar'}
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
should "be able to calculate the signature of the parameters" do
|
79
79
|
Fleakr.stubs(:shared_secret).with().returns('sekrit')
|
80
|
-
|
80
|
+
|
81
81
|
options = {:api_key => @api_key_value, :foo => 'bar', :blip => 'zeeez'}
|
82
82
|
@parameter_list.stubs(:options_without_signature).with().returns(options)
|
83
83
|
|
84
84
|
@parameter_list.signature.should == Digest::MD5.hexdigest("sekritapi_key#{@api_key_value}blipzeeezfoobar")
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
should "be able to generate a list of options with a signature" do
|
88
88
|
parameters = [ValueParameter.new('foo', 'bar')]
|
89
|
-
|
89
|
+
|
90
90
|
@parameter_list.stubs(:options_without_signature).with().returns(:foo => 'bar')
|
91
91
|
@parameter_list.stubs(:signature).with().returns('sig')
|
92
|
-
|
92
|
+
|
93
93
|
@parameter_list.options_with_signature.should == {:foo => 'bar', :api_sig => 'sig'}
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
should "know the auth token when provided to the constructor" do
|
97
97
|
pl = ParameterList.new(:auth_token => 'toke')
|
98
98
|
pl.authentication_token.should == 'toke'
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
should "know the auth token when available as a global value" do
|
102
102
|
Fleakr.stubs(:auth_token).with().returns('toke')
|
103
|
-
|
103
|
+
|
104
104
|
pl = ParameterList.new
|
105
105
|
pl.authentication_token.should == 'toke'
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
should "know that there is no authentication token if it is not available as a param or global value" do
|
109
109
|
Fleakr.stubs(:auth_token).with().returns(nil)
|
110
|
-
|
110
|
+
|
111
111
|
pl = ParameterList.new
|
112
112
|
pl.authentication_token.should be_nil
|
113
113
|
end
|
114
114
|
|
115
115
|
should "be able to generate a boundary for post data" do
|
116
116
|
rand = '0.123'
|
117
|
-
|
117
|
+
|
118
118
|
@parameter_list.stubs(:rand).with().returns(stub(:to_s => rand))
|
119
119
|
@parameter_list.boundary.should == Digest::MD5.hexdigest(rand)
|
120
120
|
end
|
121
121
|
|
122
122
|
should "be able to generate a list of parameters without a signature" do
|
123
123
|
parameter = stub()
|
124
|
-
|
124
|
+
|
125
125
|
@parameter_list.stubs(:sign?).with().returns(false)
|
126
126
|
@parameter_list.expects(:options_without_signature).with().returns(:foo => 'bar')
|
127
127
|
|
128
128
|
ValueParameter.expects(:new).with(:foo, 'bar').returns(parameter)
|
129
|
-
|
129
|
+
|
130
130
|
@parameter_list.list.should == [parameter]
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
should "be able to generate a list of parameters with a signature" do
|
134
134
|
parameter = stub()
|
135
|
-
|
135
|
+
|
136
136
|
@parameter_list.stubs(:sign?).with().returns(true)
|
137
137
|
@parameter_list.expects(:options_with_signature).with().returns(:foo => 'bar')
|
138
138
|
|
139
139
|
ValueParameter.expects(:new).with(:foo, 'bar').returns(parameter)
|
140
|
-
|
140
|
+
|
141
141
|
@parameter_list.list.should == [parameter]
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
should "be able to generate a list of parameters with upload parameters if available" do
|
145
145
|
value_parameter = stub()
|
146
146
|
file_parameter = stub()
|
147
|
-
|
147
|
+
|
148
148
|
@parameter_list.stubs(:sign?).with().returns(true)
|
149
149
|
@parameter_list.expects(:options_with_signature).with().returns(:foo => 'bar')
|
150
150
|
@parameter_list.expects(:upload_options).with().returns(:file => 'path')
|
151
|
-
|
151
|
+
|
152
152
|
ValueParameter.expects(:new).with(:foo, 'bar').returns(value_parameter)
|
153
153
|
FileParameter.expects(:new).with(:file, 'path').returns(file_parameter)
|
154
|
-
|
154
|
+
|
155
155
|
@parameter_list.list.should == [value_parameter, file_parameter]
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
context "with associated parameters" do
|
159
159
|
|
160
160
|
setup do
|
@@ -177,7 +177,7 @@ module Fleakr::Api
|
|
177
177
|
should "be able to represent a form representation of itself" do
|
178
178
|
@parameter_list.stubs(:boundary).returns('bound')
|
179
179
|
|
180
|
-
expected =
|
180
|
+
expected =
|
181
181
|
"--bound\r\n" +
|
182
182
|
"f1" +
|
183
183
|
"--bound\r\n" +
|
@@ -190,6 +190,6 @@ module Fleakr::Api
|
|
190
190
|
end
|
191
191
|
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
end
|
195
195
|
end
|