Capybara :: Element not found

I am working with the Rspec book as it is developing the "showtime" rails application that provides information about movies. As far as I can tell, I have copied the code exactly (the book is not that good, allowing readers to know every step to take), but I am getting this error.

Unable to find select box "Release Year" (Capybara::ElementNotFound)
      ./features/step_definitions/movie_steps.rb:6:in `/^I create a movie Caddyshack in the Comedy genre$/'

      

The movie_steps.rb file has this code that provides users with a select box to select a release year that Capybara cannot find.

#---
When /^I create a movie Caddyshack in the Comedy genre$/ do
  visit movies_path
  click_link "Add Movie"
  fill_in "Title", :with => "Caddyshack"
  select "1980", :from => "Release Year"
  check "Comedy"
  click_button "Save"
end

Then /^Caddyshack should be in the Comedy genre$/ do
  visit genres_path
  click_link "Comedy"
  response.should contain("1 movie")
  response.should contain("Caddyshack")
end

      

In movie view I have this code, which as far as I can tell I need to implement a select box.

<%= form_for @movie do |f| %>
  <%= f.label :title %>
  <%= f.text_field :title %>
  <%= f.label :release_year %>
  <%= f.select :release_year, (1900..2009).to_a.map(&:to_s) %>
  <% @genres.each do |genre| %>
    <label>
      <%=h genre.name %>
      <%= check_box_tag "genres[]", genre.id %>
    </label>
  <% end %>
  <%= f.submit "Save" %>
<% end %>

      

I would be grateful for any suggestions you could provide.

+3


source to share


1 answer


Try it select "1980", :from => "Release year"

. If you want it to appear as "Release Year" then change your shortcut like this:

f.label :release_year, "Release Year"

      



Rails will automatically format the shortcut for you using the humanize method , but you can change it to whatever you like.

+4


source







All Articles