fleakr 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -1
- data/Rakefile +1 -1
- data/lib/fleakr.rb +2 -1
- data/lib/fleakr/api/option.rb +6 -6
- data/lib/fleakr/version.rb +2 -2
- data/test/test_helper.rb +9 -8
- data/test/unit/fleakr/api/file_parameter_test.rb +8 -8
- data/test/unit/fleakr/api/method_request_test.rb +11 -10
- data/test/unit/fleakr/api/option_test.rb +29 -29
- data/test/unit/fleakr/api/parameter_list_test.rb +22 -22
- data/test/unit/fleakr/api/parameter_test.rb +5 -5
- data/test/unit/fleakr/api/response_test.rb +6 -6
- data/test/unit/fleakr/api/upload_request_test.rb +28 -24
- data/test/unit/fleakr/api/value_parameter_test.rb +6 -6
- data/test/unit/fleakr/core_ext/false_class_test.rb +2 -2
- data/test/unit/fleakr/core_ext/hash_test.rb +6 -6
- data/test/unit/fleakr/core_ext/true_class_test.rb +2 -2
- data/test/unit/fleakr/objects/authentication_token_test.rb +6 -6
- data/test/unit/fleakr/objects/comment_test.rb +8 -8
- data/test/unit/fleakr/objects/contact_test.rb +8 -5
- data/test/unit/fleakr/objects/error_test.rb +2 -2
- data/test/unit/fleakr/objects/group_test.rb +5 -5
- data/test/unit/fleakr/objects/image_test.rb +6 -6
- data/test/unit/fleakr/objects/photo_context_test.rb +11 -11
- data/test/unit/fleakr/objects/photo_test.rb +32 -29
- data/test/unit/fleakr/objects/search_test.rb +9 -9
- data/test/unit/fleakr/objects/set_test.rb +9 -9
- data/test/unit/fleakr/objects/tag_test.rb +12 -12
- data/test/unit/fleakr/objects/user_test.rb +10 -10
- data/test/unit/fleakr/support/attribute_test.rb +21 -21
- data/test/unit/fleakr/support/object_test.rb +17 -17
- data/test/unit/fleakr_test.rb +24 -24
- metadata +3 -3
@@ -3,18 +3,18 @@ require File.dirname(__FILE__) + '/../../../test_helper'
|
|
3
3
|
module Fleakr::Objects
|
4
4
|
class TagTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
|
6
|
+
context "The Tag class" do
|
7
7
|
|
8
8
|
should_find_all :tags, :by => :photo_id, :call => 'tags.getListPhoto', :path => 'rsp/photo/tags/tag'
|
9
9
|
should_find_all :tags, :by => :user_id, :call => 'tags.getListUser', :path => 'rsp/who/tags/tag'
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
context "An instance of the Tag class" do
|
13
13
|
|
14
|
-
|
14
|
+
setup { @tag = Tag.new }
|
15
15
|
|
16
16
|
context "when populating from the tags_getListPhoto XML data" do
|
17
|
-
|
17
|
+
setup do
|
18
18
|
@object = Tag.new(Hpricot.XML(read_fixture('tags.getListPhoto')).at('rsp/photo/tags/tag'))
|
19
19
|
end
|
20
20
|
|
@@ -26,7 +26,7 @@ module Fleakr::Objects
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
should "have an author" do
|
30
30
|
user = stub()
|
31
31
|
|
32
32
|
@tag.expects(:author_id).at_least_once.with().returns('1')
|
@@ -37,7 +37,7 @@ module Fleakr::Objects
|
|
37
37
|
@tag.author.should == user
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
should "memoize the author data" do
|
41
41
|
@tag.expects(:author_id).at_least_once.with().returns('1')
|
42
42
|
|
43
43
|
User.expects(:find_by_id).with('1').once.returns(stub())
|
@@ -45,13 +45,13 @@ module Fleakr::Objects
|
|
45
45
|
2.times { @tag.author }
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
should "return nil for author if author_id is not present" do
|
49
49
|
@tag.expects(:author_id).with().returns(nil)
|
50
50
|
|
51
51
|
@tag.author.should be(nil)
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
should "have related tags" do
|
55
55
|
@tag.expects(:value).with().returns('foo')
|
56
56
|
|
57
57
|
response = mock_request_cycle :for => 'tags.getRelated', :with => {:tag => 'foo'}
|
@@ -69,7 +69,7 @@ module Fleakr::Objects
|
|
69
69
|
@tag.related.should == stubs
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
should "memoize the data for related tags" do
|
73
73
|
@tag.expects(:value).with().returns('foo')
|
74
74
|
|
75
75
|
mock_request_cycle :for => 'tags.getRelated', :with => {:tag => 'foo'}
|
@@ -77,17 +77,17 @@ module Fleakr::Objects
|
|
77
77
|
2.times { @tag.related }
|
78
78
|
end
|
79
79
|
|
80
|
-
|
80
|
+
should "be able to generate a string representation of itself" do
|
81
81
|
@tag.expects(:value).with().returns('foo')
|
82
82
|
@tag.to_s.should == 'foo'
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
should "know that it is not a machine tag" do
|
86
86
|
@tag.expects(:machine_flag).with().returns('0')
|
87
87
|
@tag.machine?.should be(false)
|
88
88
|
end
|
89
89
|
|
90
|
-
|
90
|
+
should "know that it is a machine tag" do
|
91
91
|
@tag.expects(:machine_flag).with().returns('1')
|
92
92
|
@tag.machine?.should be(true)
|
93
93
|
end
|
@@ -10,7 +10,7 @@ module Fleakr::Objects
|
|
10
10
|
should_autoload_when_accessing :name, :photos_url, :profile_url, :photos_count, :location, :with => :load_info
|
11
11
|
should_autoload_when_accessing :icon_server, :icon_farm, :pro, :admin, :icon_url, :with => :load_info
|
12
12
|
|
13
|
-
|
13
|
+
context "The User class" do
|
14
14
|
|
15
15
|
should_find_one :user, :by => :username, :call => 'people.findByUsername', :path => 'rsp/user'
|
16
16
|
should_find_one :user, :by => :email, :with => :find_email, :call => 'people.findByEmail', :path => 'rsp/user'
|
@@ -18,9 +18,9 @@ module Fleakr::Objects
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
context "An instance of User" do
|
22
22
|
context "when populating the object from an XML document" do
|
23
|
-
|
23
|
+
setup do
|
24
24
|
@object = User.new(Hpricot.XML(read_fixture('people.findByUsername')))
|
25
25
|
@object.populate_from(Hpricot.XML(read_fixture('people.getInfo')))
|
26
26
|
end
|
@@ -41,16 +41,16 @@ module Fleakr::Objects
|
|
41
41
|
|
42
42
|
context "in general" do
|
43
43
|
|
44
|
-
|
44
|
+
setup { @user = User.new }
|
45
45
|
|
46
|
-
|
46
|
+
should "be able to retrieve additional information about the current user" do
|
47
47
|
response = mock_request_cycle :for => 'people.getInfo', :with => {:user_id => @user.id}
|
48
48
|
@user.expects(:populate_from).with(response.body)
|
49
49
|
|
50
50
|
@user.load_info
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
should "be able to generate an icon URL when the :icon_server value is greater than zero" do
|
54
54
|
@user.stubs(:icon_server).with().returns('1')
|
55
55
|
@user.stubs(:icon_farm).with().returns('2')
|
56
56
|
@user.stubs(:id).with().returns('45')
|
@@ -58,17 +58,17 @@ module Fleakr::Objects
|
|
58
58
|
@user.icon_url.should == 'http://farm2.static.flickr.com/1/buddyicons/45.jpg'
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
should "return the default icon URL when the :icon_server value is zero" do
|
62
62
|
@user.stubs(:icon_server).with().returns('0')
|
63
63
|
@user.icon_url.should == 'http://www.flickr.com/images/buddyicon.jpg'
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
should "return the default icon URL when the :icon_server value is nil" do
|
67
67
|
@user.stubs(:icon_server).with().returns(nil)
|
68
68
|
@user.icon_url.should == 'http://www.flickr.com/images/buddyicon.jpg'
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
should "return a boolean value for :pro?" do
|
72
72
|
@user.stubs(:pro).with().returns('0')
|
73
73
|
@user.pro?.should be(false)
|
74
74
|
|
@@ -76,7 +76,7 @@ module Fleakr::Objects
|
|
76
76
|
@user.pro?.should be(true)
|
77
77
|
end
|
78
78
|
|
79
|
-
|
79
|
+
should "return a boolean value for :admin?" do
|
80
80
|
@user.stubs(:admin).with().returns('0')
|
81
81
|
@user.admin?.should be(false)
|
82
82
|
|
@@ -2,59 +2,59 @@ require File.dirname(__FILE__) + '/../../../test_helper'
|
|
2
2
|
|
3
3
|
module Fleakr::Support
|
4
4
|
class AttributeTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
context "An instance of the Attribute class" do
|
6
6
|
|
7
|
-
|
7
|
+
should "know the name of the attribute" do
|
8
8
|
attr = Attribute.new('foo')
|
9
9
|
attr.name.should == :foo
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
should "have a default source" do
|
13
13
|
attr = Attribute.new(:foo)
|
14
14
|
attr.sources.should == ['foo']
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
should "be able to assign multiple sources" do
|
18
18
|
attr = Attribute.new(:foo, ['foo1', 'foo2'])
|
19
19
|
attr.sources.should == ['foo1', 'foo2']
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
should "pull the location from the source" do
|
23
23
|
attr = Attribute.new('foo')
|
24
24
|
attr.location('foo').should == 'foo'
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
should "return the location when splitting" do
|
28
28
|
attr = Attribute.new('foo')
|
29
29
|
attr.split('foo').should == ['foo', nil]
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
should "return the name for the location when splitting if the location isn't specified" do
|
33
33
|
attr = Attribute.new('foo')
|
34
34
|
attr.split('@bar').should == ['foo', 'bar']
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
should "allow the setting of the location information" do
|
38
38
|
attr = Attribute.new('foo', 'bar')
|
39
39
|
attr.sources.should == ['bar']
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
should "allow the setting of the attribute value" do
|
43
43
|
attr = Attribute.new('foo')
|
44
44
|
attr.attribute('@bogon').should == 'bogon'
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
should "use the location as the attribute" do
|
48
48
|
attr = Attribute.new('foo')
|
49
49
|
attr.attribute('foo').should == 'foo'
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
should "use the attribute for the attribute if specified" do
|
53
53
|
attr = Attribute.new(:id, '@nsid')
|
54
54
|
attr.attribute('@nsid').should == 'nsid'
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
should "be able to retrieve the node from the path" do
|
58
58
|
document = Hpricot.XML('<name>Bassdrive</name>')
|
59
59
|
expected = document.at('name')
|
60
60
|
|
@@ -62,7 +62,7 @@ module Fleakr::Support
|
|
62
62
|
attr.node_for(document, 'name').should == expected
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
should "be able to retrieve the node that contains the specified attribute" do
|
66
66
|
document = Hpricot.XML('<user id="1337" />')
|
67
67
|
expected = document.at('user')
|
68
68
|
|
@@ -70,7 +70,7 @@ module Fleakr::Support
|
|
70
70
|
attr.node_for(document, '@id').should == expected
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
should "be able to retrieve the node for the specified attribute" do
|
74
74
|
document = Hpricot.XML('<user nsid="1337" />')
|
75
75
|
expected = document.at('user')
|
76
76
|
|
@@ -78,43 +78,43 @@ module Fleakr::Support
|
|
78
78
|
attr.node_for(document, '@nsid').should == expected
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
should "be able to pull simple values from an XML document" do
|
82
82
|
document = Hpricot.XML('<name>Bassdrive</name>')
|
83
83
|
attr = Attribute.new(:name)
|
84
84
|
attr.value_from(document).should == 'Bassdrive'
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
should "be able to pull an attribute value from the current XML node" do
|
88
88
|
document = Hpricot.XML('<user id="1337" />')
|
89
89
|
attr = Attribute.new(:id)
|
90
90
|
attr.value_from(document).should == '1337'
|
91
91
|
end
|
92
92
|
|
93
|
-
|
93
|
+
should "be able to pull a specific attribute value from the current XML node" do
|
94
94
|
document = Hpricot.XML('<user nsid="1337" />')
|
95
95
|
attr = Attribute.new(:id, '@nsid')
|
96
96
|
attr.value_from(document).should == '1337'
|
97
97
|
end
|
98
98
|
|
99
|
-
|
99
|
+
should "be able to pull an attribute value for a node and attribute" do
|
100
100
|
document = Hpricot.XML('<station><genre slug="dnb">Drum & Bass</genre></station>')
|
101
101
|
attr = Attribute.new(:slug, 'station/genre@slug')
|
102
102
|
attr.value_from(document).should == 'dnb'
|
103
103
|
end
|
104
104
|
|
105
|
-
|
105
|
+
should "be able to pull a value from a nested XML node" do
|
106
106
|
document = Hpricot.XML('<rsp><user>blip</user></rsp>')
|
107
107
|
attr = Attribute.new(:user)
|
108
108
|
attr.value_from(document).should == 'blip'
|
109
109
|
end
|
110
110
|
|
111
|
-
|
111
|
+
should "return nil if it cannot find the specified node" do
|
112
112
|
document = Hpricot.XML('<user id="1" />')
|
113
113
|
attr = Attribute.new(:photoset, '@nsid')
|
114
114
|
attr.value_from(document).should be(nil)
|
115
115
|
end
|
116
116
|
|
117
|
-
|
117
|
+
should "be able to try a series of nodes to find a value" do
|
118
118
|
document = Hpricot.XML('<photoid>123</photoid>')
|
119
119
|
|
120
120
|
attr = Attribute.new(:id, ['photo@nsid', 'photoid'])
|
@@ -21,17 +21,17 @@ end
|
|
21
21
|
module Fleakr
|
22
22
|
class ObjectTest < Test::Unit::TestCase
|
23
23
|
|
24
|
-
|
24
|
+
context "A class method provided by the Flickr::Object module" do
|
25
25
|
|
26
|
-
|
26
|
+
should "have an empty list of attributes if none are supplied" do
|
27
27
|
EmptyObject.attributes.should == []
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
should "know the names of all its attributes" do
|
31
31
|
FlickrObject.attributes.map {|a| a.name.to_s }.should == %w(name description id photoset_id tag category)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
should "be able to find by ID" do
|
35
35
|
id = 1
|
36
36
|
flickr_object = stub()
|
37
37
|
|
@@ -41,7 +41,7 @@ module Fleakr
|
|
41
41
|
FlickrObject.find_by_id(id).should == flickr_object
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
should "be able to pass parameters to the :find_by_id method" do
|
45
45
|
id = 1
|
46
46
|
params = {:authenticate? => true}
|
47
47
|
flickr_object = stub()
|
@@ -54,16 +54,16 @@ module Fleakr
|
|
54
54
|
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
context "An instance method provided by the Flickr::Object module" do
|
58
58
|
|
59
|
-
|
59
|
+
should "have default reader methods" do
|
60
60
|
[:name, :description, :id, :photoset_id, :tag, :category].each do |method_name|
|
61
61
|
FlickrObject.new.respond_to?(method_name).should == true
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
context "when populating data from an XML document" do
|
66
|
-
|
66
|
+
setup do
|
67
67
|
xml = <<-XML
|
68
68
|
<name>Fleakr</name>
|
69
69
|
<desc>Awesome</desc>
|
@@ -76,47 +76,47 @@ module Fleakr
|
|
76
76
|
@object.populate_from(Hpricot.XML(xml))
|
77
77
|
end
|
78
78
|
|
79
|
-
|
79
|
+
should "have the correct value for :name" do
|
80
80
|
@object.name.should == 'Fleakr'
|
81
81
|
end
|
82
82
|
|
83
|
-
|
83
|
+
should "have the correct value for :description" do
|
84
84
|
@object.description.should == 'Awesome'
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
should "have the correct value for :photoset_id" do
|
88
88
|
@object.photoset_id.should == '1'
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
should "have the correct value for :id" do
|
92
92
|
document = Hpricot.XML('<object nsid="1" />').at('object')
|
93
93
|
@object.populate_from(document)
|
94
94
|
|
95
95
|
@object.id.should == '1'
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
should "have the correct value for :tag" do
|
99
99
|
@object.tag.should == 'Tag'
|
100
100
|
end
|
101
101
|
|
102
|
-
|
102
|
+
should "have the correct value for :category" do
|
103
103
|
@object.category.should == 'Category'
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
|
107
|
+
should "populate its data from an XML document when initializing" do
|
108
108
|
document = stub()
|
109
109
|
FlickrObject.any_instance.expects(:populate_from).with(document)
|
110
110
|
|
111
111
|
FlickrObject.new(document)
|
112
112
|
end
|
113
113
|
|
114
|
-
|
114
|
+
should "not attempt to populate itself from an XML document if one is not available" do
|
115
115
|
FlickrObject.any_instance.expects(:populate_from).never
|
116
116
|
FlickrObject.new
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
should "not overwrite existing attributes when pulling in a partial new XML document" do
|
120
120
|
object = FlickrObject.new(Hpricot.XML('<name>Fleakr</name>'))
|
121
121
|
object.populate_from(Hpricot.XML('<desc>Awesome</desc>'))
|
122
122
|
|
data/test/unit/fleakr_test.rb
CHANGED
@@ -2,10 +2,10 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
3
3
|
class FleakrTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
5
|
+
context "The Fleakr module" do
|
6
6
|
|
7
7
|
[:api_key, :shared_secret, :mini_token, :auth_token].each do |attribute|
|
8
|
-
|
8
|
+
should "be able to set a value for :#{attribute}" do
|
9
9
|
value = 'value'
|
10
10
|
|
11
11
|
Fleakr.send("#{attribute}=".to_sym, value)
|
@@ -13,13 +13,13 @@ class FleakrTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
should "provide a means to find a user by his username" do
|
17
17
|
user = stub()
|
18
18
|
Fleakr::Objects::User.expects(:find_by_username).with('username').returns(user)
|
19
19
|
Fleakr.user('username').should == user
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
should "fall back to finding a user by email if finding by username fails" do
|
23
23
|
user = stub()
|
24
24
|
email = 'user@host.com'
|
25
25
|
|
@@ -29,20 +29,20 @@ class FleakrTest < Test::Unit::TestCase
|
|
29
29
|
Fleakr.user(email).should == user
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
should "be able to perform text searches" do
|
33
33
|
photos = [stub()]
|
34
34
|
|
35
35
|
Fleakr::Objects::Search.expects(:new).with(:text => 'foo').returns(stub(:results => photos))
|
36
36
|
Fleakr.search('foo').should == photos
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
should "be able to perform searches based on tags" do
|
40
40
|
Fleakr::Objects::Search.expects(:new).with(:tags => %w(one two)).returns(stub(:results => []))
|
41
41
|
Fleakr.search(:tags => %w(one two))
|
42
42
|
end
|
43
43
|
|
44
44
|
# TODO: refactor uploading tests?
|
45
|
-
|
45
|
+
should "be able to upload a collection of images" do
|
46
46
|
glob = '*.jpg'
|
47
47
|
filenames = %w(one.jpg two.jpg)
|
48
48
|
|
@@ -54,7 +54,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
54
54
|
Fleakr.upload(glob)
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
should "return recently uploaded photos" do
|
58
58
|
filename = '/path/to/image.jpg'
|
59
59
|
new_image = stub()
|
60
60
|
|
@@ -64,7 +64,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
64
64
|
Fleakr.upload(filename).should == [new_image]
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
should "be able to pass options for the uploaded files" do
|
68
68
|
filename = '/path/to/image.jpg'
|
69
69
|
new_image = stub()
|
70
70
|
|
@@ -74,7 +74,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
74
74
|
Fleakr.upload(filename, :title => 'bop bip').should == [new_image]
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
should "be able to reset the cached token" do
|
78
78
|
@token = stub()
|
79
79
|
Fleakr.expects(:auth_token).with().at_least_once.returns('abc123')
|
80
80
|
Fleakr::Objects::AuthenticationToken.expects(:from_auth_token).with('abc123').times(2).returns(@token)
|
@@ -83,7 +83,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
83
83
|
Fleakr.token # twice
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
should "not have a token by default" do
|
87
87
|
Fleakr.expects(:mini_token).with().returns(nil)
|
88
88
|
Fleakr.expects(:auth_token).with().returns(nil)
|
89
89
|
Fleakr.expects(:frob).with().returns(nil)
|
@@ -92,7 +92,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
92
92
|
end
|
93
93
|
|
94
94
|
[:mini_token, :auth_token, :frob].each do |attribute|
|
95
|
-
|
95
|
+
should "reset_token when :#{attribute} is set" do
|
96
96
|
Fleakr.expects(:reset_token).with().at_least_once
|
97
97
|
Fleakr.send("#{attribute}=".to_sym, 'value')
|
98
98
|
end
|
@@ -100,7 +100,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
100
100
|
|
101
101
|
context "when generating an AuthenticationToken from an auth_token string" do
|
102
102
|
|
103
|
-
|
103
|
+
setup do
|
104
104
|
@token = stub()
|
105
105
|
|
106
106
|
Fleakr.expects(:auth_token).with().at_least_once.returns('abc123')
|
@@ -108,13 +108,13 @@ class FleakrTest < Test::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
# Make sure to clear the cache
|
111
|
-
|
111
|
+
teardown { Fleakr.auth_token = nil }
|
112
112
|
|
113
|
-
|
113
|
+
should "return the token" do
|
114
114
|
Fleakr.token.should == @token
|
115
115
|
end
|
116
116
|
|
117
|
-
|
117
|
+
should "cache the result" do
|
118
118
|
2.times { Fleakr.token }
|
119
119
|
end
|
120
120
|
|
@@ -122,7 +122,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
122
122
|
|
123
123
|
context "when generating an AuthenticationToken from a frob string" do
|
124
124
|
|
125
|
-
|
125
|
+
setup do
|
126
126
|
@token = stub()
|
127
127
|
|
128
128
|
Fleakr.expects(:auth_token).with().at_least_once.returns(nil)
|
@@ -131,13 +131,13 @@ class FleakrTest < Test::Unit::TestCase
|
|
131
131
|
end
|
132
132
|
|
133
133
|
# Make sure to clear the cache
|
134
|
-
|
134
|
+
teardown { Fleakr.frob = nil }
|
135
135
|
|
136
|
-
|
136
|
+
should "return the token" do
|
137
137
|
Fleakr.token.should == @token
|
138
138
|
end
|
139
139
|
|
140
|
-
|
140
|
+
should "cache the result" do
|
141
141
|
2.times { Fleakr.token }
|
142
142
|
end
|
143
143
|
|
@@ -145,7 +145,7 @@ class FleakrTest < Test::Unit::TestCase
|
|
145
145
|
|
146
146
|
context "when generating an AuthenticationToken from a mini_token string" do
|
147
147
|
|
148
|
-
|
148
|
+
setup do
|
149
149
|
@token = stub()
|
150
150
|
|
151
151
|
Fleakr.expects(:auth_token).with().at_least_once.returns(nil)
|
@@ -154,13 +154,13 @@ class FleakrTest < Test::Unit::TestCase
|
|
154
154
|
end
|
155
155
|
|
156
156
|
# Make sure to clear the cache
|
157
|
-
|
157
|
+
teardown { Fleakr.mini_token = nil }
|
158
158
|
|
159
|
-
|
159
|
+
should "return the token" do
|
160
160
|
Fleakr.token.should == @token
|
161
161
|
end
|
162
162
|
|
163
|
-
|
163
|
+
should "cache the result" do
|
164
164
|
2.times { Fleakr.token }
|
165
165
|
end
|
166
166
|
|