Michael Durrant
Michael Durrant

Reputation: 96544

rspec (expect syntax) - syntax error, unexpected tASSOC, expecting '}'

Switching to the new expect() syntax.

getting

syntax error, unexpected tASSOC, expecting '}' (SyntaxError)

for this:

expect(subject.crumbs.last.data).to eq {:foo => :bar }

How to fix this syntax error?

Upvotes: 0

Views: 691

Answers (2)

sawa
sawa

Reputation: 168199

Another ways to fix:

expect(subject.crumbs.last.data).to eq(foo: :bar)

(Ruby 1.9+)

Upvotes: 3

Michael Durrant
Michael Durrant

Reputation: 96544

This code works (adding parentheses around the eq value) :

expect(subject.crumbs.last.data).to eq({:foo => :bar })

Upvotes: 2

Related Questions