add vcr cassettes for pixiv tests

This commit is contained in:
r888888888
2013-04-30 17:35:24 -07:00
parent dc58621c28
commit 850270dafa
9 changed files with 51060 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ group :test do
gem "simplecov", :require => false gem "simplecov", :require => false
gem "pry" gem "pry"
gem "vcr" gem "vcr"
gem "webmock"
end end
group :assets do group :assets do

View File

@@ -53,6 +53,7 @@ GEM
activesupport (3.2.12) activesupport (3.2.12)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.3.4)
arel (3.0.2) arel (3.0.2)
awesome_print (1.1.0) awesome_print (1.1.0)
aws-s3 (0.6.3) aws-s3 (0.6.3)
@@ -73,6 +74,7 @@ GEM
capistrano capistrano
chronic (0.9.1) chronic (0.9.1)
coderay (1.0.9) coderay (1.0.9)
crack (0.3.2)
daemons (1.1.9) daemons (1.1.9)
delayed_job (3.0.5) delayed_job (3.0.5)
activesupport (~> 3.0) activesupport (~> 3.0)
@@ -198,6 +200,9 @@ GEM
rack rack
raindrops (~> 0.7) raindrops (~> 0.7)
vcr (2.4.0) vcr (2.4.0)
webmock (1.11.0)
addressable (>= 2.2.7)
crack (>= 0.3.2)
webrobots (0.1.1) webrobots (0.1.1)
whenever (0.8.2) whenever (0.8.2)
activesupport (>= 2.3.4) activesupport (>= 2.3.4)
@@ -240,4 +245,5 @@ DEPENDENCIES
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
unicorn unicorn
vcr vcr
webmock
whenever whenever

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -89,3 +89,9 @@ class MockMemcache
end end
MEMCACHE = MockMemcache.new MEMCACHE = MockMemcache.new
VCR.configure do |c|
c.cassette_library_dir = "test/fixtures/vcr_cassettes"
c.hook_into :webmock
c.allow_http_connections_when_no_cassette = true
end

View File

@@ -7,7 +7,9 @@ module Downloads
@source = "http://img65.pixiv.net/img/kiyoringo/21755794_p2.png" @source = "http://img65.pixiv.net/img/kiyoringo/21755794_p2.png"
@tempfile = Tempfile.new("danbooru-test") @tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path) @download = Downloads::File.new(@source, @tempfile.path)
@download.download! VCR.use_cassette("download-pixiv-manga", :record => :new_episodes) do
@download.download!
end
end end
should "instead download the big version" do should "instead download the big version" do
@@ -21,7 +23,9 @@ module Downloads
@source = "http://www.pixiv.net/member_illust.php?mode=big&illust_id=4348318" @source = "http://www.pixiv.net/member_illust.php?mode=big&illust_id=4348318"
@tempfile = Tempfile.new("danbooru-test") @tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path) @download = Downloads::File.new(@source, @tempfile.path)
@download.download! VCR.use_cassette("download-pixiv-html", :record => :new_episodes) do
@download.download!
end
end end
should "work" do should "work" do
@@ -34,7 +38,9 @@ module Downloads
@source = "http://img02.pixiv.net/img/wanwandoh/4348318_m.jpg" @source = "http://img02.pixiv.net/img/wanwandoh/4348318_m.jpg"
@tempfile = Tempfile.new("danbooru-test") @tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path) @download = Downloads::File.new(@source, @tempfile.path)
@download.download! VCR.use_cassette("download-pixiv-small", :record => :new_episodes) do
@download.download!
end
end end
should "instead download the original version" do should "instead download the original version" do

View File

@@ -6,8 +6,9 @@ module Sources
class PixivTest < ActiveSupport::TestCase class PixivTest < ActiveSupport::TestCase
context "The source site for pixiv" do context "The source site for pixiv" do
setup do setup do
@site = Sources::Site.new("http://www.pixiv.net/member_illust.php?mode=big&illust_id=9646484") VCR.use_cassette("source-pixiv-unit-test", :record => :new_episodes) do
@site.get @site = Sources::Site.new("http://www.pixiv.net/member_illust.php?mode=big&illust_id=9646484")
end
end end
should "get the profile" do should "get the profile" do