Error accessing input fields with cucumber + capybara

1

I was writing my steps for my tests with Cucumber and they are not finding it the ids , labels or names of the forms. I've looked at various tutorials on the internet and my problem is really strange, because in all cases the problem is always the reference, and in this case, mine is correct.

Steps (The first step works correctly)

Dado(/^que eu esteja na página de criação de eventos$/) do
   visit "/events/new"
end

Quando(/^eu prencho os dados do evento corretamente$/) do
  fill_in "event_name", :with => "Nome do Evento"
end

Part of the form that contains input

<div class="field form-group">
  <%= f.label :Evento %><br>
  <%= f.text_field :name, :class => "form-control", :required => true  %>
</div>
<div class="field form-group">
  <%= f.label :Data_Evento %><br>
  <%= f.date_select :date_event, :class => "form-control", :required => true  %>
</div>
<div class="field form-group">
  <%= f.label :Destacar_Evento? %><br>
  <%= f.check_box :detach, {}, "1", "2" %>
</div>
    
asked by anonymous 25.03.2014 / 13:38

1 answer

2

I created an environment to simulate your code here worked perfectly, see below the structure of the project:

    #./projeto/app.rb    
    #encoding: utf-8  
    require 'sinatra'

    get '/' do
      "home"
    end

    get '/events/new' do
      erb :index
    end

__END__
@@index
<!doctype html>
<html>
    <head>
    </head>
    <body>
      <form>
       <div class="field form-group">
          <label for="event_name">Event Name</label>
          <input name="event_name" id="event_name" type="text"/>
        </div>  
     </form>
  </body>
</html>

#./projeto/features/teste.feature
#language: pt
Funcionalidade: Preencher formulario
Dado que o quadro abaixo   

    Cenário:Preenchendo trecho de código
    Dado que eu esteja na página de criação de eventos
    Quando eu prencho os dados do evento corretamente

#./projeto/features/support/env.rb
#encoding: utf-8
require_relative '../../app'
require "capybara/cucumber"

Capybara.app = Sinatra::Application


#./projeto/features/step_definitions/teste_step.rb
#language: pt
Dado(/^que eu esteja na página de criação de eventos$/) do
    visit "/events/new"
end

Quando(/^eu prencho os dados do evento corretamente$/) do
  fill_in "event_name", :with => "Nome do Evento"
end

My tests were often crashing because there was not a route that worked again because the render (both rails and sinatra) did not find the variables were not located in the

25.03.2014 / 22:01