mirror of
https://github.com/seejohnrun/haste-client.git
synced 2025-12-15 16:25:57 +00:00
Added some tests for #27
This commit is contained in:
@@ -41,10 +41,13 @@ module Haste
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def post_path
|
||||||
|
parsed_uri = URI.parse(server_url)
|
||||||
|
"#{parsed_uri.path}/documents"
|
||||||
|
end
|
||||||
|
|
||||||
def do_post(data)
|
def do_post(data)
|
||||||
posturi= URI.parse(server_url)
|
connection.post(post_path, data)
|
||||||
posturi.path += '/documents'
|
|
||||||
connection.post(posturi.path, data)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def connection
|
def connection
|
||||||
|
|||||||
@@ -126,6 +126,42 @@ describe Haste::Uploader do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe :post_path do
|
||||||
|
|
||||||
|
let(:post_path) { uploader.send(:post_path) }
|
||||||
|
|
||||||
|
context "when the server URL doesn't have a path" do
|
||||||
|
|
||||||
|
let(:base) { 'http://example.com/' }
|
||||||
|
|
||||||
|
it 'should return /documents' do
|
||||||
|
expect(post_path).to eq('/documents')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the server URL has a path" do
|
||||||
|
|
||||||
|
let(:base) { 'http://example.com/friend' }
|
||||||
|
|
||||||
|
it 'should return /documents' do
|
||||||
|
expect(post_path).to eq('/friend/documents')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the server URL has a path that ends with slash" do
|
||||||
|
|
||||||
|
let(:base) { 'http://example.com/friend/' }
|
||||||
|
|
||||||
|
it 'should return /documents appended to the path without a duplicate slash' do
|
||||||
|
expect(post_path).to eq('/friend/documents')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
describe :server_url do
|
describe :server_url do
|
||||||
|
|
||||||
let(:server_url) { uploader.server_url }
|
let(:server_url) { uploader.server_url }
|
||||||
|
|||||||
Reference in New Issue
Block a user