Added some more tests; changed URLs for model list pages and added redirects
This commit is contained in:
41
spec/controllers/benchmark_controller_spec.rb
Normal file
41
spec/controllers/benchmark_controller_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../spec_helper'
|
||||
|
||||
RSpec.describe(BenchmarkController) do
|
||||
# /benchmark - redirects to /benchmark/list
|
||||
describe 'GET /benchmark' do
|
||||
before { get '/benchmark' }
|
||||
|
||||
it 'Benchmark base route redirects to /benchmark/list' do
|
||||
expect(last_response).to(be_redirect)
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/benchmark/list"))
|
||||
end
|
||||
end
|
||||
|
||||
# /benchmark/list - displays a table of benchmarks
|
||||
describe 'GET /benchmark/list' do
|
||||
before { get '/benchmark/list' }
|
||||
|
||||
it 'Benchmark list page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Benchmark list page contains 'List of benchmarks' on page." do
|
||||
expect(last_response.body).to(include('List of benchmarks'))
|
||||
end
|
||||
end
|
||||
|
||||
# /benchmark/add - form for adding benchmark
|
||||
describe 'GET /benchmark/add' do
|
||||
before { get '/benchmark/add' }
|
||||
|
||||
it 'Benchmark add page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Benchmark add page contains 'Add new benchmark' on page." do
|
||||
expect(last_response.body).to(include('Add new benchmark'))
|
||||
end
|
||||
end
|
||||
end
|
41
spec/controllers/hardware_controller_spec.rb
Normal file
41
spec/controllers/hardware_controller_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../spec_helper'
|
||||
|
||||
RSpec.describe(HardwareController) do
|
||||
# /hardware - redirects to /hardware/list
|
||||
describe 'GET /hardware' do
|
||||
before { get '/hardware' }
|
||||
|
||||
it 'Hardware base route redirects to /hardware/list' do
|
||||
expect(last_response).to(be_redirect)
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/hardware/list"))
|
||||
end
|
||||
end
|
||||
|
||||
# /hardware/list - displays a table of hardwares
|
||||
describe 'GET /hardware/list' do
|
||||
before { get '/hardware/list' }
|
||||
|
||||
it 'Hardware list page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Hardware list page contains 'List of hardware' on page." do
|
||||
expect(last_response.body).to(include('List of hardware'))
|
||||
end
|
||||
end
|
||||
|
||||
# /hardware/add - form for adding hardware
|
||||
describe 'GET /hardware/add' do
|
||||
before { get '/hardware/add' }
|
||||
|
||||
it 'Hardware add page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Hardware add page contains 'Add new hardware' on page." do
|
||||
expect(last_response.body).to(include('Add new hardware'))
|
||||
end
|
||||
end
|
||||
end
|
@@ -3,7 +3,6 @@
|
||||
require_relative '../spec_helper'
|
||||
|
||||
RSpec.describe(IndexController) do
|
||||
# / route
|
||||
describe 'GET /' do
|
||||
before { get '/' }
|
||||
|
||||
|
17
spec/controllers/reports_controller_spec.rb
Normal file
17
spec/controllers/reports_controller_spec.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../spec_helper'
|
||||
|
||||
RSpec.describe(ReportsController) do
|
||||
describe 'GET /report' do
|
||||
before { get '/report' }
|
||||
|
||||
it 'Reports page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Reports page contains 'Generate report' on page." do
|
||||
expect(last_response.body).to(include('Generate report'))
|
||||
end
|
||||
end
|
||||
end
|
41
spec/controllers/test_controller_spec.rb
Normal file
41
spec/controllers/test_controller_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../spec_helper'
|
||||
|
||||
RSpec.describe(TestController) do
|
||||
# /test - redirects to /test/list
|
||||
describe 'GET /test' do
|
||||
before { get '/test' }
|
||||
|
||||
it 'Test base route redirects to /test/list' do
|
||||
expect(last_response).to(be_redirect)
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/test/list"))
|
||||
end
|
||||
end
|
||||
|
||||
# /test/list - displays a table of tests
|
||||
describe 'GET /test/list' do
|
||||
before { get '/test/list' }
|
||||
|
||||
it 'Test list page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Test list page contains 'List of tests' on page." do
|
||||
expect(last_response.body).to(include('List of tests'))
|
||||
end
|
||||
end
|
||||
|
||||
# /test/add - form for adding test
|
||||
describe 'GET /test/add' do
|
||||
before { get '/test/add' }
|
||||
|
||||
it 'Test add page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it "Test add page contains 'Add new test' on page." do
|
||||
expect(last_response.body).to(include('Add new test'))
|
||||
end
|
||||
end
|
||||
end
|
@@ -6,6 +6,9 @@ require_relative '../src/server'
|
||||
require 'rspec'
|
||||
require 'rack/test'
|
||||
|
||||
# setting this here so all redirect tests can reference the same base URL
|
||||
BASE_URL = 'http://example.org'
|
||||
|
||||
module RSpecMixin
|
||||
|
||||
include Rack::Test::Methods
|
||||
|
Reference in New Issue
Block a user