Ruby、Rails、rspecの新機能です。私は、次の失敗を取得rpecの失敗原因を理解していませんか?
describe '#sorted_college_list_for_degrees' do
before do
stub_const("COLLEGE_AND_DEPARTMENT",
{"current_colleges_for_degrees"=>
{
"ceas"=>{"label"=>"Engineering"},
"com"=>{"label"=>"College of Medicine"},
"a&s"=>{"label"=>"Arts & Sciences"}
}
}
)
end
it "should return an array" do
expect(helper.sorted_college_list_for_degrees).to be_an(Array)
end
it "should contain all the colleges for degrees, plus 'other'" do
expect(helper.sorted_college_list_for_degrees).to eq(
['Arts & Sciences','College of Medicine','Engineering','Other']
)
end
end
describe '#sorted_college_list_for_generic_works' do
before do
stub_const("COLLEGE_AND_DEPARTMENT",
{"current_colleges_for_degrees"=>
{
"ceas"=>{"label"=>"Engineering"},
"com"=>{"label"=>"Arts & Sciences"},
},
"additional_current_colleges"=>
{
"ucl"=>{"label"=>"Libraries"},
"ucba"=>{"label"=>"Blue Ash College"},
},
}
)
end
it "should return an array" do
expect(helper.sorted_college_list_for_degrees).to be_an(Array)
end
it "should contain all the colleges for degrees, plus additional colleges, plus 'other'" do
expect(helper.sorted_college_list_for_generic_works).to eq(
['Arts & Sciences','Blue Ash College','Engineering','Libraries','Other']
)
end
エンド
:私は、私は書いていない次のコードを使用してテストを実行しています
ApplicationHelper#** sorted_college_list_for_degreesは度のために、すべての大学が含まれている必要がありますが、プラス 'その他' **エラー/エラー:(helper.sorted_college_list_for_degrees).to eq( タイプエラー: ハッシュへの暗黙的な変換なし
"RSpecの/Users/lisa/workspaces/curate/spec/helpers/curate_helper_spec.rb:257#ApplicationHelper#sorted_college_list_for_degrees度のために、すべての大学が含まれている必要があり、加えて 'その他'"
だから、私は私はエラーを理解しているか分からない。元ヘルパーファイルで、この方法があることに注意してください:事前
質問を編集して失敗した仕様のみを含むようにすると、読者はより簡単になります。 –
それを指摘していただきありがとうございます。 – LisaH