Sha256: bedaa887fee2a2f966ae46fa32fc25479a543a69e1b868fd4f7212605f01dc4a

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

module Stash
  describe Client do
    let(:client) { Client.new(host: 'git.example.com', credentials: 'foo:bar') }

    def response_with_value(params)
      {
        'values' => [params],
        'isLastPage' => true,
        'start' => 0,
        'size' => 1
      }.to_json
    end

    it 'fetches projects' do
      stub_request(:get, "foo:bar@git.example.com/rest/api/1.0/projects").to_return(body: response_with_value('key' => 'value'))
      client.projects.should == [{"key" => "value"}]
    end

    it 'fetches repositories' do
      stub_request(:get, "foo:bar@git.example.com/rest/api/1.0/projects").to_return(body: response_with_value('link' => {'url' => '/projects/foo'}))
      stub_request(:get, "foo:bar@git.example.com/rest/api/1.0/projects/foo/repos").to_return(body: response_with_value('key' => 'value'))

      client.repositories.should == [{'key' => 'value'}]
    end

    it 'fetches commits' do
      stub_request(:get, 'foo:bar@git.example.com/rest/api/1.0/repos/foo/commits?limit=100').to_return(body: response_with_value('key' => 'value'))
      client.commits_for({'link' => {'url' => '/repos/foo/browse'}}).should == [{'key' => 'value'}]
    end

    it 'respects since/until when fetching commits' do
      stub_request(:get, 'foo:bar@git.example.com/rest/api/1.0/repos/foo/commits?since=cafebabe&until=deadbeef').to_return(body: response_with_value('key' => 'value'))
      client.commits_for({'link' => {'url' => '/repos/foo/browse'}}, since: 'cafebabe', until: 'deadbeef').should == [{'key' => 'value'}]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stash-client-0.0.6 spec/stash/client_spec.rb
stash-client-0.0.5 spec/stash/client_spec.rb