Skip to content

Commit

Permalink
Fixing some bugs and obvious typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
grimen committed Aug 5, 2009
1 parent 750991c commit f2cb448
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.textile
Expand Up @@ -26,7 +26,7 @@ h2. Usage/Examples

Initialize:

<pre>snapper = PageGlimse.new('ec0ccd....26df') # => nil</pre>
<pre>snapper = PageGlimpse.new('ec0ccd....26df') # => nil</pre>

Tell PageGlimpse to generate a webpage thumbnail:

Expand Down
7 changes: 3 additions & 4 deletions lib/page_glimse.rb → lib/page_glimpse.rb
@@ -1,9 +1,9 @@
require 'rubygems'

gem 'httparty', '0.4.3'
gem 'httparty', '0.4.4'
require 'httparty'

class PageGlimse
class PageGlimpse

InvalidAPIKeyError = Class.new(StandardError)

Expand Down Expand Up @@ -53,7 +53,7 @@ def thumbnail_url(url, options = {})

# Get single thumbnail image (PNG).
def thumbnail(url, options = {})
response = self.class.get(thumbnail_url)
response = self.class.get(thumbnail_url(url, options))
handle_response(response)
response.body
end
Expand Down Expand Up @@ -130,7 +130,6 @@ def generate_url(*args)
params << "nothumb=#{@nothumb}" if ACTION_PARAMS[action].include?(:nothumb) && @nothumb && !@nothumb.empty?
params << "devkey=#{@devkey}" if ACTION_PARAMS[action].include?(:devkey)
query_url = "/#{action}?#{params.join('&')}"
@thumbnail_url =
end

end
23 changes: 19 additions & 4 deletions test/page_glimse_test.rb
@@ -1,17 +1,32 @@
require 'rubygems'
require 'test/unit'
require 'shoulda'

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'page_glimpse'))

class PageGlimpseTest < Test::Unit::TestCase

VALID_API_KEY = 'ec0ccd30be1b39393d19cb5f410d26df'
INVALID_API_KEY = 'ec0ccd30be1b39393d19cb5f410d26d'
INVALID_API_KEY = 'ec0ccd30be1b39393d19'

def setup
@glimpser = PageGlimpse.new(TEST_API_KEY)
@valid_glimpser = PageGlimpse.new(VALID_API_KEY)
@invalid_glimpser = PageGlimpse.new(INVALID_API_KEY)
end

should "be instanciated correctly" do
assert_instance_of PageGlimpse, @valid_glimpser
end

should "be true" do
assert true
should "work with valid api key" do
assert_equal 200, @valid_glimpser.class.get('http://google.com').code.to_i
end

should "make a snapshot of a valid webpage" do
@valid_glimpser.request!('http://google.com')
assert_not_nil @valid_glimpser.thumbnail('http://google.com', :size => :small)
end

# TODO: Write thorough tests.

end

0 comments on commit f2cb448

Please sign in to comment.