Sha256: 20801c0e2359e2207bcaac56bf4074628d3114aa5c5a61c1b7d3e45d78e585ae

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require File.expand_path '../test_helper.rb', __FILE__

class DeepThoughtTravisPluginTest < MiniTest::Unit::TestCase
  def setup
    DatabaseCleaner.start

    @travis_plugin = DeepThought::CIService::TravisPlugin.new
  end

  def teardown
    DatabaseCleaner.clean
  end

  def test_travis_setup_success
    @travis_plugin.setup?({"CI_SERVICE_ENDPOINT" => "endpoint"})

    assert @travis_plugin.endpoint == 'endpoint'
  end

  def test_travis_plugin_is_branch_green_success
    # successful test with CI service (I suggest stubbing the payload and mocking the API call)

    json = stub(:body => '{"branch": {"state": "passing"}}')
    HTTParty.expects(:get).with("#{@travis_plugin.endpoint}/repos/app/branches/branch").returns(json)

    assert @travis_plugin.is_branch_green?('app', 'branch', '')
  end

  def test_travis_plugin_is_branch_green_failed
    # failed test with CI service (I suggest stubbing the payload and mocking the API call)

    json = stub(:body => '{"branch": {"state": "failed"}}')
    HTTParty.expects(:get).with("#{@travis_plugin.endpoint}/repos/app/branches/branch").returns(json)

    assert !@travis_plugin.is_branch_green?('app', 'branch', 'hash')
  end

  def test_travis_plugin_is_branch_green_missing
    # failed test with CI service (I suggest stubbing the payload and mocking the API call)

    json = stub(:body => '{"branch": {"id": 123}}')
    HTTParty.expects(:get).with("#{@travis_plugin.endpoint}/repos/app/branches/branch").returns(json)

    assert !@travis_plugin.is_branch_green?('app', 'branch', 'hash')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deep_thought-travis_plugin-0.1.0 test/deep_thought_ci_service_plugin_test.rb