Reputation: 102
I am trying to use capybara in my feature tests, but I keep getting the above error. However, my tests work when non Capybara functions are involved.
Here is the settings in my env.rb:
Capybara.server_host = 45454
#Capybara.server_host = host
Capybara.app_host = 'http://localhost:45454'
Capybara.default_driver = :poltergeist
PATH variable is also set for Phantomjs
Following is the steps definition file where I am facing the issue.
Given(/^I navigate to home page$/) do
visit '/'
end
And /^I take screenshot$/ do
page.save_screenshot
end
Following is the feature file
Scenario: To validate the page shows up
Given I navigate to home page
And I take screenshot
Here is the output:
Scenario: To validate the page shows up←[90m # features/home.feature:8←[0m
←[31mGiven I navigate to home page←[90m # features/step_definitions/
home_steps.rb:8←[0m←[0m
←[31m wrong argument type Fixnum (expected String) (TypeError)←[0m
←[31m ./features/step_definitions/home_steps.rb:9:in `/^I navigate to
home
page$/'←[0m
←[31m features/home.feature:9:in `Given I navigate to home page'←[0m
←[36mAnd I take screenshot←[90m # features/step_definitions/
home_steps.rb:12←[0m←[0m
←[31m wrong argument type Fixnum (expected String) (TypeError)←[0m
←[31mFailing Scenarios:←[0m
←[31mcucumber features/home.feature:8←[0m←[90m # Scenario: To validate the
page
shows up←[0m
1 scenario (←[31m1 failed←[0m)
2 steps (←[31m1 failed←[0m, ←[36m1 skipped←[0m)
0m0.649s
Upvotes: 0
Views: 310
Reputation: 49870
Capybara.server_host
needs to be the hostname/ip of an interface Capybara can bind the AUT to, not a number.
You're probably trying to set the port, which would be
Capybara.server_port = 45454
and then judging by your setting of app_host
(which probably isn't necessary) you also want to be setting
Capybara.server_host = 'localhost'
Upvotes: 1