【问题标题】:syntax error, unexpected $end, expecting keyword_end语法错误,意外的 $end,预期为 keyword_end
【发布时间】:2012-03-28 10:45:55
【问题描述】:

尝试单击带有变音符号的按钮时出现此错误:

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

我正在使用 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

【问题讨论】:

  • 请显示该页面的代码..
  • 如果你正确缩进你的代码,你就更有可能自己检测到这些错误。

标签: ruby syntax-error


【解决方案1】:

如果您有一个流浪的. 跟踪方法,也会发生这种情况,因此也要检查它们。

【讨论】:

    【解决方案2】:

    它发生在我身上是因为特殊字符,在我的例子中是葡萄牙语符号。我相信问题是hinzufügen中的“ü”。还在寻找解决方案。

    编辑:找到解决方案!

    我在 rb 文件的最顶部添加了以下内容:

    #编码:utf-8

    (不要错过#号,它是必需的)

    【讨论】:

      【解决方案3】:

      这个错误是由于一个额外的结尾。意味着你写了一个没有匹配的额外结尾。

      【讨论】:

      • ##Create_User_spec.rb require 'acceptance/acceptance_helper' ## Feature 'Create User' feature 'Create User' do ## Scenario 'Create a User' 场景'Create a User' do ## Login进入服务访问 '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结束
      • Create_User_spec.rb require 'acceptance/acceptance_helper' Feature 'Create User' feature 'Create User' do end Scenario 'Create a User' 场景 'Create a User' do 登录服务访问 '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
      【解决方案4】:

      这也发生在我身上,但因为我错过了一个结局。我正在关注本教程

      http://tutorials.jumpstartlab.com/projects/blogger.html

      我的模型是:

      class ArticlesController < ApplicationController
          def index
           @articles = Article.all
          end
      

      必须是:

      class ArticlesController < ApplicationController
          def index
           @articles = Article.all
          end 
      end
      

      希望对某人有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-02
        • 1970-01-01
        相关资源
        最近更新 更多