Added some more unit tests
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,17 +1,18 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../spec_helper'
|
require_relative '../spec_helper'
|
||||||
|
require_relative '../../src/models/benchmark'
|
||||||
|
|
||||||
RSpec.describe(BenchmarkController) do
|
RSpec.describe(BenchmarkController) do
|
||||||
# /benchmark - redirects to /benchmark/list
|
# GET /benchmark - redirects to /benchmark/list
|
||||||
describe 'GET /benchmark' do
|
describe 'GET /benchmark' do
|
||||||
before { get '/benchmark' }
|
before { get '/benchmark' }
|
||||||
|
|
||||||
it 'Benchmark base route is a redirect' do
|
it 'Benchmark base route is a redirect.' do
|
||||||
expect(last_response).to(be_redirect)
|
expect(last_response).to(be_redirect)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Benchmark base route is an HTML response' do
|
it 'Benchmark base route is an HTML response.' do
|
||||||
expect(last_response['Content-Type']).to(include('text/html'))
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ RSpec.describe(BenchmarkController) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# /benchmark/list - displays a table of benchmarks
|
# GET /benchmark/list - displays a table of benchmarks
|
||||||
describe 'GET /benchmark/list' do
|
describe 'GET /benchmark/list' do
|
||||||
before { get '/benchmark/list' }
|
before { get '/benchmark/list' }
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ RSpec.describe(BenchmarkController) do
|
|||||||
expect(last_response).to(be_ok)
|
expect(last_response).to(be_ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Benchmark list page is an HTML response' do
|
it 'Benchmark list page is an HTML response.' do
|
||||||
expect(last_response['Content-Type']).to(include('text/html'))
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ RSpec.describe(BenchmarkController) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# /benchmark/add - form for adding benchmark
|
# GET /benchmark/add - form for adding benchmark
|
||||||
describe 'GET /benchmark/add' do
|
describe 'GET /benchmark/add' do
|
||||||
before { get '/benchmark/add' }
|
before { get '/benchmark/add' }
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ RSpec.describe(BenchmarkController) do
|
|||||||
expect(last_response).to(be_ok)
|
expect(last_response).to(be_ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Benchmark add page is an HTML response' do
|
it 'Benchmark add page is an HTML response.' do
|
||||||
expect(last_response['Content-Type']).to(include('text/html'))
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,4 +54,64 @@ RSpec.describe(BenchmarkController) do
|
|||||||
expect(last_response.body).to(include('Add new benchmark'))
|
expect(last_response.body).to(include('Add new benchmark'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# POST /benchmark/add - backend for adding a benchmark
|
||||||
|
describe 'POST /benchmark/add' do
|
||||||
|
before do
|
||||||
|
request_data = {
|
||||||
|
benchmark_name: 'Test Benchmark',
|
||||||
|
benchmark_scoring: 'fps',
|
||||||
|
benchmark_description: 'Benchmark for testing'
|
||||||
|
}
|
||||||
|
post '/benchmark/add', request_data
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route is a redirect.' do
|
||||||
|
expect(last_response).to(be_redirect)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route is an HTML response.' do
|
||||||
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route Location header points to /benchmark/1' do
|
||||||
|
expect(last_response['Location']).to(eq("#{BASE_URL}/benchmark/1"))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route creates new Benchmark.' do
|
||||||
|
expect(Benchmark.count).to(eq(1))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route created benchmark has name.' do
|
||||||
|
expect(Benchmark.first.name).to(eq('Test Benchmark'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route created benchmark has scoring type.' do
|
||||||
|
expect(Benchmark.first.scoring).to(eq('fps'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark add POST route created benchmark has description.' do
|
||||||
|
expect(Benchmark.first.description).to(eq('Benchmark for testing'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /benchmark/:benchmark_id - page for viewing a benchmark model
|
||||||
|
describe 'GET /benchmark/:benchmark_id' do
|
||||||
|
before do
|
||||||
|
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
|
||||||
|
get "/benchmark/#{@benchmark.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark view page returns 200.' do
|
||||||
|
expect(last_response).to(be_ok)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark view page is an HTML response' do
|
||||||
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Benchmark view page contains "Add new benchmark" on page.' do
|
||||||
|
expect(last_response.body).to(include("#{@benchmark.name}"))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../spec_helper'
|
require_relative '../spec_helper'
|
||||||
|
require_relative '../../src/models/hardware'
|
||||||
|
|
||||||
RSpec.describe(HardwareController) do
|
RSpec.describe(HardwareController) do
|
||||||
# /hardware - redirects to /hardware/list
|
# GET /hardware - redirects to /hardware/list
|
||||||
describe 'GET /hardware' do
|
describe 'GET /hardware' do
|
||||||
before { get '/hardware' }
|
before { get '/hardware' }
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ RSpec.describe(HardwareController) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# /hardware/list - displays a table of hardwares
|
# GET /hardware/list - displays a table of hardwares
|
||||||
describe 'GET /hardware/list' do
|
describe 'GET /hardware/list' do
|
||||||
before { get '/hardware/list' }
|
before { get '/hardware/list' }
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ RSpec.describe(HardwareController) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# /hardware/add - form for adding hardware
|
# GET /hardware/add - form for adding hardware
|
||||||
describe 'GET /hardware/add' do
|
describe 'GET /hardware/add' do
|
||||||
before { get '/hardware/add' }
|
before { get '/hardware/add' }
|
||||||
|
|
||||||
@@ -53,4 +54,59 @@ RSpec.describe(HardwareController) do
|
|||||||
expect(last_response.body).to(include('Add new hardware'))
|
expect(last_response.body).to(include('Add new hardware'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# POST /hardware/add - backend for adding a hardware component
|
||||||
|
describe 'POST /hardware/add' do
|
||||||
|
before do
|
||||||
|
request_data = {
|
||||||
|
hardware_name: 'Test Hardware',
|
||||||
|
hardware_type: 'gpu',
|
||||||
|
}
|
||||||
|
post '/hardware/add', request_data
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware add POST route is a redirect.' do
|
||||||
|
expect(last_response).to(be_redirect)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware add POST route is an HTML response.' do
|
||||||
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware add POST route Location header points to /hardware/1' do
|
||||||
|
expect(last_response['Location']).to(eq("#{BASE_URL}/hardware/1"))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware add POST route creates new Hardware.' do
|
||||||
|
expect(Hardware.count).to(eq(1))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware add POST route created hardware has name.' do
|
||||||
|
expect(Hardware.first.name).to(eq('Test Hardware'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware add POST route created hardware has type.' do
|
||||||
|
expect(Hardware.first.type).to(eq('gpu'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /hardware/:hardware_id - page for viewing a hardware model
|
||||||
|
describe 'GET /hardware/:hardware_id' do
|
||||||
|
before do
|
||||||
|
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||||
|
get "/hardware/#{@hardware.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware view page returns 200.' do
|
||||||
|
expect(last_response).to(be_ok)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware view page is an HTML response' do
|
||||||
|
expect(last_response['Content-Type']).to(include('text/html'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Hardware view page contains "Add new hardware" on page.' do
|
||||||
|
expect(last_response.body).to(include("#{@hardware.name}"))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
require_relative '../spec_helper'
|
require_relative '../spec_helper'
|
||||||
|
|
||||||
RSpec.describe(TestController) do
|
RSpec.describe(TestController) do
|
||||||
# /test - redirects to /test/list
|
# GET /test - redirects to /test/list
|
||||||
describe 'GET /test' do
|
describe 'GET /test' do
|
||||||
before { get '/test' }
|
before { get '/test' }
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ RSpec.describe(TestController) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# /test/list - displays a table of tests
|
# GET /test/list - displays a table of tests
|
||||||
describe 'GET /test/list' do
|
describe 'GET /test/list' do
|
||||||
before { get '/test/list' }
|
before { get '/test/list' }
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ RSpec.describe(TestController) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# /test/add - form for adding test
|
# GET /test/add - form for adding test
|
||||||
describe 'GET /test/add' do
|
describe 'GET /test/add' do
|
||||||
before { get '/test/add' }
|
before { get '/test/add' }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user