spec/beaker/dsl/helpers/web_helpers_spec.rb in beaker-4.39.0 vs spec/beaker/dsl/helpers/web_helpers_spec.rb in beaker-4.40.0
- old
+ new
@@ -12,11 +12,11 @@
end
describe ClassMixedWithDSLHelpers do
let( :logger ) { double("Beaker::Logger", :notify => nil , :debug => nil ) }
- let( :url ) { "http://beaker.tool" }
+ let( :url ) { "http://example.com" }
let( :name ) { "name" }
let( :destdir ) { "destdir" }
def fetch_allows
allow( subject ).to receive( :logger ) { logger }
@@ -35,19 +35,20 @@
it "returns its second and third arguments concatenated." do
concat_path = "#{destdir}/#{name}"
create_files([concat_path])
allow(logger).to receive(:notify)
- allow(subject).to receive(:open)
+ allow(URI).to receive(:open).with("#{url}/#{name}").and_return(status: 200)
result = subject.fetch_http_file url, name, destdir
expect(result).to eq(concat_path)
end
it 'doesn\'t cache by default' do
expect( logger ).to receive( :notify ).with( /^Fetching/ ).ordered
expect( logger ).to receive( :notify ).with( /^\ \ and\ saving\ to\ / ).ordered
- expect( subject ).to receive( :open )
+ allow(URI).to receive(:open).with("#{url}/#{name}").and_return(status: 200)
+ expect(URI).to receive(:open)
subject.fetch_http_file( url, name, destdir )
end
context ':cache_files_locally option is set' do
@@ -65,22 +66,24 @@
options[:cache_files_locally] = true
allow(File).to receive(:exist?).and_return(false)
expect( logger ).to receive( :notify ).with( /^Fetching/ ).ordered
expect( logger ).to receive( :notify ).with( /^\ \ and\ saving\ to\ / ).ordered
- expect( subject ).to receive( :open )
+ allow(URI).to receive(:open).with("#{url}/#{name}").and_return(status: 200)
+ expect(URI).to receive(:open)
subject.fetch_http_file( url, name, destdir )
end
end
end
describe 'given invalid arguments' do
it 'chomps correctly when given a URL ending with a / character' do
- expect( subject ).to receive( :open ).with( "#{url}/#{name}", anything )
- subject.fetch_http_file( url, name, destdir )
+ allow(URI).to receive(:open).with("#{url}/#{name}").and_return(status: 200)
+ expect( URI ).to receive( :open ).with( "#{url}/#{name}" )
+ subject.fetch_http_file( "#{url}/", name, destdir )
end
end
end