3

我有一些 lambda 代码,例如

lambda { Watir::Browser.new(mock_driver) }.should_not raise_error

如何更改它以使用期望语法?

我试过:

expect({ Watir::Browser.new(mock_driver)}).to not raise_error

但我得到了:

syntax error, unexpected '}', expecting tASSOC (SyntaxError)
...expect ({Watir::Browser.new(mock_driver)}).to not raise_error

我试过了

expect{( Watir::Browser.new(mock_driver))}.to not raise_error

但得到了

syntax error, unexpected tIDENTIFIER, expecting '('
4

1 回答 1

6

你不需要那些括号。

expect{Watir::Browser.new(mock_driver)}.to_not raise_error
于 2013-10-23T18:16:44.720 回答