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,98 +1,99 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Objects
|
4
4
|
class TagTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
context "The Tag class" do
|
7
|
-
|
8
|
-
should_find_all :tags, :by => :photo_id, :call => 'tags.getListPhoto', :path => 'rsp/photo/tags/tag'
|
9
|
-
should_find_all :tags, :by => :user_id, :call => 'tags.getListUser', :path => 'rsp/who/tags/tag'
|
7
|
+
|
8
|
+
should_find_all :tags, :by => :photo_id, :call => 'tags.getListPhoto', :path => 'rsp/photo/tags/tag', :class => Tag
|
9
|
+
should_find_all :tags, :by => :user_id, :call => 'tags.getListUser', :path => 'rsp/who/tags/tag', :class => Tag
|
10
|
+
|
10
11
|
end
|
11
|
-
|
12
|
+
|
12
13
|
context "An instance of the Tag class" do
|
13
|
-
|
14
|
+
|
14
15
|
setup { @tag = Tag.new }
|
15
|
-
|
16
|
+
|
16
17
|
context "when populating from the tags_getListPhoto XML data" do
|
17
18
|
setup do
|
18
19
|
@object = Tag.new(Hpricot.XML(read_fixture('tags.getListPhoto')).at('rsp/photo/tags/tag'))
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
should_have_a_value_for :id => '1'
|
22
23
|
should_have_a_value_for :author_id => '15498419@N05'
|
23
24
|
should_have_a_value_for :value => 'stu72'
|
24
25
|
should_have_a_value_for :raw => 'stu 72'
|
25
26
|
should_have_a_value_for :machine_flag => '0'
|
26
|
-
|
27
|
+
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
should "have an author" do
|
30
31
|
user = stub()
|
31
|
-
|
32
|
+
|
32
33
|
@tag.expects(:author_id).at_least_once.with().returns('1')
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
|
35
36
|
User.expects(:find_by_id).with('1').returns(user)
|
36
|
-
|
37
|
+
|
37
38
|
@tag.author.should == user
|
38
39
|
end
|
39
|
-
|
40
|
+
|
40
41
|
should "memoize the author data" do
|
41
42
|
@tag.expects(:author_id).at_least_once.with().returns('1')
|
42
|
-
|
43
|
+
|
43
44
|
User.expects(:find_by_id).with('1').once.returns(stub())
|
44
|
-
|
45
|
+
|
45
46
|
2.times { @tag.author }
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
should "return nil for author if author_id is not present" do
|
49
50
|
@tag.expects(:author_id).with().returns(nil)
|
50
|
-
|
51
|
+
|
51
52
|
@tag.author.should be(nil)
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
should "have related tags" do
|
55
56
|
@tag.expects(:value).with().returns('foo')
|
56
|
-
|
57
|
+
|
57
58
|
response = mock_request_cycle :for => 'tags.getRelated', :with => {:tag => 'foo'}
|
58
59
|
|
59
60
|
stubs = []
|
60
61
|
elements = (response.body/'rsp/tags/tag').map
|
61
|
-
|
62
|
+
|
62
63
|
elements.each do |element|
|
63
64
|
stub = stub()
|
64
65
|
stubs << stub
|
65
66
|
|
66
67
|
Tag.expects(:new).with(element).returns(stub)
|
67
68
|
end
|
68
|
-
|
69
|
+
|
69
70
|
@tag.related.should == stubs
|
70
71
|
end
|
71
|
-
|
72
|
+
|
72
73
|
should "memoize the data for related tags" do
|
73
74
|
@tag.expects(:value).with().returns('foo')
|
74
|
-
|
75
|
+
|
75
76
|
mock_request_cycle :for => 'tags.getRelated', :with => {:tag => 'foo'}
|
76
|
-
|
77
|
+
|
77
78
|
2.times { @tag.related }
|
78
79
|
end
|
79
|
-
|
80
|
+
|
80
81
|
should "be able to generate a string representation of itself" do
|
81
82
|
@tag.expects(:value).with().returns('foo')
|
82
83
|
@tag.to_s.should == 'foo'
|
83
84
|
end
|
84
|
-
|
85
|
+
|
85
86
|
should "know that it is not a machine tag" do
|
86
87
|
@tag.expects(:machine_flag).with().returns('0')
|
87
88
|
@tag.machine?.should be(false)
|
88
89
|
end
|
89
|
-
|
90
|
+
|
90
91
|
should "know that it is a machine tag" do
|
91
92
|
@tag.expects(:machine_flag).with().returns('1')
|
92
93
|
@tag.machine?.should be(true)
|
93
94
|
end
|
94
|
-
|
95
|
+
|
95
96
|
end
|
96
|
-
|
97
|
+
|
97
98
|
end
|
98
99
|
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Fleakr::Objects
|
4
|
+
class UrlTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context "An instance of the Url class" do
|
7
|
+
|
8
|
+
should "know that it's not a shortened URL" do
|
9
|
+
u = Url.new('http://flickr.com/photos/reagent/4041660453/')
|
10
|
+
u.shortened?.should be(false)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "know that it's a shortened URL" do
|
14
|
+
u = Url.new('http://flic.kr/p/7a9yQV')
|
15
|
+
u.shortened?.should be(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "know the path for a shortened URL" do
|
19
|
+
url = 'http://flic.kr/p/7a9yQV'
|
20
|
+
|
21
|
+
Fleakr::Support::UrlExpander.stubs(:expand).with(url).returns('/expanded/path')
|
22
|
+
|
23
|
+
u = Url.new(url)
|
24
|
+
u.path.should == '/expanded/path'
|
25
|
+
end
|
26
|
+
|
27
|
+
should "now the path for a normal URL" do
|
28
|
+
u = Url.new('http://www.flickr.com/photos/reagent/4041660453/')
|
29
|
+
u.path.should == '/photos/reagent/4041660453/'
|
30
|
+
end
|
31
|
+
|
32
|
+
should "know the path when there is no hostname" do
|
33
|
+
u = Url.new('http://flickr.com/photos/reagent/4041660453/')
|
34
|
+
u.path.should == '/photos/reagent/4041660453/'
|
35
|
+
end
|
36
|
+
|
37
|
+
should "be able to retrieve a user" do
|
38
|
+
u = Url.new('')
|
39
|
+
u.stubs(:user_identifier).with().returns('reagent')
|
40
|
+
|
41
|
+
User.expects(:find_by_identifier).with('reagent').returns('user')
|
42
|
+
|
43
|
+
u.user.should == 'user'
|
44
|
+
end
|
45
|
+
|
46
|
+
should "memoize the user" do
|
47
|
+
u = Url.new('')
|
48
|
+
u.stubs(:user_identifier).with().returns('reagent')
|
49
|
+
|
50
|
+
User.expects(:find_by_identifier).with('reagent').once.returns('user')
|
51
|
+
|
52
|
+
2.times { u.user }
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when provided a single photo URL" do
|
56
|
+
subject { Url.new('http://flickr.com/photos/reagent/4041660453/') }
|
57
|
+
|
58
|
+
should "know that it's retrieving a photo resource" do
|
59
|
+
subject.resource_type.should == Photo
|
60
|
+
end
|
61
|
+
|
62
|
+
should "know the :user_identifier" do
|
63
|
+
subject.user_identifier.should == 'reagent'
|
64
|
+
end
|
65
|
+
|
66
|
+
should "know the :resource_identifier" do
|
67
|
+
subject.resource_identifier.should == '4041660453'
|
68
|
+
end
|
69
|
+
|
70
|
+
should "know that it's not retrieving a collection of resources" do
|
71
|
+
subject.collection?.should be(false)
|
72
|
+
end
|
73
|
+
|
74
|
+
should "return the resource" do
|
75
|
+
Fleakr::Objects::Photo.expects(:find_by_id).with('4041660453').returns('photo')
|
76
|
+
subject.resource.should == 'photo'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when provided with a photoset URL" do
|
81
|
+
subject { @subject ||= Url.new('http://www.flickr.com/photos/reagent/') }
|
82
|
+
|
83
|
+
should "know that it's retrieving a Photo resource" do
|
84
|
+
subject.resource_type.should == Photo
|
85
|
+
end
|
86
|
+
|
87
|
+
should "know the :user_identifier" do
|
88
|
+
subject.user_identifier.should == 'reagent'
|
89
|
+
end
|
90
|
+
|
91
|
+
should "not have a :resource_identifier" do
|
92
|
+
subject.resource_identifier.should be_nil
|
93
|
+
end
|
94
|
+
|
95
|
+
should "know that it's retrieving a collection of resources" do
|
96
|
+
subject.collection?.should be(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
should "return the resource" do
|
100
|
+
subject.stubs(:user).with().returns(stub(:id => '1'))
|
101
|
+
|
102
|
+
Fleakr::Objects::Photo.expects(:find_all_by_user_id).with('1').returns('photos')
|
103
|
+
subject.resource.should == 'photos'
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when provided with a profile URL" do
|
109
|
+
subject { @subject ||= Url.new('http://www.flickr.com/people/reagent/') }
|
110
|
+
|
111
|
+
should "know that it's retrieving a user resource" do
|
112
|
+
subject.resource_type.should == User
|
113
|
+
end
|
114
|
+
|
115
|
+
should "know the :user_identifier" do
|
116
|
+
subject.user_identifier.should == 'reagent'
|
117
|
+
end
|
118
|
+
|
119
|
+
should "not have a :resource_identifier" do
|
120
|
+
subject.resource_identifier.should be_nil
|
121
|
+
end
|
122
|
+
|
123
|
+
should "return the resource" do
|
124
|
+
subject.expects(:user).with().returns('user')
|
125
|
+
subject.resource.should == 'user'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "when provided a profile URL with a user ID" do
|
130
|
+
subject { Url.new('http://www.flickr.com/people/43955217@N05/') }
|
131
|
+
|
132
|
+
should "know the :user_identifier" do
|
133
|
+
subject.user_identifier.should == '43955217@N05'
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
context "when provided with a single set URL" do
|
139
|
+
subject { Url.new('http://www.flickr.com/photos/reagent/sets/72157622660138146/') }
|
140
|
+
|
141
|
+
should "know that it's retrieving a set resource" do
|
142
|
+
subject.resource_type.should == Set
|
143
|
+
end
|
144
|
+
|
145
|
+
should "know the :user_identifier" do
|
146
|
+
subject.user_identifier.should == 'reagent'
|
147
|
+
end
|
148
|
+
|
149
|
+
should "know the :resource_identifier" do
|
150
|
+
subject.resource_identifier.should == '72157622660138146'
|
151
|
+
end
|
152
|
+
|
153
|
+
should "return the resource" do
|
154
|
+
Fleakr::Objects::Set.expects(:find_by_id).with('72157622660138146').returns('set')
|
155
|
+
subject.resource.should == 'set'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "when provided a set listing URL" do
|
160
|
+
subject { @subject ||= Url.new('http://www.flickr.com/photos/reagent/sets/') }
|
161
|
+
|
162
|
+
should "know that it's retrieving a set resource" do
|
163
|
+
subject.resource_type.should == Set
|
164
|
+
end
|
165
|
+
|
166
|
+
should "know the :user_identifier" do
|
167
|
+
subject.user_identifier.should == 'reagent'
|
168
|
+
end
|
169
|
+
|
170
|
+
should "not have a :resource_identifier" do
|
171
|
+
subject.resource_identifier.should be_nil
|
172
|
+
end
|
173
|
+
|
174
|
+
should "return the resource" do
|
175
|
+
subject.stubs(:user).with().returns(stub(:id => '1'))
|
176
|
+
|
177
|
+
Fleakr::Objects::Set.expects(:find_all_by_user_id).with('1').returns('sets')
|
178
|
+
subject.resource.should == 'sets'
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
end
|
@@ -1,21 +1,48 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Objects
|
4
4
|
class UserTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
should_search_by :user_id
|
7
7
|
|
8
|
-
should_have_many :photos, :
|
9
|
-
|
8
|
+
should_have_many :photos, :class => Photo
|
9
|
+
should_have_many :groups, :class => Group
|
10
|
+
should_have_many :sets, :class => Set
|
11
|
+
should_have_many :contacts, :class => Contact
|
12
|
+
should_have_many :tags, :class => Tag
|
13
|
+
should_have_many :collections, :class => Collection
|
14
|
+
|
10
15
|
should_autoload_when_accessing :name, :photos_url, :profile_url, :photos_count, :location, :with => :load_info
|
11
16
|
should_autoload_when_accessing :icon_server, :icon_farm, :pro, :admin, :icon_url, :with => :load_info
|
12
17
|
|
13
18
|
context "The User class" do
|
14
19
|
|
15
|
-
should_find_one :user, :by => :username, :call => 'people.findByUsername', :path => 'rsp/user'
|
16
|
-
should_find_one :user, :by => :email, :with => :find_email, :call => 'people.findByEmail', :path => 'rsp/user'
|
17
|
-
should_find_one :user, :by => :id, :with => :user_id, :call => 'people.getInfo', :path => 'rsp/person'
|
18
|
-
should_find_one :user, :by => :url, :call => 'urls.lookupUser', :path => 'rsp/user'
|
20
|
+
should_find_one :user, :by => :username, :call => 'people.findByUsername', :path => 'rsp/user', :class => User
|
21
|
+
should_find_one :user, :by => :email, :with => :find_email, :call => 'people.findByEmail', :path => 'rsp/user', :class => User
|
22
|
+
should_find_one :user, :by => :id, :with => :user_id, :call => 'people.getInfo', :path => 'rsp/person', :class => User
|
23
|
+
should_find_one :user, :by => :url, :call => 'urls.lookupUser', :path => 'rsp/user', :class => User
|
24
|
+
|
25
|
+
should "recognize a string as not being a Flickr user ID" do
|
26
|
+
User.user_id?('reagent').should be(false)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "recognize a string as being a Flickr user ID" do
|
30
|
+
User.user_id?('43955217@N05').should be(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "be able to find a user by ID when supplied with an identifier" do
|
34
|
+
id = '43955217@N05'
|
35
|
+
User.expects(:find_by_id).with(id).returns('user')
|
36
|
+
|
37
|
+
User.find_by_identifier(id).should == 'user'
|
38
|
+
end
|
39
|
+
|
40
|
+
should "be able to find a user by username when supplied with an identifier" do
|
41
|
+
username = 'reagent'
|
42
|
+
User.expects(:find_by_username).with(username).returns('user')
|
43
|
+
|
44
|
+
User.find_by_identifier(username).should == 'user'
|
45
|
+
end
|
19
46
|
|
20
47
|
end
|
21
48
|
|
@@ -37,18 +64,18 @@ module Fleakr::Objects
|
|
37
64
|
should_have_a_value_for :icon_farm => '1'
|
38
65
|
should_have_a_value_for :pro => '1'
|
39
66
|
should_have_a_value_for :admin => '0'
|
40
|
-
|
67
|
+
|
41
68
|
end
|
42
|
-
|
69
|
+
|
43
70
|
context "when populating an object from the urls.lookupUser API call" do
|
44
71
|
setup do
|
45
72
|
document = Hpricot.XML(read_fixture('urls.lookupUser'))
|
46
73
|
@object = User.new(document)
|
47
74
|
end
|
48
|
-
|
75
|
+
|
49
76
|
should_have_a_value_for :id => '123456'
|
50
77
|
should_have_a_value_for :username => 'frootpantz'
|
51
|
-
|
78
|
+
|
52
79
|
end
|
53
80
|
|
54
81
|
context "in general" do
|
@@ -79,23 +106,23 @@ module Fleakr::Objects
|
|
79
106
|
@user.stubs(:icon_server).with().returns(nil)
|
80
107
|
@user.icon_url.should == 'http://www.flickr.com/images/buddyicon.jpg'
|
81
108
|
end
|
82
|
-
|
109
|
+
|
83
110
|
should "return a boolean value for :pro?" do
|
84
111
|
@user.stubs(:pro).with().returns('0')
|
85
112
|
@user.pro?.should be(false)
|
86
|
-
|
113
|
+
|
87
114
|
@user.stubs(:pro).with().returns('1')
|
88
115
|
@user.pro?.should be(true)
|
89
116
|
end
|
90
|
-
|
117
|
+
|
91
118
|
should "return a boolean value for :admin?" do
|
92
119
|
@user.stubs(:admin).with().returns('0')
|
93
120
|
@user.admin?.should be(false)
|
94
|
-
|
121
|
+
|
95
122
|
@user.stubs(:admin).with().returns('1')
|
96
123
|
@user.admin?.should be(true)
|
97
124
|
end
|
98
|
-
|
125
|
+
|
99
126
|
end
|
100
127
|
end
|
101
128
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../../test_helper', __FILE__)
|
2
2
|
|
3
3
|
module Fleakr::Support
|
4
4
|
class AttributeTest < Test::Unit::TestCase
|
@@ -13,7 +13,7 @@ module Fleakr::Support
|
|
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']
|
@@ -23,32 +23,32 @@ module Fleakr::Support
|
|
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'
|
@@ -57,15 +57,15 @@ module Fleakr::Support
|
|
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
|
+
|
61
61
|
attr = Attribute.new(:name)
|
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
|
+
|
69
69
|
attr = Attribute.new(:id)
|
70
70
|
attr.node_for(document, '@id').should == expected
|
71
71
|
end
|
@@ -73,11 +73,11 @@ module Fleakr::Support
|
|
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
|
+
|
77
77
|
attr = Attribute.new(:id, '@nsid')
|
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)
|
@@ -89,7 +89,7 @@ module Fleakr::Support
|
|
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')
|
@@ -101,7 +101,7 @@ module Fleakr::Support
|
|
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)
|