Stubbing web call.

This commit is contained in:
Adam Williams 2012-01-19 10:08:07 -05:00
parent 7181a5a8bf
commit 50719f03a7
3 changed files with 8 additions and 4 deletions

View File

@ -23,5 +23,6 @@ bin/octopress
s.add_development_dependency('rake') s.add_development_dependency('rake')
s.add_development_dependency('rdoc') s.add_development_dependency('rdoc')
s.add_development_dependency('fakefs') s.add_development_dependency('fakefs')
s.add_development_dependency('aruba', '0.4.10') s.add_development_dependency('webmock')
s.add_development_dependency('aruba', '0.4.11')
end end

View File

@ -3,14 +3,16 @@ require 'spec_helper'
describe Octopress::Commands::Create do describe Octopress::Commands::Create do
include FakeFS::SpecHelpers include FakeFS::SpecHelpers
let(:url) { 'http://hostname.com/myfile.txt' }
let(:project_path) { File.expand_path File.join('tmp', 'create') } let(:project_path) { File.expand_path File.join('tmp', 'create') }
subject { described_class.new(project_path) } subject { described_class.new(project_path) }
it 'downloads to tmp location in project_path' do it 'downloads to tmp location in project_path' do
download_path = subject.download 'https://github.com/octopress/theme-classic/zipball/master', 'theme-classic.zip' stub_request(:get, url).to_return(body:'my file')
download_path.should == File.join(project_path, 'tmp', 'theme-classic.zip') download_path = subject.download url, 'thename.txt'
download_path.should == File.join(project_path, 'tmp', 'thename.txt')
File.exists?(download_path).should be_true File.exists?(download_path).should be_true
File.size(download_path).should > 0 File.read(download_path).should == 'my file'
end end
end end

View File

@ -1,2 +1,3 @@
require 'fakefs/spec_helpers' require 'fakefs/spec_helpers'
require 'webmock/rspec'
require 'octopress' require 'octopress'