-1
我混淆了使用红宝石散列码格式和let
。Rspec让散列键意外=>,期待'}'
这在正常情况下工作。
{
"id" => 1,
"description" => "test 3",
"difficulty" => { "id" => 1, "description" => "easy" },
}
但let
块
这里失败的代码:
describe 'incorrect_question' do
let(:wrong_question1) {
"id" => 1,
"description" => "test 3",
"difficulty" => { "id" => 1, "description" => "easy" },
}
it 'does something' do
# ...
end
end
这导致以下情况例外:
syntax error, unexpected =>, expecting '}' (SyntaxError)
"id" => 1,
^
我认为,问题是,你需要将你的哈希移到在'..“之后加一个'{}'并移除'''easy'},' –
你的问题是什么? – sawa
顺便说一下,在代码中甚至没有''id“=> 3'。 – sawa