我的代码使用了一个before :each
块:
before :each do
@unsorted=[1,5,6,7,4,5,8,4,2,5,2]
end
it "contains an unsorted an array" do
test_array = BubbleSort.new(@unsorted)
expect(test_array.contents).to eq [1,5,6,7,4,5,8,4,2,5,2]
end
我希望before :each
代码是内联的,但使用
before :each {@unsorted=[1,5,6,7,4,5,8,4,2,5,2]}
给出:
syntax error, unexpected '{', expecting keyword_
end (SyntaxError)
我怎样才能解决这个问题?