0

While developing spec tests for a Puppet module, TravisCI tests against various Ruby/Gem/Puppet versions. Often all tests work on all versions except with Ruby 1.8.7. There the tests don't even start. Instead you get an error that mentions configuration.rb:1105 and syntax error, unexpected ')'.

Here is one example:

/home/travis/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load': /home/travis/build/puppetlabs/puppetlabs-haproxy/spec/classes/haproxy_spec.rb:347: syntax error, unexpected ')' (SyntaxError)
/home/travis/build/puppetlabs/puppetlabs-haproxy/spec/classes/haproxy_spec.rb:355: syntax error, unexpected kDO_BLOCK, expecting kEND
/home/travis/build/puppetlabs/puppetlabs-haproxy/spec/classes/haproxy_spec.rb:364: syntax error, unexpected $end, expecting kEND

I've seen this on multiple projects.

How to fix this?

TomOnTime
  • 4,175
  • 4
  • 36
  • 39

1 Answers1

1

The problem is that ruby-1.8.7 was less forgiving about extra commas. If you look at the line following the one with configuration.rb:1105, it mentions a file. That is the file that has an extra comma or some other issue. In the above case, the problem is haproxy_spec.rb:355; in older Ruby the last line of a hash must omit the comma.

Here's the diff between the version that triggers the error and the version that fixes it:

         it 'should create directory /etc/haproxy' do
           subject.should contain_file('/etc/haproxy').with(
-            'ensure' => 'directory',
+            'ensure' => 'directory'
           )
         end
       end

As you'll see in the next TravisCI build, this fixed it.

TomOnTime
  • 4,175
  • 4
  • 36
  • 39