Thursday, April 19, 2012

Ruby 1.9.3 hash syntax not working with rspec-rails 2.9?

I have a Rails 3.2 project I just started, and I'm trying to write some tests.

When I try to utilize Ruby 1.9.3's JSON-esque hash syntax and do this:

let(:user) { 'Joe', last_name: 'Blow') }

or this:

let(:user) {{first_name: 'Joe', last_name: 'Blow'}) }

I get this error:

syntax error, unexpected ':', expecting ')' (SyntaxError)
let(:user) { 'Joe', last_name: 'Blow') }

When I revert to the :key => 'value' syntax, rspec then looks at the user.rb file I'm requiring and says it doesn't know what is going on with the syntax present there, either.

Is there a way I can remedy this?

No comments:

Post a Comment