Sha256: ce82ed84ac96d32e2f979f9716ae2e949f98c2426b87b420fa27553108616583

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'
require 'rack/test'
include Rack::Test::Methods

describe Crono::Web do
  let(:app) { Crono::Web }

  before do
    Crono::CronoJob.destroy_all
    @test_job_id = 'Perform TestJob every 5 seconds'
    @test_job_log = 'All runs ok'
    @test_job = Crono::CronoJob.create!(
      job_id: @test_job_id,
      log: @test_job_log
    )
  end

  after { @test_job.destroy }

  describe '/' do
    it 'should show all jobs' do
      get '/'
      expect(last_response).to be_ok
      expect(last_response.body).to include @test_job_id
    end

    it 'should show a error mark when a job is unhealthy' do
      @test_job.update(healthy: false)
      get '/'
      expect(last_response.body).to include 'Error'
    end
  end

  describe '/job/:id' do
    it 'should show job log' do
      get "/job/#{@test_job.id}"
      expect(last_response).to be_ok
      expect(last_response.body).to include @test_job_id
      expect(last_response.body).to include @test_job_log
    end

    it 'should show a message about the unhealthy job' do
      message = 'An error occurs during the last execution of this job'
      @test_job.update(healthy: false)
      get "/job/#{@test_job.id}"
      expect(last_response.body).to include message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crono-0.8.1 spec/web_spec.rb