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
1 parent
f6a0060
commit 51a46a7
Showing
7 changed files
with
74 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
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 +1,8 @@ | ||
require "bundler/gem_tasks" | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << 'test' | ||
t.test_files = FileList['test/**/test*.rb'] | ||
t.verbose = true | ||
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 |
---|---|---|
|
@@ -24,4 +24,8 @@ class Charge < Base | |
def refund | ||
post(:refund) | ||
end | ||
end | ||
|
||
class Token < Base | ||
path '/v1/tokens' | ||
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
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
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
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,45 @@ | ||
require 'minitest/autorun' | ||
require 'webmock/minitest' | ||
require 'nestful' | ||
|
||
WebMock.disable_net_connect! | ||
|
||
class TestResource < MiniTest::Unit::TestCase | ||
class Charge < Nestful::Resource | ||
endpoint 'http://example.com' | ||
path '/v1/charges' | ||
end | ||
|
||
def setup | ||
end | ||
|
||
def test_get | ||
stub_request(:any, 'http://example.com/v1/charges').to_return(:body => '') | ||
Charge.get | ||
assert_requested(:get, 'http://example.com/v1/charges') | ||
end | ||
|
||
def test_post | ||
stub_request(:any, 'http://example.com/v1/charges/unknown').to_return(:body => '') | ||
Charge.post 'unknown' | ||
assert_requested(:post, 'http://example.com/v1/charges/unknown') | ||
end | ||
|
||
def test_get_json | ||
stub_request(:any, 'http://example.com/v1/charges/1').to_return( | ||
:body => '{"id": 1, "amount": 2000}', | ||
:headers => {'Content-Type' => 'application/json'} | ||
) | ||
charge = Charge.find(1) | ||
assert_requested(:get, 'http://example.com/v1/charges/1') | ||
assert_equal 1, charge.id | ||
assert_equal 2000, charge.amount | ||
end | ||
|
||
def test_instance_put | ||
stub_request(:any, 'http://example.com/v1/charges/1/capture') | ||
charge = Charge.new({:id => 1}) | ||
charge.put(:capture) | ||
assert_requested(:put, 'http://example.com/v1/charges/1/capture') | ||
end | ||
end |