这是我的DSL
animal 'Cat' do
likes :eating, :sleeping
dislikes :dogs
end
这是我的Earth.rb文件,用于评估方法:
def animal(name, &block)
animal = Animal.new(name)
animal.instance_eval(&block)
@animals << animals
end
这是我正在尝试运行的spec文件:
describe '.animal' do
context 'with correct block' do
it "creates a set of animals" do
expect(earth.animal('Cat', "likes :sugar, :cinema dislikes :dogs")).
to be something
end
end
end
传递那个无法正常工作的块会有什么方法? 谢谢!
答案 0 :(得分:1)
block = lambda do
likes :sugar, :cinema
dislikes :dogs
end
expect(earth.animal('Cat', &block)).to be something