spec/target_spec.rb in rubyretriever-1.2.4 vs spec/target_spec.rb in rubyretriever-1.3.0
- old
+ new
@@ -1,11 +1,12 @@
require 'retriever'
require 'open-uri'
-t = Retriever::Target.new('http://www.cnet.com/reviews/', /\.exe\z/)
-
describe 'Target' do
+ let(:t) do
+ Retriever::Target.new('http://www.cnet.com/reviews/', /\.exe\z/)
+ end
it 'creates target var' do
expect(t.target).to eq('http://www.cnet.com/reviews/')
end
@@ -28,17 +29,19 @@
it 'fails if given URL has no dot in it' do
expect { Retriever::Target.new('cnetcom') }.to raise_error
end
describe '#source' do
+ let(:redirecting_url) do
+ Retriever::Target.new('http://software-by-joe.appspot.com').source
+ end
it 'opens URL and returns source as String' do
expect(Retriever::Target.new('http://techcrunch.com/').source.class)
.to eq(String)
end
it 'fails if target redirects to new host' do
- expect { Retriever::Target.new('http://tinyurl.com/nkfkypa').source }
- .to raise_error
+ expect { redirecting_url }.to raise_error
end
end
end