Add dictionary controller specs and factories
This commit is contained in:
		
							
								
								
									
										22
									
								
								spec/controllers/dictionary_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								spec/controllers/dictionary_spec.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					require 'rails_helper'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RSpec.describe DictionaryController, type: :controller do
 | 
				
			||||||
 | 
					  describe "GET :index" do
 | 
				
			||||||
 | 
					    it 'renders the index template' do
 | 
				
			||||||
 | 
					      get :index
 | 
				
			||||||
 | 
					      expect(response).to render_template(:index)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    it 'sets @parts_of_speech instance variable' do
 | 
				
			||||||
 | 
					      get :index
 | 
				
			||||||
 | 
					      FactoryBot.create(:part_of_speech)
 | 
				
			||||||
 | 
					      expect(assigns(:parts_of_speech)).to be_a(ActiveRecord::Relation)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it 'sets @words instance variable' do
 | 
				
			||||||
 | 
					      get :index
 | 
				
			||||||
 | 
					      FactoryBot.create(:word)
 | 
				
			||||||
 | 
					      expect(assigns(:words)).to be_a(ActiveRecord::Relation)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										6
									
								
								spec/factories/part_of_speech.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								spec/factories/part_of_speech.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					FactoryBot.define do
 | 
				
			||||||
 | 
					  factory :part_of_speech do
 | 
				
			||||||
 | 
					    sequence(:pos) { |n| "test-#{n.to_s}" }
 | 
				
			||||||
 | 
					    definition { "test definition" }
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										5
									
								
								spec/factories/word.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								spec/factories/word.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					FactoryBot.define do
 | 
				
			||||||
 | 
					  factory :word do
 | 
				
			||||||
 | 
					    sequence(:word) { |n| "test-#{n.to_s}" }
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
		Reference in New Issue
	
	Block a user