2023-10-13 23:42:17 +00:00
|
|
|
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
|
2023-10-22 18:05:01 +00:00
|
|
|
|
|
|
|
it "renders the parts_of_speech partial" do
|
|
|
|
get "/dictionary"
|
|
|
|
expect(response).to render_template(partial: "_partsofspeech")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows the count of parts of speech in the database" do
|
|
|
|
5.times { FactoryBot.create(:part_of_speech) }
|
|
|
|
get "/dictionary"
|
|
|
|
expect(response.body).to include("#{PartOfSpeech.count} parts of speech entries in database")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows the count of words in the database" do
|
|
|
|
5.times { FactoryBot.create(:word) }
|
|
|
|
get "/dictionary"
|
|
|
|
expect(response.body).to include("#{Word.count} word entries in database")
|
|
|
|
end
|
2023-10-13 23:42:17 +00:00
|
|
|
end
|
2023-10-20 18:29:34 +00:00
|
|
|
|
|
|
|
describe "GET /show" do
|
|
|
|
it 'renders the show template' do
|
|
|
|
get "/dictionary/a"
|
|
|
|
expect(response).to render_template(:show)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sets @letter instance variable" do
|
|
|
|
get "/dictionary/a"
|
|
|
|
expect(assigns(:letter)).to be_a(String)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sets @words instance variable" do
|
|
|
|
get "/dictionary/a"
|
|
|
|
expect(assigns(:words)).to be_a(ActiveRecord::Relation)
|
|
|
|
end
|
2023-10-22 18:05:01 +00:00
|
|
|
|
|
|
|
it "renders the definitions partial" do
|
|
|
|
FactoryBot.create(:definition)
|
|
|
|
get "/dictionary/t"
|
|
|
|
expect(response).to render_template(partial: "_definitions")
|
|
|
|
end
|
2023-10-20 18:29:34 +00:00
|
|
|
end
|
2023-10-13 23:42:17 +00:00
|
|
|
end
|