Add rspec and request tests
This commit is contained in:
10
spec/requests/dictionary_spec.rb
Normal file
10
spec/requests/dictionary_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Dictionary", type: :request do
|
||||
describe "GET /index" do
|
||||
it 'renders the index template' do
|
||||
get "/dictionary"
|
||||
expect(response).to render_template(:index)
|
||||
end
|
||||
end
|
||||
end
|
32
spec/requests/root_spec.rb
Normal file
32
spec/requests/root_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Root path", type: :request do
|
||||
describe "GET /" do
|
||||
it "works! (now write some real specs)" do
|
||||
get root_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "logged out" do
|
||||
it "should have 'Register' link" do
|
||||
get root_path
|
||||
expect(response.body).to include("Register")
|
||||
end
|
||||
end
|
||||
|
||||
describe "logged in" do
|
||||
it "should have 'Sign Out' link" do
|
||||
sign_in FactoryBot.create(:user)
|
||||
get root_path
|
||||
expect(response.body).to include("Sign Out")
|
||||
end
|
||||
|
||||
it "should welcome user by username" do
|
||||
user = FactoryBot.create(:user)
|
||||
sign_in user
|
||||
get root_path
|
||||
expect(response.body).to include(user.username)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user