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
|
||||
|
||||
require_relative '../spec_helper'
|
||||
require_relative '../../src/models/benchmark'
|
||||
|
||||
RSpec.describe(BenchmarkController) do
|
||||
# /benchmark - redirects to /benchmark/list
|
||||
# GET /benchmark - redirects to /benchmark/list
|
||||
describe 'GET /benchmark' do
|
||||
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)
|
||||
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'))
|
||||
end
|
||||
|
||||
@@ -20,7 +21,7 @@ RSpec.describe(BenchmarkController) do
|
||||
end
|
||||
end
|
||||
|
||||
# /benchmark/list - displays a table of benchmarks
|
||||
# GET /benchmark/list - displays a table of benchmarks
|
||||
describe 'GET /benchmark/list' do
|
||||
before { get '/benchmark/list' }
|
||||
|
||||
@@ -28,7 +29,7 @@ RSpec.describe(BenchmarkController) do
|
||||
expect(last_response).to(be_ok)
|
||||
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'))
|
||||
end
|
||||
|
||||
@@ -37,7 +38,7 @@ RSpec.describe(BenchmarkController) do
|
||||
end
|
||||
end
|
||||
|
||||
# /benchmark/add - form for adding benchmark
|
||||
# GET /benchmark/add - form for adding benchmark
|
||||
describe 'GET /benchmark/add' do
|
||||
before { get '/benchmark/add' }
|
||||
|
||||
@@ -45,7 +46,7 @@ RSpec.describe(BenchmarkController) do
|
||||
expect(last_response).to(be_ok)
|
||||
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'))
|
||||
end
|
||||
|
||||
@@ -53,4 +54,64 @@ RSpec.describe(BenchmarkController) do
|
||||
expect(last_response.body).to(include('Add new benchmark'))
|
||||
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
|
||||
|
Reference in New Issue
Block a user