reagent-fleakr 0.4.3 → 0.5.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.
Files changed (32) hide show
  1. data/Rakefile +1 -1
  2. data/lib/fleakr/api/option.rb +6 -6
  3. data/lib/fleakr/version.rb +2 -2
  4. data/lib/fleakr.rb +2 -1
  5. data/test/test_helper.rb +9 -8
  6. data/test/unit/fleakr/api/file_parameter_test.rb +8 -8
  7. data/test/unit/fleakr/api/method_request_test.rb +11 -10
  8. data/test/unit/fleakr/api/option_test.rb +29 -29
  9. data/test/unit/fleakr/api/parameter_list_test.rb +22 -22
  10. data/test/unit/fleakr/api/parameter_test.rb +5 -5
  11. data/test/unit/fleakr/api/response_test.rb +6 -6
  12. data/test/unit/fleakr/api/upload_request_test.rb +28 -24
  13. data/test/unit/fleakr/api/value_parameter_test.rb +6 -6
  14. data/test/unit/fleakr/core_ext/false_class_test.rb +2 -2
  15. data/test/unit/fleakr/core_ext/hash_test.rb +6 -6
  16. data/test/unit/fleakr/core_ext/true_class_test.rb +2 -2
  17. data/test/unit/fleakr/objects/authentication_token_test.rb +6 -6
  18. data/test/unit/fleakr/objects/comment_test.rb +8 -8
  19. data/test/unit/fleakr/objects/contact_test.rb +8 -5
  20. data/test/unit/fleakr/objects/error_test.rb +2 -2
  21. data/test/unit/fleakr/objects/group_test.rb +5 -5
  22. data/test/unit/fleakr/objects/image_test.rb +6 -6
  23. data/test/unit/fleakr/objects/photo_context_test.rb +11 -11
  24. data/test/unit/fleakr/objects/photo_test.rb +32 -29
  25. data/test/unit/fleakr/objects/search_test.rb +9 -9
  26. data/test/unit/fleakr/objects/set_test.rb +9 -9
  27. data/test/unit/fleakr/objects/tag_test.rb +12 -12
  28. data/test/unit/fleakr/objects/user_test.rb +10 -10
  29. data/test/unit/fleakr/support/attribute_test.rb +21 -21
  30. data/test/unit/fleakr/support/object_test.rb +17 -17
  31. data/test/unit/fleakr_test.rb +24 -24
  32. metadata +3 -3
@@ -21,17 +21,17 @@ end
21
21
  module Fleakr
22
22
  class ObjectTest < Test::Unit::TestCase
23
23
 
24
- describe "A class method provided by the Flickr::Object module" do
24
+ context "A class method provided by the Flickr::Object module" do
25
25
 
26
- it "should have an empty list of attributes if none are supplied" do
26
+ should "have an empty list of attributes if none are supplied" do
27
27
  EmptyObject.attributes.should == []
28
28
  end
29
29
 
30
- it "should know the names of all its attributes" do
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
- it "should be able to find by ID" do
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
- it "should be able to pass parameters to the :find_by_id method" do
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
- describe "An instance method provided by the Flickr::Object module" do
57
+ context "An instance method provided by the Flickr::Object module" do
58
58
 
59
- it "should have default reader methods" do
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
- before do
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
- it "should have the correct value for :name" do
79
+ should "have the correct value for :name" do
80
80
  @object.name.should == 'Fleakr'
81
81
  end
82
82
 
83
- it "should have the correct value for :description" do
83
+ should "have the correct value for :description" do
84
84
  @object.description.should == 'Awesome'
85
85
  end
86
86
 
87
- it "should have the correct value for :photoset_id" do
87
+ should "have the correct value for :photoset_id" do
88
88
  @object.photoset_id.should == '1'
89
89
  end
90
90
 
91
- it "should have the correct value for :id" do
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
- it "should have the correct value for :tag" do
98
+ should "have the correct value for :tag" do
99
99
  @object.tag.should == 'Tag'
100
100
  end
101
101
 
102
- it "should have the correct value for :category" do
102
+ should "have the correct value for :category" do
103
103
  @object.category.should == 'Category'
104
104
  end
105
105
  end
106
106
 
107
- it "should populate its data from an XML document when initializing" do
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
- it "should not attempt to populate itself from an XML document if one is not available" do
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
- it "should not overwrite existing attributes when pulling in a partial new XML document" do
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
 
@@ -2,10 +2,10 @@ require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
3
  class FleakrTest < Test::Unit::TestCase
4
4
 
5
- describe "The Fleakr module" do
5
+ context "The Fleakr module" do
6
6
 
7
7
  [:api_key, :shared_secret, :mini_token, :auth_token].each do |attribute|
8
- it "should be able to set a value for :#{attribute}" do
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
- it "should provide a means to find a user by his username" do
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
- it "should fall back to finding a user by email if finding by username fails" do
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
- it "should be able to perform text searches" do
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
- it "should be able to perform searches based on tags" do
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
- it "should be able to upload a collection of images" do
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
- it "should return recently uploaded photos" do
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
- it "should be able to pass options for the uploaded files" do
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
- it "should be able to reset the cached token" do
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
- it "should not have a token by default" do
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
- it "should reset_token when :#{attribute} is set" do
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
- before do
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
- after { Fleakr.auth_token = nil }
111
+ teardown { Fleakr.auth_token = nil }
112
112
 
113
- it "should return the token" do
113
+ should "return the token" do
114
114
  Fleakr.token.should == @token
115
115
  end
116
116
 
117
- it "should cache the result" do
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
- before do
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
- after { Fleakr.frob = nil }
134
+ teardown { Fleakr.frob = nil }
135
135
 
136
- it "should return the token" do
136
+ should "return the token" do
137
137
  Fleakr.token.should == @token
138
138
  end
139
139
 
140
- it "should cache the result" do
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
- before do
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
- after { Fleakr.mini_token = nil }
157
+ teardown { Fleakr.mini_token = nil }
158
158
 
159
- it "should return the token" do
159
+ should "return the token" do
160
160
  Fleakr.token.should == @token
161
161
  end
162
162
 
163
- it "should cache the result" do
163
+ should "cache the result" do
164
164
  2.times { Fleakr.token }
165
165
  end
166
166
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reagent-fleakr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Reagan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-11 00:00:00 -07:00
12
+ date: 2009-05-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.6.0
23
+ version: 0.8.1
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport