Permalink
Browse files

use VCR to record API requests

  • Loading branch information...
1 parent f5a4191 commit 2514384ef469cda1a563888ce7f73b8eba8de4fe @quadule committed Mar 12, 2012
View
@@ -11,10 +11,15 @@ group :assets do
end
group :development, :test do
- gem 'capybara'
gem 'rspec-rails'
end
+group :test do
+ gem 'capybara'
+ gem 'vcr'
+ gem 'webmock'
+end
+
gem 'activerecord-mysql2spatial-adapter'
gem 'face'
gem 'geokit'
View
@@ -50,6 +50,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
+ crack (0.3.1)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
@@ -159,6 +160,10 @@ GEM
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ vcr (2.0.0)
+ webmock (1.8.2)
+ addressable (>= 2.2.7)
+ crack (>= 0.1.7)
xpath (0.1.4)
nokogiri (~> 1.3)
@@ -179,3 +184,5 @@ DEPENDENCIES
sass-rails (~> 3.2.3)
sqlite3
uglifier (>= 1.0.3)
+ vcr
+ webmock

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe InstagramSearch do
+describe InstagramSearch, :vcr => true do
let!(:instagram) { InstagramSearch.new.at }
it "returns a hash" do
View
@@ -1,17 +1,21 @@
require 'spec_helper'
-describe Person do
+describe Person, :vcr => true do
describe '.api' do
subject { Person.api }
it { should respond_to(:faces_detect) }
end
describe '.batch_from_photo' do
context 'using an image of two people' do
- photo = Photo.create url: "http://www.comicmix.com/wp-content/uploads/2011/02/prince-william-kate-middleton.jpg"
- subject { Person.batch_from_photo(photo) }
+ subject do
+ photo = Photo.create url: "http://www.comicmix.com/wp-content/uploads/2011/02/prince-william-kate-middleton.jpg"
+ Person.batch_from_photo photo
+ end
- it { should have(2).people }
+ it 'should have two people' do
+ should have(2).people
+ end
end
end
end
View
@@ -8,6 +8,12 @@
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+VCR.configure do |c|
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
+ c.hook_into :webmock
+ c.configure_rspec_metadata!
+end
+
RSpec.configure do |config|
# ## Mock Framework
#

0 comments on commit 2514384

Please sign in to comment.