Unexpected KENSURE awaiting $ end - Rails / Cucumber / Haml

There was a problem with Rails / Cucumber / Haml. The following Haml file works fine in the development environment and in real time, but in Cucumber it does not work with the following error:

/app/views/competitions/show.haml:30: syntax error, unexpected kENSURE, expecting $end (ActionView::TemplateError)
On line #30 of app/views/competitions/show.haml

Line number 30 is the end of the file. It works in Ham.3 version 2.2.3, but not in later versions (I tried 2.2.23, 2.2.22, 2.2.17)

- title @competition.name

%h1
  =h @competition.name

- if @competition.image?
  #main_image
    = image_tag(@competition.image_url)

= RedCloth.new(@competition.description).to_html

%h2
  =h @competition.question

%p 
  - if @competition.running?
    = link_to 'Enter competition', enter_path(:id => @competition.secret)
  - else
    = case @competition.state
      - when 'scheduled' then 'Competition has not opened'
      - when 'closed' then 'Competition closed'

if can? :update, @competition
  = link_to 'Edit', edit_competition_path(@competition)
  |

- if can? :show_stats, @competition
  = link_to 'View stats', competition_stats_path(@competition)

Any ideas what is going on?

+3
source share
1 answer

In my experience with cucumber + haml, this kind of thing is most often caused by ambiguity in the method call and haml, which lose track of the area in conditional expressions. Try copying parentheses around all of your methods.

if -.

when case , haml , -.

Rails ?

0

Source: https://habr.com/ru/post/1742181/


All Articles