From ad08b283b032e5904171e0994a856bacaf83acdc Mon Sep 17 00:00:00 2001 From: maddiebaka Date: Sat, 14 Oct 2023 13:05:54 -0400 Subject: [PATCH] Add model specs --- spec/factories/definitions.rb | 7 +++++++ spec/models/definition_spec.rb | 8 ++++++++ spec/models/word_spec.rb | 8 ++++++++ 3 files changed, 23 insertions(+) create mode 100644 spec/factories/definitions.rb create mode 100644 spec/models/definition_spec.rb create mode 100644 spec/models/word_spec.rb diff --git a/spec/factories/definitions.rb b/spec/factories/definitions.rb new file mode 100644 index 0000000..19046f3 --- /dev/null +++ b/spec/factories/definitions.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :definition do + pos { "n" } + definition { "this is a definition" } + word_id { FactoryBot.create(:word).id } + end +end diff --git a/spec/models/definition_spec.rb b/spec/models/definition_spec.rb new file mode 100644 index 0000000..d22850f --- /dev/null +++ b/spec/models/definition_spec.rb @@ -0,0 +1,8 @@ +require 'rails_helper' + +RSpec.describe Definition, type: :model do + it "successfully creates a definition" do + definition = FactoryBot.create(:definition) + expect(Definition.count).to eq(1) + end +end diff --git a/spec/models/word_spec.rb b/spec/models/word_spec.rb new file mode 100644 index 0000000..46fb15f --- /dev/null +++ b/spec/models/word_spec.rb @@ -0,0 +1,8 @@ +require 'rails_helper' + +RSpec.describe Word, type: :model do + it "successfully creates a new word" do + word = FactoryBot.create(:word) + expect(Word.count).to eq(1) + end +end