Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
source :rubygems | ||
|
||
#gem "mechanize" | ||
gem "rest-client" | ||
gem "rest-client", :require => 'rest_client' | ||
|
||
group :test, :development do | ||
gem "minitest", :require => 'minitest/autorun' | ||
gem "webmock" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
addressable (2.3.1) | ||
crack (0.3.1) | ||
mime-types (1.19) | ||
minitest (3.2.0) | ||
rest-client (1.6.7) | ||
mime-types (>= 1.16) | ||
webmock (1.8.7) | ||
addressable (>= 2.2.7) | ||
crack (>= 0.1.7) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
minitest | ||
rest-client | ||
webmock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "rubygems" | ||
require "bundler/setup" | ||
Bundler.require(:default) | ||
|
||
require "json" | ||
|
||
class ReadList | ||
attr_reader :url | ||
|
||
def self.create | ||
response = RestClient.post('http://readlists.com/api/v1/readlists/', {}.to_json, :content_type => :json, :accept => :json) | ||
|
||
raise "#{response.code} is not a 201 response" unless response.code == 201 | ||
raise "No location given" unless response.headers[:location] | ||
|
||
new({ :url => response.headers[:location] }) | ||
end | ||
|
||
def initialize(params={}) | ||
@url = params[:url] | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'minitest/autorun' | ||
require 'webmock/minitest' | ||
require './lib/readlist' | ||
|
||
class TestReadList < MiniTest::Unit::TestCase | ||
def test_creates_anonymous_readlist | ||
readlist = ReadList.new | ||
refute_nil readlist | ||
end | ||
|
||
def test_has_url | ||
stub = stub_request(:post, 'http://readlists.com/api/v1/readlists/') | ||
.with( | ||
:body => {}, | ||
:headers => {"Content-Type" => "application/json", "Accept" => "application/json"} | ||
) | ||
.to_return(:status => 201, :headers => { "Location" => "http://readlists.com/api/v1/readlists/075c62a3/"}) | ||
|
||
readlist = ReadList.create | ||
|
||
assert_requested stub | ||
assert_equal readlist.url, 'http://readlists.com/api/v1/readlists/075c62a3/' | ||
end | ||
end |