Skip to content

Commit

Permalink
refactor: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef-Rousset committed Oct 29, 2024
1 parent 85ad39c commit 10213d8
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module Forms
end

describe "#serialize" do

let(:serialized) { subject.serialize }

it "includes the answer for each question" do
Expand All @@ -87,7 +86,7 @@ module Forms
end

serialized_files_answer = files_answer.attachments.map(&:url)

expect(serialized).to include(
"#{multichoice_question.position + 1}. #{translated(multichoice_question.body, locale: I18n.locale)}" => [multichoice_answer_choices.first.body, multichoice_answer_choices.last.body]
)
Expand All @@ -103,7 +102,6 @@ module Forms
expect(serialized).to include(
"#{files_question.position + 1}. #{translated(files_question.body, locale: I18n.locale)}" => serialized_files_answer
)

end

context "and includes the attributes" do
Expand Down Expand Up @@ -213,10 +211,9 @@ def memory_usage
end

describe "questions_hash" do

it "generates a hash of questions ordered by position" do
questions.shuffle!
expect(subject.instance_eval { questions_hash }.keys.map{|key| key[0].to_i}.uniq).to eq(questions.sort_by{|q| q.position}.map{|question| question.position + 1})
expect(subject.instance_eval { questions_hash }.keys.map { |key| key[0].to_i }.uniq).to eq(questions.sort_by(&:position).map { |question| question.position + 1 })
end
end
end
Expand Down

0 comments on commit 10213d8

Please sign in to comment.