flickrmocks 0.8.13 → 0.8.14

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.13
1
+ 0.8.14
data/flickrmocks.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flickrmocks}
8
- s.version = "0.8.13"
8
+ s.version = "0.8.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Takaltoo"]
12
- s.date = %q{2010-12-06}
12
+ s.date = %q{2010-12-08}
13
13
  s.description = %q{FlickrMocks makes it possible to Marshal responses
14
14
  generated from the FLickRaw gem. This is useful for
15
15
  Mocking/Stubbing the Flickr interface for testing purposes.
@@ -67,6 +67,7 @@ Gem::Specification.new do |s|
67
67
  "spec/base/stubs_spec.rb",
68
68
  "spec/base/version_spec.rb",
69
69
  "spec/fixtures/author_photos.marshal",
70
+ "spec/fixtures/commons_institution_photos.marshal",
70
71
  "spec/fixtures/commons_institutions.marshal",
71
72
  "spec/fixtures/empty_photos.marshal",
72
73
  "spec/fixtures/expected_methods.marshal",
@@ -1,9 +1,12 @@
1
1
  require 'ostruct'
2
+ require 'singleton'
2
3
 
3
4
  module FlickrMocks
4
5
  class Fixtures
6
+ include Singleton
5
7
  attr_accessor :photos,:interesting_photos,:author_photos,:photo,:photo_details,
6
- :photo_sizes,:photo_size,:expected_methods,:empty_photos,:commons_institutions
8
+ :photo_sizes,:photo_size,:expected_methods,:empty_photos,
9
+ :commons_institutions,:commons_institution_photos
7
10
 
8
11
  def initialize
9
12
  @photos = load_fixture(:photos)
@@ -17,7 +20,8 @@ module FlickrMocks
17
20
  @photo_size = load_fixture(:photo_size)
18
21
 
19
22
  @commons_institutions = load_fixture(:commons_institutions)
20
-
23
+ @commons_institution_photos = load_fixture(:commons_institution_photos)
24
+
21
25
  @empty_photos = load_fixture(:empty_photos)
22
26
 
23
27
  @expected_methods = load_fixture(:expected_methods)
@@ -9,7 +9,7 @@ module FlickrMocks
9
9
 
10
10
 
11
11
  def self.stub_search
12
- fixtures = Fixtures.new
12
+ fixtures = Fixtures.instance
13
13
  Proc.new { flickr.photos.stub(:search) do |params|
14
14
  if !params.is_a?(Hash)
15
15
  raise FlickRaw::FailedResponse.new('Parameterless searches have been disabled. Please use flickr.photos.getRecent instead.',
@@ -45,7 +45,7 @@ module FlickrMocks
45
45
  raise FlickRaw::FailedResponse.new('Photo "%s" not found (invalid ID)' % params[:photo_id],
46
46
  'code','flickr.photos.getInfo')
47
47
  else
48
- Fixtures.new.photo_details
48
+ Fixtures.instance.photo_details
49
49
  end
50
50
  end
51
51
  }.call
@@ -64,7 +64,7 @@ module FlickrMocks
64
64
  raise FlickRaw::FailedResponse.new('Photo not found',
65
65
  'code','flickr.photos.getSizes')
66
66
  else
67
- Fixtures.new.photo_sizes
67
+ Fixtures.instance.photo_sizes
68
68
  end
69
69
  end
70
70
  }.call
@@ -74,17 +74,17 @@ module FlickrMocks
74
74
  Proc.new {
75
75
  flickr.interestingness.stub(:getList) do |params|
76
76
  if !params.is_a?(Hash)
77
- Fixtures.new.interesting_photos
77
+ Fixtures.instance.interesting_photos
78
78
  elsif !params.has_key?(:date)
79
- Fixtures.new.interesting_photos
79
+ Fixtures.instance.interesting_photos
80
80
  elsif params[:date] == 'garbage'
81
81
  raise FlickRaw::FailedResponse.new('Not a valid date string',
82
82
  'code','flickr.interestingness.getList'
83
83
  )
84
84
  elsif params[:date] == '2000-01-01'
85
- Fixtures.new.empty_photos
85
+ Fixtures.instance.empty_photos
86
86
  else
87
- Fixtures.new.interesting_photos
87
+ Fixtures.instance.interesting_photos
88
88
  end
89
89
  end
90
90
  }.call
@@ -93,7 +93,7 @@ module FlickrMocks
93
93
  def self.stub_commons_institutions
94
94
  Proc.new {
95
95
  flickr.commons.stub(:getInstitutions) do
96
- Fixtures.new.commons_institutions
96
+ Fixtures.instance.commons_institutions
97
97
  end
98
98
  }.call
99
99
  end
data/spec/api/api_spec.rb CHANGED
@@ -3,13 +3,13 @@ require 'ruby-debug'
3
3
  describe APP::Api do
4
4
  let(:klass) { APP::Api }
5
5
 
6
- let(:fixtures) { APP::Fixtures.new }
7
- let(:photo) {fixtures.photo}
8
- let(:photos) {fixtures.photos}
9
- let(:sizes) {fixtures.photo_sizes}
10
- let(:photo_details) {fixtures.photo_details}
11
- let(:interesting_photos) {fixtures.interesting_photos}
12
- let(:commons_institutions) {fixtures.commons_institutions}
6
+ let(:fixtures){APP::Fixtures.instance}
7
+ let(:photo){fixtures.photo}
8
+ let(:photos){fixtures.photos}
9
+ let(:sizes){fixtures.photo_sizes}
10
+ let(:photo_details){fixtures.photo_details}
11
+ let(:interesting_photos){fixtures.interesting_photos}
12
+ let(:commons_institutions){fixtures.commons_institutions}
13
13
 
14
14
 
15
15
  context "class instance variables" do
@@ -91,4 +91,4 @@ describe APP::Api do
91
91
  end
92
92
 
93
93
  end
94
- end
94
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::Api do
4
4
  let(:klass){APP::Api}
5
- let(:fixtures){APP::Fixtures.new}
5
+ let(:fixtures){APP::Fixtures.instance}
6
6
 
7
7
  context "class methods" do
8
8
  specify {klass.should respond_to(:flickr_photos)}
@@ -4,9 +4,18 @@ require 'ruby-debug'
4
4
  describe APP::Fixtures do
5
5
 
6
6
  let(:klass) {APP::Fixtures}
7
- let(:fixtures) {APP::Fixtures.new}
7
+ let(:fixtures) {klass.instance}
8
8
  let(:subject) {fixtures}
9
-
9
+
10
+ context "singleton behavior" do
11
+ specify {klass.should respond_to(:instance)}
12
+ it "returns an instance of the fixtures class" do
13
+ klass.instance.should == fixtures
14
+ end
15
+ it "raises an error when new called" do
16
+ expect {klass.new}.to raise_error(NoMethodError)
17
+ end
18
+ end
10
19
  context "class methods" do
11
20
  specify {klass.should respond_to(:repository)}
12
21
  context "repository" do
@@ -84,6 +93,12 @@ describe APP::Fixtures do
84
93
  let(:fixture){:commons_institutions}
85
94
  it_behaves_like "a flickraw fixture"
86
95
  end
96
+
97
+ specify {subject.should respond_to(:commons_institution_photos)}
98
+ context "commons_institutions_photos" do
99
+ let(:fixture){:commons_institution_photos}
100
+ it_behaves_like "a flickraw fixture"
101
+ end
87
102
  end
88
103
 
89
104
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe APP::CustomClone do
4
- let(:fixtures){APP::Fixtures.new}
4
+ let(:fixtures){APP::Fixtures.instance}
5
5
 
6
6
  let(:photo){fixtures.photo}
7
7
  let(:photos){fixtures.photos}
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe APP::CustomCompare do
4
- let(:fixtures){APP::Fixtures.new}
4
+ let(:fixtures){APP::Fixtures.instance}
5
5
 
6
6
  let(:photo){fixtures.photo}
7
7
  let(:photos){fixtures.photos}
@@ -45,7 +45,7 @@ describe APP::CustomCompare do
45
45
  context "photos flickraw responselist" do
46
46
  let(:subject){photos}
47
47
  let(:other){photo_details}
48
-
48
+
49
49
  it_behaves_like "flickraw response for =="
50
50
 
51
51
  it "returns false when object is compared with object that is slightly different" do
@@ -62,9 +62,9 @@ describe APP::CustomCompare do
62
62
  it_behaves_like "flickraw response for =="
63
63
 
64
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
65
+ other = subject.clone
66
+ other.stub(:farm).and_return(123421)
67
+ subject.should_not == other
68
68
  end
69
69
  end
70
70
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe APP::CustomMarshal do
4
4
  let(:klass) {APP::CustomMarshal}
5
5
  let(:helpers) {APP::Helpers}
6
- let(:fixtures) {APP::Fixtures.new}
6
+ let(:fixtures) {APP::Fixtures.instance}
7
7
 
8
8
  shared_examples_for "marshalling and unmarshalling flickraw objects" do
9
9
  it "should properly marshal/unmarshal Photos object" do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::Helpers do
4
4
  let(:klass) {APP::Helpers}
5
- let(:fixtures) {APP::Fixtures.new}
5
+ let(:fixtures) {APP::Fixtures.instance}
6
6
 
7
7
  context "class methods" do
8
8
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::Stubs do
4
4
  let(:klass) {APP::Stubs}
5
- let(:fixtures) {APP::Fixtures.new}
5
+ let(:fixtures) {APP::Fixtures.instance}
6
6
 
7
7
  context "class methods" do
8
8
 
@@ -27,6 +27,7 @@ describe APP::Stubs do
27
27
  it "stubs flickr.commons.getInstitutions" do
28
28
  flickr.commons.getInstitutions.should == fixtures.commons_institutions
29
29
  end
30
+
30
31
  end
31
32
 
32
33
  specify {klass.should respond_to(:stub_search)}
Binary file
@@ -1,4 +1,4 @@
1
- U:OpenStruct{: photos[ : page:
1
+ U:OpenStruct{: photos[ : page:
2
2
  pages: perpage:
3
3
  total:
4
4
  photo:flickr_type:empty_photos[ ;;; ;
@@ -14,4 +14,5 @@ notes: tags:
14
14
  media; :photo_sizes[
15
15
  : canblog:
16
16
  label:
17
- width: height: source:url;-; :commons_institutions[:institution;
17
+ width: height: source:url;-; :commons_institutions[:institution; :commons_institution_photos[ ;;; ;
18
+ ; ;
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe APP::CommonsInstitution do
4
4
  let(:api) {APP::Api}
5
5
  let(:klass) {APP::CommonsInstitution}
6
- let(:fixtures){APP::Fixtures.new}
6
+ let(:fixtures){APP::Fixtures.instance}
7
7
  let(:fixture){fixtures.commons_institutions[0]}
8
8
  subject {klass.new(fixture)}
9
9
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe APP::CommonsInstitutions do
4
4
  let(:api) {APP::Api}
5
5
  let(:klass) {APP::CommonsInstitutions}
6
- let(:fixtures){APP::Fixtures.new}
6
+ let(:fixtures){APP::Fixtures.instance}
7
7
  let(:fixture){fixtures.commons_institutions}
8
8
  subject {klass.new(fixture)}
9
9
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::PhotoDetails do
4
4
  let(:klass){APP::PhotoDetails}
5
- let(:fixtures){APP::Fixtures.new}
5
+ let(:fixtures){APP::Fixtures.instance}
6
6
 
7
7
  let(:basic_photo) { APP::Photo.new fixtures.photo }
8
8
  let(:extended_photo) { APP::Photo.new fixtures.photo_details }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe APP::PhotoSearch do
4
4
  let(:api) {APP::Api}
5
5
  let(:klass) {APP::PhotoSearch}
6
- let(:fixtures){APP::Fixtures.new}
6
+ let(:fixtures){APP::Fixtures.instance}
7
7
  let(:options) {{:search_terms => 'iran', :page => '20', :date => '2010-10-03'}}
8
8
 
9
9
  subject { klass.new fixtures.photos,options }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::PhotoSize do
4
4
  let(:klass){APP::PhotoSize}
5
- let(:fixtures){ APP::Fixtures.new}
5
+ let(:fixtures){APP::Fixtures.instance}
6
6
  let(:size_fixture){fixtures.photo_size}
7
7
 
8
8
  subject {klass.new size_fixture}
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::PhotoSizes do
4
4
  let(:klass){APP::PhotoSizes}
5
- let(:fixtures){APP::Fixtures.new}
5
+ let(:fixtures){APP::Fixtures.instance}
6
6
 
7
7
  subject {APP::PhotoSizes.new fixtures.photo_sizes}
8
8
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe APP::Photo do
4
4
  let(:klass){APP::Photo}
5
- let(:fixtures){APP::Fixtures.new}
5
+ let(:fixtures){APP::Fixtures.instance}
6
6
  let(:basic_photo){klass.new fixtures.photo}
7
7
  let(:extended_photo){klass.new fixtures.photo_details}
8
8
 
@@ -1,10 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
-
4
3
  describe APP::Photos do
5
4
  let(:api) {APP::Api}
6
5
  let(:klass) {APP::Photos}
7
- let(:fixtures){APP::Fixtures.new}
6
+ let(:fixtures){APP::Fixtures.instance}
8
7
  let(:photos_fixture) {fixtures.photos}
9
8
  let(:interesting_photos_fixture){fixtures.interesting_photos}
10
9
 
data/spec/spec_helper.rb CHANGED
@@ -15,10 +15,8 @@ require 'shared_examples/collection'
15
15
  require 'flickrmocks'
16
16
 
17
17
  Rspec.configure do |c|
18
- # c.mock_with :mocha
19
-
18
+ # c.mock_with :mocha
20
19
  APP = FlickrMocks
21
- FlickrFixtures = APP::Fixtures.new
22
20
  end
23
21
 
24
22
 
data/tasks/fixtures.rb CHANGED
@@ -6,8 +6,9 @@ require 'ruby-debug'
6
6
  # used for providing fixtures to users of the gem
7
7
  namespace :fixtures do
8
8
  desc 'generate all fixtures for USERS of the GEM'
9
- task :all => [:photos,:empty_photos,:interesting_photos,:author_photos,:photo,:photo_details,
10
- :photo_sizes,:photo_size,:expected_methods, :commons_institutions]
9
+ task :all => [:photos,:empty_photos,:interesting_photos,:author_photos,
10
+ :photo,:photo_details,:photo_sizes,:photo_size,:expected_methods,
11
+ :commons_institutions,:commons_institution_photos]
11
12
 
12
13
  desc 'generate fixture for flickr.photos.search'
13
14
  task :photos => :repository do
@@ -64,6 +65,13 @@ namespace :fixtures do
64
65
  dump default_commons_institutions, :commons_institutions
65
66
  end
66
67
 
68
+ desc 'generate fixture for commons institution photos'
69
+ task :commons_institution_photos => :repository do
70
+ config_flickr
71
+ dump default_commons_institution_photos, :commons_institution_photos
72
+ end
73
+
74
+
67
75
  desc 'expected methods'
68
76
  task :expected_methods => :repository do
69
77
  data = OpenStruct.new
@@ -77,6 +85,7 @@ namespace :fixtures do
77
85
  data.photo_sizes = default_methods(default_photo_sizes)
78
86
  data.photo_size = default_methods(default_photo_size)
79
87
  data.commons_institutions = default_methods(default_commons_institutions)
88
+ data.commons_institution_photos = default_methods(default_commons_institution_photos)
80
89
  dump data,:expected_methods
81
90
  end
82
91
 
@@ -166,11 +175,14 @@ namespace :fixtures do
166
175
  @default_commons_institutions ||= flickr.commons.getInstitutions
167
176
  @default_commons_institutions
168
177
  end
178
+
179
+ def default_commons_institution_photos
180
+ @default_commons_institution_photos ||= flickr.photos.search :user_id => '35532303@N08', :per_page => '200', :extras=>'license'
181
+ @default_commons_institution_photos
182
+ end
169
183
 
170
184
  def default_methods(obj)
171
- obj.methods(false).push(:flickr_type)
185
+ obj.methods.include?(:flickr_type) ? obj.methods(false).push(:flickr_type) : obj.methods(false)
172
186
  end
173
-
174
-
175
187
 
176
188
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 13
9
- version: 0.8.13
8
+ - 14
9
+ version: 0.8.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - Takaltoo
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-06 00:00:00 -08:00
17
+ date: 2010-12-08 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -165,6 +165,7 @@ files:
165
165
  - spec/base/stubs_spec.rb
166
166
  - spec/base/version_spec.rb
167
167
  - spec/fixtures/author_photos.marshal
168
+ - spec/fixtures/commons_institution_photos.marshal
168
169
  - spec/fixtures/commons_institutions.marshal
169
170
  - spec/fixtures/empty_photos.marshal
170
171
  - spec/fixtures/expected_methods.marshal