Skip to content

Commit

Permalink
Merge pull request #11 from factor-io/addlogs#9
Browse files Browse the repository at this point in the history
Addlogs#9
  • Loading branch information
Maciej Skierkowski committed May 13, 2015
2 parents 32af905 + e638433 commit 5bf7541
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
15 changes: 14 additions & 1 deletion lib/ephemeral/client.rb
Expand Up @@ -23,15 +23,28 @@ def build(image, repo, build_type)
})
end

def getLogs(id)
resource = "builds/#{id}/logs"

get(resource)
end

private

def post(resource, options)
def post(resource, options={})
uri = gen_uri(resource)
response = RestClient.post(uri, options)
content = JSON.parse(response)
content
end

def get(resource, options={})
uri = gen_uri(resource)
response = RestClient.get(uri, options)
content = JSON.parse(response)
content
end

def gen_uri(resource)
uri = URI.parse(BASE)
uri.path = "/v1/#{resource}"
Expand Down
39 changes: 25 additions & 14 deletions spec/client_spec.rb
Expand Up @@ -5,22 +5,33 @@

describe 'Ephemeral::Client' do

it 'expects 3 arguments' do
test_client = Ephemeral::Client.new
expect{
test_client.build
}.to raise_error ArgumentError
end
describe 'build' do
it 'expects 3 arguments' do
test_client = Ephemeral::Client.new
expect{
test_client.build
}.to raise_error ArgumentError
end

it 'returns a hash' do
test_client = Ephemeral::Client.new
response = test_client.build("ruby:2.1", "https://github.com/skierkowski/hello-middleman", "middleman")
expect(response).to be_an_instance_of Hash
end

it 'returns a hash' do
test_client = Ephemeral::Client.new
response = test_client.build("ruby:2.1", "https://github.com/skierkowski/hello-middleman", "middleman")
expect(response).to be_an_instance_of Hash
it 'returns a hash which contains an id' do
test_client = Ephemeral::Client.new
response = test_client.build("ruby:2.1", "https://github.com/skierkowski/hello-middleman", "middleman")
expect(response).to have_key('id')
end
end

it 'returns a hash which contains an id' do
test_client = Ephemeral::Client.new
response = test_client.build("ruby:2.1", "https://github.com/skierkowski/hello-middleman", "middleman")
expect(response).to have_key('id')
describe 'getLogs' do
it 'returns array from id' do
# test_client = Ephemeral::Client.new
# response = test_client.build("ruby:2.1", "https://github.com/skierkowski/hello-middleman", "middleman")
# logs = test_client.getLogs(response['id'])
# expect(logs).to be_an_instance_of(Array)
end
end
end

0 comments on commit 5bf7541

Please sign in to comment.