Browse Source

Add some controller specs

pull/21/head
baarkerlounger 3 years ago
parent
commit
d01bb9f00b
  1. 6
      app/controllers/case_logs_controller.rb
  2. 41
      spec/controllers/case_logs_controller_spec.rb
  3. 0
      spec/controllers/test_controller_spec.rb
  4. 8
      spec/features/case_log_spec.rb
  5. 8
      spec/features/form_spec.rb

6
app/controllers/case_logs_controller.rb

@ -7,10 +7,4 @@ class CaseLogsController < ApplicationController
def show def show
@case_log = CaseLog.find(params[:id]) @case_log = CaseLog.find(params[:id])
end end
def edit
end
def new
end
end end

41
spec/controllers/case_logs_controller_spec.rb

@ -0,0 +1,41 @@
require "rails_helper"
RSpec.describe CaseLogsController, type: :controller do
let(:valid_session) { {} }
context "Collection routes" do
describe "GET #index" do
it "returns a success response" do
get :index, params: {}, session: valid_session
expect(response).to be_successful
end
end
describe "GET #new" do
it "returns a success response" do
get :new, params: {}, session: valid_session
expect(response).to be_successful
end
end
end
context "Instance routes" do
let!(:case_log) { FactoryBot.create(:case_log) }
let(:id) { case_log.id }
describe "GET #show" do
it "returns a success response" do
get :show, params: { id: id }
expect(response).to be_successful
end
end
describe "GET #edit" do
it "returns a success response" do
get :edit, params: { id: id }
puts response
expect(response).to be_successful
end
end
end
end

0
spec/controllers/test_controllers_spec.rb → spec/controllers/test_controller_spec.rb

8
spec/features/case_log_spec.rb

@ -4,9 +4,15 @@ RSpec.describe "Test Features" do
let(:id) { case_log.id } let(:id) { case_log.id }
let(:status) { case_log.status } let(:status) { case_log.status }
it "Displays a tasklist header" do it "displays a tasklist header" do
visit("/case_logs/342351") visit("/case_logs/342351")
expect(page).to have_content("Tasklist for log #{id}") expect(page).to have_content("Tasklist for log #{id}")
expect(page).to have_content("This submission is #{status}") expect(page).to have_content("This submission is #{status}")
end end
it "has an edit form" do
visit("/case_logs/new")
expect(page).to have_field("age")
expect(page).to have_button("Continue")
end
end end

8
spec/features/form_spec.rb

@ -1,8 +0,0 @@
require "rails_helper"
RSpec.describe "Test Features" do
it "Displays the name of the app" do
visit("/case_logs/new")
expect(page).to have_field("age")
expect(page).to have_button("Continue")
end
end
Loading…
Cancel
Save