Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added expect()

  • Loading branch information...
commit 8096e25ed2b37225496b2a11a49039fc3f039bbd 1 parent 8570305
youpy authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 spec/www-favicon_spec.rb
18 spec/www-favicon_spec.rb
View
@@ -10,37 +10,41 @@
end
it "should find from link element when rel is short" do
- @favicon.stub!(:request).and_return OpenStruct.new(:body => '<html><link rel="icon" href="/favicon_shortrel.ico" /></html>')
+ @favicon.stub!(:request).and_return expect(:body => '<html><link rel="icon" href="/favicon_shortrel.ico" /></html>')
@favicon.find('http://example.com/').should == 'http://example.com/favicon_shortrel.ico'
end
it "should find from link element when rel is upcase" do
- @favicon.stub!(:request).and_return OpenStruct.new(:body => '<html><link rel="Shortcut Icon" href="/favicon_shortrel.ico" /></html>')
+ @favicon.stub!(:request).and_return expect(:body => '<html><link rel="Shortcut Icon" href="/favicon_shortrel.ico" /></html>')
@favicon.find('http://example.com/').should == 'http://example.com/favicon_shortrel.ico'
end
it "should find absolute url from link element" do
- @favicon.stub!(:request).and_return OpenStruct.new(:body => '<html><link rel="shortcut icon" href="/favicon.ico" /></html>')
+ @favicon.stub!(:request).and_return expect(:body => '<html><link rel="shortcut icon" href="/favicon.ico" /></html>')
@favicon.find('http://example.com/repos/').should == 'http://example.com/favicon.ico'
end
it "should find relative url from link element" do
- @favicon.stub!(:request).and_return OpenStruct.new(:body => '<html><link rel="shortcut icon" href="./chrome/common/trac.ico" /></html>')
+ @favicon.stub!(:request).and_return expect(:body => '<html><link rel="shortcut icon" href="./chrome/common/trac.ico" /></html>')
@favicon.find('http://example.com/repos/').should == 'http://example.com/repos/chrome/common/trac.ico'
end
it "should find from link element when href starts with http" do
- @favicon.stub!(:request).and_return OpenStruct.new(:body => '<html><link rel="shortcut icon" href="http://example.com/foo/favicon.ico" /></html>')
+ @favicon.stub!(:request).and_return expect(:body => '<html><link rel="shortcut icon" href="http://example.com/foo/favicon.ico" /></html>')
@favicon.find('http://example.com/').should == 'http://example.com/foo/favicon.ico'
end
it "should find from default path" do
- @favicon.stub!(:request).and_return(OpenStruct.new(:body => '<html></html>'), OpenStruct.new(:code => '200'))
+ @favicon.stub!(:request).and_return(expect(:body => '<html></html>'), expect(:code => '200'))
@favicon.find('http://www.example.com/').should == 'http://www.example.com/favicon.ico'
end
it "should find from default path" do
- @favicon.stub!(:request).and_return(OpenStruct.new(:body => '<html></html>'), OpenStruct.new(:code => '404'))
+ @favicon.stub!(:request).and_return(expect(:body => '<html></html>'), expect(:code => '404'))
@favicon.find('http://example.com/').should be_nil
end
end
+
+def expect(attr)
+ OpenStruct.new(attr)
+end
Please sign in to comment.
Something went wrong with that request. Please try again.