Sha256: 2d241ed23f486c0470de39e20992fed0d3e8cf6f4691b4da67675a036ca2a1c3

Contents?: true

Size: 1.95 KB

Versions: 10

Compression:

Stored size: 1.95 KB

Contents

describe DeployGate::API::V1::Push do
  describe "#upload" do
    it "success" do
      target_user = 'test'
      token = 'token'
      message = 'message'
      response = {
          :error => false,
          :because => '',
          :results => {
              :name => 'application_name',
              :user => {:name => 'user name'},
              :package_name => 'com.example.package.name',
              :revision => 1,
              :path => '/path/to/app'
          }
      }

      stub_request(:post, "#{API_ENDPOINT}/users/#{target_user}/apps").
          with(:headers => { 'AUTHORIZATION' => token }).
          to_return(:body => response.to_json)

      call_process_block = false
      results = DeployGate::API::V1::Push.upload(test_file_path, target_user, token, message, '')
      expect(results).to eq ({
                                :error => response[:error],
                                :message => response[:because],
                                :application_name => response[:results][:name],
                                :owner_name => response[:results][:user][:name],
                                :package_name => response[:results][:package_name],
                                :revision => response[:results][:revision],
                                :web_url => DeployGate::API::V1::Base::BASE_URL + response[:results][:path]
                            })
    end

    it "failed" do
      target_user = 'test'
      token = 'token'
      message = 'message'
      response = {
          :error => true,
          :because => 'error message'
      }

      stub_request(:post, "#{API_ENDPOINT}/users/#{target_user}/apps").
          with(:headers => { 'AUTHORIZATION' => token }).
          to_return(:body => response.to_json)

      results = DeployGate::API::V1::Push.upload(test_file_path, target_user, token, message, '')
      expect(results).to eq ({:error => response[:error], :message => response[:because]})
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
deploygate-0.3.1 spec/deploygate/api/v1/push_spec.rb
deploygate-0.3.0 spec/deploygate/api/v1/push_spec.rb
deploygate-0.2.3 spec/deploygate/api/v1/push_spec.rb
deploygate-0.2.2 spec/deploygate/api/v1/push_spec.rb
deploygate-0.2.1 spec/deploygate/api/v1/push_spec.rb
deploygate-0.2.0 spec/deploygate/api/v1/push_spec.rb
deploygate-0.1.2 spec/deploygate/api/v1/push_spec.rb
deploygate-0.1.1 spec/deploygate/api/v1/push_spec.rb
deploygate-0.1.0 spec/deploygate/api/v1/push_spec.rb
deploygate-0.0.6 spec/deploygate/api/v1/push_spec.rb