syntax error, unexpected $end, expecting keyword_end

54,541

Solution 1

This also can happen if you have a stray . trailing a method, so check for those as well.

Solution 2

It happened to me because of special characters, in my case portuguese signs. I believe the problem is the "ü" in hinzufügen. Looking for a solution yet.

Edit: found a solution!

I added the following to the very top of the rb file:

# encoding: utf-8

(don't miss the # sign, it is needed)

Solution 3

This error due to an extra end.Mean you have written an extra end with no matching do.

Share:
54,541
mancho1981
Author by

mancho1981

Updated on July 20, 2020

Comments

  • mancho1981
    mancho1981 almost 4 years

    I am getting this error when trying to click a button with umlaut:

    syntax error, unexpected $end, expecting keyword_end
                    click_on 'Neue Firma hinzufц╪gen'
    

    I am testing with Ruby & Capabara.

    ##Create_User_spec.rb 
    require 'acceptance/acceptance_helper' 
    ## Feature 'Create User' 
    feature 'Create User' do ## 
    Scenario 'Create a User' 
    scenario 'Create a User' do 
      ## Login into the service 
      visit 'url' 
      fill_in 'User-username', :with => 'test' 
      fill_in 'User-password', :with => 'test' 
      click_on 'login' 
      click_link 'Test' 
      click_on 'Neue Firma hinzufügen' 
    end 
    end