flickrmocks 0.8.5
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/.autotest +36 -0
- data/.document +5 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +76 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +1 -0
- data/flickrmocks.gemspec +155 -0
- data/lib/flickr_mocks/api/api.rb +42 -0
- data/lib/flickr_mocks/api/flickr.rb +27 -0
- data/lib/flickr_mocks/api/helpers.rb +19 -0
- data/lib/flickr_mocks/api/options.rb +55 -0
- data/lib/flickr_mocks/api/sanitize.rb +29 -0
- data/lib/flickr_mocks/fixtures.rb +35 -0
- data/lib/flickr_mocks/flickraw/custom_clone.rb +19 -0
- data/lib/flickr_mocks/flickraw/custom_compare.rb +25 -0
- data/lib/flickr_mocks/flickraw/custom_marshal.rb +39 -0
- data/lib/flickr_mocks/flickraw/flickraw.rb +14 -0
- data/lib/flickr_mocks/helpers.rb +52 -0
- data/lib/flickr_mocks/models/helpers.rb +14 -0
- data/lib/flickr_mocks/models/photo.rb +101 -0
- data/lib/flickr_mocks/models/photo_details.rb +86 -0
- data/lib/flickr_mocks/models/photo_dimensions.rb +103 -0
- data/lib/flickr_mocks/models/photo_search.rb +115 -0
- data/lib/flickr_mocks/models/photo_size.rb +60 -0
- data/lib/flickr_mocks/models/photo_sizes.rb +93 -0
- data/lib/flickr_mocks/models/photos.rb +133 -0
- data/lib/flickr_mocks/stubs.rb +103 -0
- data/lib/flickr_mocks/version.rb +4 -0
- data/lib/flickrmocks.rb +27 -0
- data/spec/api/api_spec.rb +84 -0
- data/spec/api/flickr_spec.rb +48 -0
- data/spec/api/helper_spec.rb +37 -0
- data/spec/api/options_spec.rb +152 -0
- data/spec/api/sanitize_spec.rb +90 -0
- data/spec/base/fixtures_spec.rb +89 -0
- data/spec/base/flickraw/custom_clone_spec.rb +70 -0
- data/spec/base/flickraw/custom_compare_spec.rb +98 -0
- data/spec/base/flickraw/custom_marshal_spec.rb +45 -0
- data/spec/base/helpers_spec.rb +63 -0
- data/spec/base/stubs_spec.rb +180 -0
- data/spec/base/version_spec.rb +15 -0
- data/spec/fixtures/author_photos.marshal +0 -0
- data/spec/fixtures/empty_photos.marshal +0 -0
- data/spec/fixtures/expected_methods.marshal +17 -0
- data/spec/fixtures/interesting_photos.marshal +0 -0
- data/spec/fixtures/photo.marshal +0 -0
- data/spec/fixtures/photo_details.marshal +0 -0
- data/spec/fixtures/photo_size.marshal +0 -0
- data/spec/fixtures/photo_sizes.marshal +0 -0
- data/spec/fixtures/photos.marshal +0 -0
- data/spec/models/helpers_spec.rb +25 -0
- data/spec/models/photo_details_spec.rb +224 -0
- data/spec/models/photo_dimensions_spec.rb +208 -0
- data/spec/models/photo_search_spec.rb +255 -0
- data/spec/models/photo_size_spec.rb +122 -0
- data/spec/models/photo_sizes_spec.rb +168 -0
- data/spec/models/photo_spec.rb +278 -0
- data/spec/models/photos_spec.rb +305 -0
- data/spec/shared_examples/array_accessor.rb +157 -0
- data/spec/shared_examples/collection.rb +49 -0
- data/spec/shared_examples/image_url_helpers.rb +56 -0
- data/spec/shared_examples/size_accessor.rb +13 -0
- data/spec/spec_helper.rb +24 -0
- data/tasks/fixtures.rb +164 -0
- metadata +259 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ruby-debug'
|
3
|
+
|
4
|
+
describe APP::Fixtures do
|
5
|
+
|
6
|
+
let(:klass) {APP::Fixtures}
|
7
|
+
let(:fixtures) {APP::Fixtures.new}
|
8
|
+
let(:subject) {fixtures}
|
9
|
+
|
10
|
+
context "class methods" do
|
11
|
+
specify {klass.should respond_to(:repository)}
|
12
|
+
context "repository" do
|
13
|
+
it "returns expected directory for the repository" do
|
14
|
+
expected = File.expand_path(File.dirname(__FILE__) + '/../fixtures') + '/'
|
15
|
+
klass.repository.should == expected
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
context "instance_methods" do
|
22
|
+
shared_examples_for "a flickraw fixture" do
|
23
|
+
let (:subject) {fixtures.send(fixture)}
|
24
|
+
let(:expected_methods){fixtures.expected_methods.send(fixture)}
|
25
|
+
it "responds to expected methods" do
|
26
|
+
expected_methods.each do |method|
|
27
|
+
subject.should respond_to(method)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
specify {subject.should respond_to(:photo)}
|
35
|
+
context "photo" do
|
36
|
+
let(:fixture) {:photo}
|
37
|
+
it_behaves_like "a flickraw fixture"
|
38
|
+
end
|
39
|
+
|
40
|
+
specify {subject.should respond_to(:photos)}
|
41
|
+
context "photos" do
|
42
|
+
let(:fixture) {:photos}
|
43
|
+
it_behaves_like "a flickraw fixture"
|
44
|
+
end
|
45
|
+
|
46
|
+
specify {subject.should respond_to(:empty_photos)}
|
47
|
+
context "empty_photos" do
|
48
|
+
let(:fixture){:empty_photos}
|
49
|
+
it_behaves_like "a flickraw fixture"
|
50
|
+
end
|
51
|
+
|
52
|
+
specify {subject.should respond_to(:photo_details)}
|
53
|
+
context "photo_details" do
|
54
|
+
let(:fixture) {:photo_details}
|
55
|
+
it_behaves_like "a flickraw fixture"
|
56
|
+
end
|
57
|
+
|
58
|
+
specify {subject.should respond_to(:interesting_photos)}
|
59
|
+
context 'interesting_photos' do
|
60
|
+
let(:fixture) {:interesting_photos}
|
61
|
+
it_behaves_like "a flickraw fixture"
|
62
|
+
end
|
63
|
+
|
64
|
+
specify {subject.should respond_to(:author_photos)}
|
65
|
+
context "author_photos" do
|
66
|
+
let(:fixture) {:author_photos}
|
67
|
+
it_behaves_like "a flickraw fixture"
|
68
|
+
end
|
69
|
+
|
70
|
+
specify {subject.should respond_to(:photo_size)}
|
71
|
+
context "photo_size" do
|
72
|
+
let(:fixture) {:photo_size}
|
73
|
+
it_behaves_like "a flickraw fixture"
|
74
|
+
end
|
75
|
+
|
76
|
+
specify {subject.should respond_to(:photo_sizes)}
|
77
|
+
context "photo_sizes" do
|
78
|
+
let(:fixture) {:photo_sizes}
|
79
|
+
it_behaves_like "a flickraw fixture"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::CustomClone do
|
4
|
+
let(:fixtures){APP::Fixtures.new}
|
5
|
+
|
6
|
+
let(:photo){fixtures.photo}
|
7
|
+
let(:photos){fixtures.photos}
|
8
|
+
let(:photo_details){fixtures.photo_details}
|
9
|
+
let(:photo_sizes){fixtures.photo_sizes}
|
10
|
+
let(:photo_size){fixtures.photo_size}
|
11
|
+
|
12
|
+
# helper test method that check the ids of all object containted in a
|
13
|
+
# => FlickRaw::Response/ResponseList objects
|
14
|
+
def same_ids?(object,other)
|
15
|
+
case object
|
16
|
+
when FlickRaw::Response then same_ids?(object.instance_eval('@h'), other.instance_eval('@h'))
|
17
|
+
when Fixnum then nil
|
18
|
+
when String then object.__id__ == other.__id__
|
19
|
+
when Array then object.each_with_index.map do |value,index|
|
20
|
+
same_ids?(value,other[index])
|
21
|
+
end.keep_if do |value|
|
22
|
+
!value.nil?
|
23
|
+
end.inject(true) do |previous,current|
|
24
|
+
previous && current
|
25
|
+
end
|
26
|
+
when Hash then object.keys.map do |key|
|
27
|
+
same_ids?(object[key],other[key])
|
28
|
+
end.keep_if do |value|
|
29
|
+
!value.nil?
|
30
|
+
end.inject(true) do |previous,current|
|
31
|
+
previous && current
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "clone" do
|
37
|
+
shared_examples_for "cloning any flickraw response" do
|
38
|
+
it "returns clone with distinct ids from original object" do
|
39
|
+
other = subject.clone
|
40
|
+
same_ids?(subject,other).should be_false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "cloning photo flickraw response" do
|
45
|
+
let(:subject){ photo}
|
46
|
+
it_behaves_like "cloning any flickraw response"
|
47
|
+
end
|
48
|
+
|
49
|
+
context "cloning photos flickraw responseList" do
|
50
|
+
let(:subject) { photos }
|
51
|
+
it_behaves_like "cloning any flickraw response"
|
52
|
+
end
|
53
|
+
|
54
|
+
context "cloning photo_details flickraw responseList" do
|
55
|
+
let(:subject) {photo_details}
|
56
|
+
it_behaves_like "cloning any flickraw response"
|
57
|
+
end
|
58
|
+
|
59
|
+
context "cloning photo_sizes flickraw responseList" do
|
60
|
+
let(:subject) { photo_sizes }
|
61
|
+
it_behaves_like "cloning any flickraw response"
|
62
|
+
end
|
63
|
+
|
64
|
+
context "cloning photo_size responseList" do
|
65
|
+
let(:subject) {photo_size}
|
66
|
+
it_behaves_like "cloning any flickraw response"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::CustomCompare do
|
4
|
+
let(:fixtures){APP::Fixtures.new}
|
5
|
+
|
6
|
+
let(:photo){fixtures.photo}
|
7
|
+
let(:photos){fixtures.photos}
|
8
|
+
let(:photo_details){fixtures.photo_details}
|
9
|
+
let(:photo_sizes){fixtures.photo_sizes}
|
10
|
+
let(:photo_size){fixtures.photo_size}
|
11
|
+
|
12
|
+
shared_examples_for "flickraw response for ==" do
|
13
|
+
it "should be equal to itself" do
|
14
|
+
subject.should == subject
|
15
|
+
end
|
16
|
+
it "should not be equal to nil" do
|
17
|
+
subject.should_not == nil
|
18
|
+
end
|
19
|
+
it "should be equal to clone of itself" do
|
20
|
+
subject.should == subject.clone
|
21
|
+
end
|
22
|
+
it "should not equal a different class" do
|
23
|
+
subject.should_not == [1,2,3,4]
|
24
|
+
end
|
25
|
+
it "should not eq another response" do
|
26
|
+
subject.should_not == other
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "instance methods" do
|
31
|
+
context "#==" do
|
32
|
+
context "photo flickraw response" do
|
33
|
+
let(:subject){photo}
|
34
|
+
let(:other){photo_details}
|
35
|
+
|
36
|
+
it_behaves_like "flickraw response for =="
|
37
|
+
|
38
|
+
it "returns false when object is compared with object that is slightly different" do
|
39
|
+
other = subject.clone
|
40
|
+
other.stub(:title).and_return(Faker::Lorem.sentence(3))
|
41
|
+
subject.should_not == other
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "photos flickraw responselist" do
|
46
|
+
let(:subject){photos}
|
47
|
+
let(:other){photo_details}
|
48
|
+
|
49
|
+
it_behaves_like "flickraw response for =="
|
50
|
+
|
51
|
+
it "returns false when object is compared with object that is slightly different" do
|
52
|
+
other = subject.clone
|
53
|
+
other.stub(:total).and_return('123454321')
|
54
|
+
subject.should_not == other
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "photo_details flickraw response" do
|
59
|
+
let(:subject){photo_details}
|
60
|
+
let(:other){photo_sizes}
|
61
|
+
|
62
|
+
it_behaves_like "flickraw response for =="
|
63
|
+
|
64
|
+
it "returns false when object is compared with object that is slightly different" do
|
65
|
+
other = subject.clone
|
66
|
+
subject.stub(:farm).and_return(123421)
|
67
|
+
subject.should_not == other
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "photo_sizes response list" do
|
72
|
+
let(:subject){photo_sizes}
|
73
|
+
let(:other){photo_details}
|
74
|
+
|
75
|
+
it_behaves_like "flickraw response for =="
|
76
|
+
|
77
|
+
it "returns false when object is compared with object that is slightly different" do
|
78
|
+
other = subject.clone
|
79
|
+
other.stub(:canprint).and_return(1234321)
|
80
|
+
subject.should_not == other
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "photo_size response" do
|
85
|
+
let(:subject){photo_size}
|
86
|
+
let(:other){photo_details}
|
87
|
+
|
88
|
+
it_behaves_like "flickraw response for =="
|
89
|
+
|
90
|
+
it "returns false when object is compared with object that is slightly different" do
|
91
|
+
other = subject.clone
|
92
|
+
other.stub(:width).and_return(1234321)
|
93
|
+
subject.should_not == other
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::CustomMarshal do
|
4
|
+
let(:klass) {APP::CustomMarshal}
|
5
|
+
let(:helpers) {APP::Helpers}
|
6
|
+
let(:fixtures) {APP::Fixtures.new}
|
7
|
+
|
8
|
+
shared_examples_for "marshalling and unmarshalling flickraw objects" do
|
9
|
+
it "should properly marshal/unmarshal Photos object" do
|
10
|
+
marshalled = Marshal.load(Marshal.dump(subject))
|
11
|
+
helpers.equivalent?(subject,marshalled).should be_true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "intance methods" do
|
16
|
+
context "flickraw fixtures" do
|
17
|
+
context "#marshal and #unmarshal" do
|
18
|
+
context "fixture: photos" do
|
19
|
+
let(:subject){fixtures.photos}
|
20
|
+
it_behaves_like "marshalling and unmarshalling flickraw objects"
|
21
|
+
end
|
22
|
+
|
23
|
+
context "fixture: photo_sizes" do
|
24
|
+
let(:subject){fixtures.photo_sizes}
|
25
|
+
it_behaves_like "marshalling and unmarshalling flickraw objects"
|
26
|
+
end
|
27
|
+
|
28
|
+
context "fixture: photo_details" do
|
29
|
+
let(:subject){fixtures.photo_details}
|
30
|
+
it_behaves_like "marshalling and unmarshalling flickraw objects"
|
31
|
+
end
|
32
|
+
|
33
|
+
context "fixture: photo" do
|
34
|
+
let(:subject){fixtures.photo}
|
35
|
+
it_behaves_like "marshalling and unmarshalling flickraw objects"
|
36
|
+
end
|
37
|
+
|
38
|
+
context "fixture: interesting_photos" do
|
39
|
+
let(:subject){fixtures.interesting_photos}
|
40
|
+
it_behaves_like "marshalling and unmarshalling flickraw objects"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::Helpers do
|
4
|
+
let(:klass) {APP::Helpers}
|
5
|
+
let(:fixtures) {APP::Fixtures.new}
|
6
|
+
|
7
|
+
context "class methods" do
|
8
|
+
|
9
|
+
specify {klass.should respond_to(:extension)}
|
10
|
+
context 'extension' do
|
11
|
+
it "returns expected extension: .marshal" do
|
12
|
+
klass.extension.should == '.marshal'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
specify {klass.should respond_to(:fname_fixture)}
|
17
|
+
context "fname_fixture" do
|
18
|
+
it "returns correct fixture file name with symbol argument" do
|
19
|
+
expected_fname = 'sample_file' + klass.extension
|
20
|
+
klass.fname_fixture(:sample_file).should == expected_fname
|
21
|
+
end
|
22
|
+
it "raises an error when file name is a string" do
|
23
|
+
expect {klass.fname_fixture('sample_file')}.to raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
specify {klass.should respond_to(:equivalent?)}
|
28
|
+
context "equivalent?" do
|
29
|
+
it "returns true when photo_detail object compared to itself" do
|
30
|
+
klass.should be_equivalent(fixtures.photo_details,fixtures.photo_details)
|
31
|
+
end
|
32
|
+
it "returns true when photo_sizes object is compared to itself" do
|
33
|
+
klass.should be_equivalent(fixtures.photo_sizes,fixtures.photo_sizes)
|
34
|
+
end
|
35
|
+
it "returns true when same photo object is compared to itself" do
|
36
|
+
klass.should be_equivalent(fixtures.photos,fixtures.photos)
|
37
|
+
end
|
38
|
+
it "returns false when photo_details object is compared to photo object" do
|
39
|
+
klass.should_not be_equivalent(fixtures.photo_details, fixtures.photos.first)
|
40
|
+
end
|
41
|
+
it "returns false when photo_sizes object is compared to photo_details object" do
|
42
|
+
klass.should_not be_equivalent(fixtures.photo_sizes,fixtures.photo_details)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
specify {klass.should respond_to(:dump)}
|
47
|
+
specify {klass.should respond_to(:load)}
|
48
|
+
context "dump/load behavior" do
|
49
|
+
it "dumps and loads an object without losing data" do
|
50
|
+
begin
|
51
|
+
fname = "/tmp/#{Time.now}_#{Random.rand}"
|
52
|
+
expected = [Random.rand,Random.rand]
|
53
|
+
klass.dump(expected,fname)
|
54
|
+
actual = klass.load(fname)
|
55
|
+
actual.should == expected
|
56
|
+
ensure
|
57
|
+
File.delete fname
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::Stubs do
|
4
|
+
let(:klass) {APP::Stubs}
|
5
|
+
let(:fixtures) {APP::Fixtures.new}
|
6
|
+
|
7
|
+
context "class methods" do
|
8
|
+
|
9
|
+
specify{klass.should respond_to(:stub_flickr)}
|
10
|
+
context "stub_flickr" do
|
11
|
+
before(:each) do
|
12
|
+
klass.stub_flickr
|
13
|
+
end
|
14
|
+
it "stubs flickr.photos.search" do
|
15
|
+
flickr.photos.search(:tags => 'france').should == fixtures.photos
|
16
|
+
end
|
17
|
+
it "stubs flickr.photos.getSizes" do
|
18
|
+
flickr.photos.getSizes(:photo_id => '2121', :secret => '123abc').should == fixtures.photo_sizes
|
19
|
+
end
|
20
|
+
it "stubs flickr.photos.getInfo" do
|
21
|
+
flickr.photos.getInfo(:photo_id => '2121', :secret => '123abc').should == fixtures.photo_details
|
22
|
+
end
|
23
|
+
it "stubs flickr.interestingness.getList" do
|
24
|
+
flickr.interestingness.getList.should == fixtures.interesting_photos
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
specify {klass.should respond_to(:stub_search)}
|
29
|
+
context "stub_search: stubs for flickr.photos.search" do
|
30
|
+
before(:each) do
|
31
|
+
klass.stub_search
|
32
|
+
end
|
33
|
+
it "raises error when no options provided" do
|
34
|
+
expect {
|
35
|
+
flickr.photos.search
|
36
|
+
}.to raise_error(
|
37
|
+
FlickRaw::FailedResponse,
|
38
|
+
/'flickr.photos.search' - Parameterless searches have been disabled. Please use flickr.photos.getRecent instead./
|
39
|
+
)
|
40
|
+
end
|
41
|
+
it "raises when non-Hash option provided" do
|
42
|
+
expect {
|
43
|
+
flickr.photos.search([])
|
44
|
+
}.to raise_error(
|
45
|
+
FlickRaw::FailedResponse,
|
46
|
+
/'flickr.photos.search' - Parameterless searches have been disabled. Please use flickr.photos.getRecent instead./
|
47
|
+
)
|
48
|
+
end
|
49
|
+
it "raises error when neither :photo nor :user_id given" do
|
50
|
+
expect {
|
51
|
+
flickr.photos.search(:per_page => '3', :license => '4' )
|
52
|
+
}.to raise_error(
|
53
|
+
FlickRaw::FailedResponse,
|
54
|
+
/'flickr.photos.search' - Parameterless searches have been disabled. Please use flickr.photos.getRecent instead./
|
55
|
+
)
|
56
|
+
end
|
57
|
+
it "returns default photos fixture when :tags option given with non-garbage value" do
|
58
|
+
flickr.photos.search(:tags => "france").should == fixtures.photos
|
59
|
+
end
|
60
|
+
it "returns empty photos when :tags option given with garbage value" do
|
61
|
+
flickr.photos.search(:tags => "garbage").should == fixtures.empty_photos
|
62
|
+
end
|
63
|
+
it "returns author photo fixture when :user_id option given with non-garbage option" do
|
64
|
+
flickr.photos.search(:user_id => '23@393').should == fixtures.author_photos
|
65
|
+
end
|
66
|
+
it "returns empty photos when :user_id is garbage" do
|
67
|
+
flickr.photos.search(:user_id => 'garbage').should == fixtures.empty_photos
|
68
|
+
end
|
69
|
+
it "returns :author_photos when both :tags and :author_id provided with non-garbage option" do
|
70
|
+
flickr.photos.search(:user_id => '23@23', :tags => '23@23').should == fixtures.author_photos
|
71
|
+
end
|
72
|
+
it "returns empty_photos when :tags is garbage and :author_id is non-garbage" do
|
73
|
+
flickr.photos.search(:author_id => '23@393', :tags => 'garbage').should == fixtures.empty_photos
|
74
|
+
end
|
75
|
+
it "returns empty_photos when :author_id is garbage and :tags is non-garbage" do
|
76
|
+
flickr.photos.search(:user_id=> 'garbage', :tags => 'france').should == fixtures.empty_photos
|
77
|
+
end
|
78
|
+
it "returns :empty when both :author_id and :tags is garbage" do
|
79
|
+
flickr.photos.search(:user_id=>'garbage',:tags => 'garbage').should == fixtures.empty_photos
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
specify {klass.should respond_to(:stub_getInfo)}
|
85
|
+
context "stub_getInfo: which stubs flickr.photos.getInfo" do
|
86
|
+
before(:each) do
|
87
|
+
klass.stub_getInfo
|
88
|
+
end
|
89
|
+
it "raises error when no arguments provided" do
|
90
|
+
expect { flickr.photos.getInfo.should }.to raise_error(
|
91
|
+
FlickRaw::FailedResponse,
|
92
|
+
/'flickr.photos.getInfo' - Photo not found/
|
93
|
+
)
|
94
|
+
end
|
95
|
+
it "raises error when improper photo_id provided" do
|
96
|
+
expect { flickr.photos.getInfo(:photo_id => 'garbage').should }.to raise_error(
|
97
|
+
FlickRaw::FailedResponse,
|
98
|
+
/'flickr.photos.getInfo' - Photo "garbage" not found \(invalid ID\)/
|
99
|
+
)
|
100
|
+
end
|
101
|
+
it "raises error when non-hash option provided" do
|
102
|
+
expect { flickr.photos.getInfo([]).should }.to raise_error(
|
103
|
+
FlickRaw::FailedResponse,
|
104
|
+
/'flickr.photos.getInfo' - Photo not found/
|
105
|
+
)
|
106
|
+
end
|
107
|
+
it "raises photo details fixture when photo_id and secret given" do
|
108
|
+
flickr.photos.getInfo(:secret => 'b5da82cd4e', :photo_id => '51028174').should == fixtures.photo_details
|
109
|
+
end
|
110
|
+
it "raises photo details fixture when photo_id and no secret given" do
|
111
|
+
flickr.photos.getInfo(:photo_id => '51028174').should == fixtures.photo_details
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
specify {klass.should respond_to(:stub_getSizes)}
|
116
|
+
context "stub_getSizes: which stubs flickr.photos.getSizes" do
|
117
|
+
before(:each) do
|
118
|
+
klass.stub_getSizes
|
119
|
+
end
|
120
|
+
it "raises error when no options given" do
|
121
|
+
expect {
|
122
|
+
flickr.photos.getSizes
|
123
|
+
}.to raise_error(
|
124
|
+
FlickRaw::FailedResponse,
|
125
|
+
/'flickr.photos.getSizes' - Photo not found/
|
126
|
+
)
|
127
|
+
end
|
128
|
+
it "raises error when non-hash given" do
|
129
|
+
expect {
|
130
|
+
flickr.photos.getSizes []
|
131
|
+
}.to raise_error(
|
132
|
+
FlickRaw::FailedResponse,
|
133
|
+
/'flickr.photos.getSizes' - Photo not found/
|
134
|
+
)
|
135
|
+
end
|
136
|
+
it "raises error when garbage given as photo_id" do
|
137
|
+
expect {
|
138
|
+
flickr.photos.getSizes :photo_id => 'garbage'
|
139
|
+
}.to raise_error(
|
140
|
+
FlickRaw::FailedResponse,
|
141
|
+
/'flickr.photos.getSizes' - Photo not found/
|
142
|
+
)
|
143
|
+
end
|
144
|
+
it "returns photo sizes fixture when option given" do
|
145
|
+
flickr.photos.getSizes(:secret => '3c4374b19e', :photo_id => "5102817422").should == fixtures.photo_sizes
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
specify {klass.should respond_to(:stub_interestingness)}
|
150
|
+
context "stub_interestingness: stubs flickr.interestingness.getList" do
|
151
|
+
before(:each) do
|
152
|
+
klass.stub_interestingness
|
153
|
+
end
|
154
|
+
it "returns interesting fixture when no option given" do
|
155
|
+
flickr.interestingness.getList.should == fixtures.interesting_photos
|
156
|
+
end
|
157
|
+
it "returns interesting fixture with non-hash option argument" do
|
158
|
+
flickr.interestingness.getList([]).should == fixtures.interesting_photos
|
159
|
+
end
|
160
|
+
it "returns interesting fixture if hash-option with :date key provided" do
|
161
|
+
flickr.interestingness.getList(:tags => 'hello').should == fixtures.interesting_photos
|
162
|
+
end
|
163
|
+
it "raises error if invalid date provided" do
|
164
|
+
expect {
|
165
|
+
flickr.interestingness.getList(:date => 'garbage')
|
166
|
+
}.to raise_error(
|
167
|
+
FlickRaw::FailedResponse,
|
168
|
+
/Not a valid date string/
|
169
|
+
)
|
170
|
+
end
|
171
|
+
it "returns empty string if 2001-01-01 given" do
|
172
|
+
flickr.interestingness.getList(:date => '2000-01-01').should == fixtures.empty_photos
|
173
|
+
end
|
174
|
+
it "returns photo details fixture when option given" do
|
175
|
+
flickr.interestingness.getList(:date=> '2010-10-10').should == fixtures.interesting_photos
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::VERSION do
|
4
|
+
subject{APP::VERSION}
|
5
|
+
|
6
|
+
context "constants" do
|
7
|
+
context "VERSION" do
|
8
|
+
it "returns expected version number" do
|
9
|
+
expected_version = File.read(File.expand_path("../../../VERSION", __FILE__)).strip
|
10
|
+
subject.should == expected_version
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
U:OpenStruct{
|
2
|
+
pages:perpage:
|
3
|
+
total:
|
4
|
+
photo:flickr_type:empty_photos[;;; ;
|
5
|
+
;;:interesting_photos[;;; ;
|
6
|
+
;;:author_photos[;;; ;
|
7
|
+
;;;[:id:
|
8
|
+
owner:secret:server: farm:
|
9
|
+
title:
|
10
|
+
dates:
|
11
|
+
views:editability:
|
12
|
+
usage:
|
13
|
+
notes: tags:
|
14
|
+
media;:photo_sizes[
|
15
|
+
:canblog:
|
16
|
+
label:
|
17
|
+
width:height:source:url;,;
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe APP::Models::Helpers do
|
4
|
+
let(:klass) {APP::Models::Helpers}
|
5
|
+
context "class methods" do
|
6
|
+
|
7
|
+
specify {klass.should respond_to(:array_accessor_methods)}
|
8
|
+
context "array_accessor_methods" do
|
9
|
+
it "returns expected array methods" do
|
10
|
+
klass.array_accessor_methods.sort.should == [:[], :at,:fetch, :first, :last,:each,
|
11
|
+
:each_index, :reverse_each,:length, :size,
|
12
|
+
:empty?, :find_index, :index,:rindex, :collect,
|
13
|
+
:map, :select, :keep_if, :values_at].sort
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
specify {klass.should respond_to(:possible_sizes)}
|
18
|
+
context "possible_sizes" do
|
19
|
+
it "returns expected array of possible image sizes" do
|
20
|
+
klass.possible_sizes.should == [:square, :thumbnail, :small, :medium,
|
21
|
+
:medium_640, :large, :original]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|