no implicit conversion from nil to integer (TypeError)

472 views
Skip to first unread message

Chuck Shriver

unread,
Dec 13, 2015, 10:47:35 PM12/13/15
to Cucumber and Cheese
Hello,

I am getting a

no implicit conversion from nil to integer (TypeError)

Are there any changes I can make to fix it? Source code and run results are below.

Thanks!!


***************** home_page.rb ***********


require_relative
'../features/support/pages/side_menu_panel'

class HomePage
include PageObject
include SideMenuPanel
page_url "http://puppies.herokuapp.com"
divs(:name, :class => 'name')
buttons(:view_detail, :value => 'View Details')

def select_puppy(name = 'Brook')
index = index_for(name)
view_detail_elements[index].click
end

private

def index_for(name)
name_elements.find_index { |the_div| the_div.text == name }
end
end


*********** Run Results *************
/Users/charlesshriver/.rvm/rubies/ruby-2.0.0-p643/bin/ruby -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/charlesshriver/.rvm/gems/ruby-2.0.0-p643/bin/cucumber /Users/charlesshriver/RubymineProjects/puppies/features/administering_puppies.feature --color -r features --format pretty
Using the default profile...
Feature: Administering puppies
As a puppy lover
I want to help puppies
So they can chew my furniture

# Background:
# Given I am on the puppy administration site
# Scenario Outline: Login
# Given I see "Please Log In"
# When I enter "<login>" in the userid field
# And I enter "<password>" in the password field
# And I click on the Login button
# Then I should see "Welcome"
# Examples:
# | login | password |
# | admin | password |
Scenario: Verify message when adoption is processed
Given I have a pending adoption for "Cheezy"
no implicit conversion from nil to integer (TypeError)
./features/home_page.rb:12:in `[]'
./features/home_page.rb:12:in `select_puppy'
./features/step_definitions/administering_puppy_steps.rb:37:in `/^I have a pending adoption for "([^"]*)"$/'
./features/administering_puppies.feature:24:in `Given I have a pending adoption for "Cheezy"'
When I process that adoption
Then I should see "Please thank Cheezy for the order!"

Failing Scenarios:
cucumber /Users/charlesshriver/RubymineProjects/puppies/features/administering_puppies.feature:23

1 scenario (1 failed)
3 steps (1 failed, 2 skipped)
0m2.209s

Process finished with exit code 1

Joseph Ours

unread,
Dec 14, 2015, 10:27:27 AM12/14/15
to Chuck Shriver, Cucumber and Cheese
Try debugging theses two lines

index = index_for(name)
view_detail_elements[index].click
Looks like index is nil, meaning it can't find the index for the name you're passing in resulting in a nil index.  Nil cannot be converted into an integer ( that's the error you're getting )


Chuck Shriver

unread,
Dec 14, 2015, 9:32:17 PM12/14/15
to Cucumber and Cheese

Thanks, this has been resolved. A key part of the resolution involved restoring
visit(HomePage)to administering_puppy_steps.rb.


Reply all
Reply to author
Forward
0 new messages