Sha256: f94e985973a085dce0a693adc08ddbdbe070763cfba2fd7d6eeb861df0b03c95

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
require File.dirname(__FILE__) + '/../../lib/provisional/scm/github'

class GithubTest < Test::Unit::TestCase
  def setup
    @scm = new_scm(Provisional::SCM::Github)
  end

  def test_checkin
    stub_git_checkin do |stub|
      stub.expects(:config).with('github.user').returns('user')
      stub.expects(:config).with('github.token').returns('token')
      stub.expects(:add_remote)
      stub.expects(:push)
    end

    URI.expects(:parse).with('https://github.com/api/v2/yaml/repos/create')
    Net::HTTP.expects(:post_form).with(nil, { 'login' => 'user', 'token' => 'token', 'name' => 'name' })

    @scm.checkin
  end

  def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception
    stub_git_checkin do |stub|
      stub.expects(:config).with('github.user').returns('user')
      stub.expects(:config).with('github.token').returns('token')
    end

    URI.expects(:parse).with('https://github.com/api/v2/yaml/repos/create')
    Net::HTTP.expects(:post_form).with(nil, { 'login' => 'user', 'token' => 'token', 'name' => 'name' }).raises(Net::HTTPUnauthorized)

    assert_raise RuntimeError do
      @scm.checkin
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vigetlabs-provisional-2.1.3 test/unit/github_test.rb
vigetlabs-provisional-2.1.4 test/unit/github_test.rb
vigetlabs-provisional-2.1.5 test/unit/github_test.rb
vigetlabs-provisional-2.1.6 test/unit/github_test.rb