Sha256: 8269455f7bb92b5fc50b538d8d10e7b0db970968af758ded2760e99d616bbcd0

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

require_relative '../spec_helper'

VCR.configure do |c|
  c.cassette_library_dir = 'fixtures/vcr_cassettes'
  c.hook_into :webmock
end

describe Chicanery::Cctray do
  let(:server) do
    Chicanery::Cctray.new 'chicanery', 'https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml'
  end

  it 'should detect idle build' do
    VCR.use_cassette('idle') do
      server.jobs.should == {
        "markryall/chicanery" => {
          activity: :sleeping,
          last_build_status: :success,
          last_build_time: 1355537908,
          url: "api.travis-ci.org/markryall/chicanery",
          last_label: "48"
        }
      }
    end
  end

  it 'should detect running build' do
    VCR.use_cassette('running') do
      server.jobs.should == {
        "markryall/chicanery" => {
          activity: :building,
          last_build_status: :unknown,
          last_build_time: 0,
          url: "api.travis-ci.org/markryall/chicanery",
          last_label: "49"
        }
      }
    end
  end

  it 'should detect failed build' do
    VCR.use_cassette('broken') do
      server.jobs.should == {
        "markryall/chicanery" => {
          activity: :sleeping,
          last_build_status: :failure,
          last_build_time: 1355539280,
          url: "api.travis-ci.org/markryall/chicanery",
          last_label: "50"
        }
      }
    end
  end

  it 'should complain if there are no jobs in response' do
     VCR.use_cassette('no_projects') do
       expect{server.jobs}.to raise_error "could not find any jobs in response: [Nothing here but us chickens]"
     end
  end

  it 'should complain if it gets a non 2xx response' do
     VCR.use_cassette('redirect') do
       expect{server.jobs}.to raise_error Net::HTTPRetriableError
     end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chicanery-0.2.0 spec/chicanery/cctray_spec.rb
chicanery-0.1.9 spec/chicanery/cctray_spec.rb