mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-20 08:34:41 +01:00
Add tests for Crono::Web
This commit is contained in:
@@ -44,6 +44,8 @@ GEM
|
||||
rack (1.6.0)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rake (10.4.2)
|
||||
rspec (3.2.0)
|
||||
rspec-core (~> 3.2.0)
|
||||
@@ -78,6 +80,7 @@ DEPENDENCIES
|
||||
byebug
|
||||
crono!
|
||||
haml
|
||||
rack-test
|
||||
rake (~> 10.0)
|
||||
rspec (~> 3.0)
|
||||
sinatra
|
||||
|
||||
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
||||
s.add_development_dependency "byebug"
|
||||
s.add_development_dependency "sinatra"
|
||||
s.add_development_dependency "haml"
|
||||
s.add_development_dependency "rack-test"
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
||||
|
||||
@@ -12,7 +12,7 @@ module Crono
|
||||
haml :dashboard, format: :html5
|
||||
end
|
||||
|
||||
get '/jobs/:id' do
|
||||
get '/job/:id' do
|
||||
@job = Crono::CronoJob.find(params[:id])
|
||||
haml :job
|
||||
end
|
||||
|
||||
32
spec/web_spec.rb
Normal file
32
spec/web_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require "spec_helper"
|
||||
require "rack/test"
|
||||
include Rack::Test::Methods
|
||||
|
||||
describe Crono::Web do
|
||||
let(:app) { Crono::Web }
|
||||
|
||||
before do
|
||||
@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
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -12,6 +12,6 @@
|
||||
%td= job.job_id
|
||||
%td= job.last_performed_at || "—"
|
||||
%td
|
||||
%a{href: url("/jobs/#{job.id}")}
|
||||
%a{href: url("/job/#{job.id}")}
|
||||
Log
|
||||
%span.glyphicon.glyphicon-menu-right
|
||||
|
||||
Reference in New Issue
Block a user