Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rspec - how to change lambda should to expect?

Tags:

ruby

rspec

I have some lambda code, e.g.

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

How can I change this to use the expect syntax?

I tried:

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

but I got:

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

and I tried

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

but got

syntax error, unexpected tIDENTIFIER, expecting '('
like image 237
Michael Durrant Avatar asked Sep 02 '26 14:09

Michael Durrant


1 Answers

You don't need those parentheses.

expect{Watir::Browser.new(mock_driver)}.to_not raise_error
like image 72
Sergio Tulentsev Avatar answered Sep 05 '26 17:09

Sergio Tulentsev