Skip to content

Commit

Permalink
Backfill item methods specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysonvirissimo committed Dec 22, 2023
1 parent 80fc4b4 commit 1f23d39
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/active_recall/item_methods_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require "spec_helper"

describe ActiveRecall::ItemMethods do
let(:user) { User.create!(name: "Test User") }
let(:item) { Word.create!(kanji: "漢字", kana: "かんじ", translation: "Kanji") }

before do
user.words << item
end

describe "#right_answer_for!" do
it "calls right! on the corresponding item" do
expect_any_instance_of(ActiveRecall::Item).to receive(:right!).and_call_original
user.right_answer_for!(item)
end
end

describe "#wrong_answer_for!" do
it "calls wrong! on the corresponding item" do
expect_any_instance_of(ActiveRecall::Item).to receive(:wrong!).and_call_original
user.wrong_answer_for!(item)
end
end

xdescribe "#score!" do
let(:grade) { 4 }

it "calls score! on the corresponding item with the correct grade" do
expect_any_instance_of(ActiveRecall::Item).to receive(:score!).with(grade).and_call_original
user.score!(grade, item)
end
end
end

0 comments on commit 1f23d39

Please sign in to comment.