Skip to content

Commit b1ae977

Browse files
committed
adding VCR, hooking into typhoeus, initial simple sample tests for some RemoteTag
1 parent bb8f254 commit b1ae977

File tree

9 files changed

+137
-26
lines changed

9 files changed

+137
-26
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ gem 'geocoder'
1414
group :test do
1515
gem "turn"
1616
gem "mocha", :require => false
17+
gem "vcr"
1718
end
1819

1920
group :test, :development do

Gemfile.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ GEM
5353
metaclass (0.0.4)
5454
mime-types (1.25.1)
5555
minitest (4.7.5)
56-
minitest-rails (0.9.2)
56+
minitest-rails (1.0.1)
5757
minitest (~> 4.7)
58-
rails (>= 3.0)
58+
minitest-test (~> 1.0)
59+
railties (>= 3.0, < 4.1)
60+
minitest-test (1.1.0)
61+
minitest (~> 4.0)
5962
mocha (1.0.0)
6063
metaclass (~> 0.0.1)
6164
multi_json (1.9.2)
@@ -113,6 +116,7 @@ GEM
113116
typhoeus (0.6.8)
114117
ethon (>= 0.7.0)
115118
tzinfo (0.3.39)
119+
vcr (2.9.0)
116120

117121
PLATFORMS
118122
ruby
@@ -135,3 +139,4 @@ DEPENDENCIES
135139
swagger-docs
136140
turn
137141
typhoeus
142+
vcr

app/models/remote_tag.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def destroy_tags_for_city (city_id, tag_names = [])
4848
private
4949
def hydra
5050
@hydra ||= begin
51-
Typhoeus::Config.memoize = true
5251
Typhoeus::Hydra.new(max_concurrency: max_concurrency)
5352
end
5453
end

fixtures/vcr_cassettes/tags_bacon.yml

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/vcr_cassettes/tags_city_id_1.yml

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/cities.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/models/city_test.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/models/remote_tag_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'test_helper'
2+
3+
describe RemoteTag do
4+
describe "#find_by_city_ids" do
5+
it "has the correct number of tags for a city" do
6+
VCR.use_cassette('tags_city_id_1') do
7+
RemoteTag.find_by_city_ids([1]).must_equal []
8+
end
9+
end
10+
end
11+
12+
describe "#find_by_name" do
13+
it "finds a tag by name" do
14+
VCR.use_cassette('tags_bacon') do
15+
RemoteTag.find_by_name('bacon').name.must_equal 'bacon'
16+
end
17+
end
18+
end
19+
end

test/test_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
ENV["RAILS_ENV"] ||= "test"
22
require File.expand_path('../../config/environment', __FILE__)
33
require 'rails/test_help'
4+
require 'vcr'
5+
6+
VCR.configure do |c|
7+
c.hook_into :typhoeus
8+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
9+
c.ignore_localhost = false
10+
end
11+
412

513
class ActiveSupport::TestCase
614
ActiveRecord::Migration.check_pending!

0 commit comments

Comments
 (0)