Skip to content

Commit

Permalink
More coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaberer committed Jun 9, 2013
1 parent 921d6e1 commit a8731f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cinch-toolbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def Toolbox.get_html_element(url, selector, mode = :css)
else
return url.send(mode.to_sym, selector).first.content
end
rescue SocketError
rescue SocketError, RuntimeError
# Rescue for any kind of network sillyness
return nil
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cinch-toolbox/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Cinch
module Toolbox
VERSION = "0.0.5"
VERSION = "1.0.0"
end
end
15 changes: 15 additions & 0 deletions spec/cinch-toolbox_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
Cinch::Toolbox.get_html_element('http://example.com/', "//div/div[3]", :xpath).
should be_nil
end

it 'should return nil if there is a problem finding the site' do
Cinch::Toolbox.get_html_element('http://baddurl.com/', '.foo2', :css).
should be_nil
end

it 'should return the page title if there is a http => https trasition' do
Cinch::Toolbox.get_html_element('http://github.com/bhaberer/', 'title', :css).
should include 'bhaberer (Brian Haberer)'
end

it 'should return nil if there is a https => http trasition' do
Cinch::Toolbox.get_html_element('https://www.amazon.com/', 'title', :css).
should be_nil
end
end

describe 'the get_page_title method' do
Expand Down

0 comments on commit a8731f0

Please sign in to comment.