Cucumber Error: Socket Error for Test Environment Host in REST API

Posted by tmo256 on Stack Overflow See other posts from Stack Overflow or by tmo256
Published on 2010-01-12T21:14:34Z Indexed on 2010/04/03 3:03 UTC
Read the original article Hit count: 400

Filed under:
|
|

I posted this to the Cucumber group with no replies, which makes me wonder if this is actually a cucumber issue or not. I'm pretty new to cucumber, and there are a number of things I really don't quite understand about how the cucumber environment is set up and executed within the test environment.

I have a REST API rails app I'm testing with cucumber, using the RestClient gem to generate a post to controller create action. When I run the feature with a hard-coded URL pointing to a running localhost server (my local dev server environment; replacing tickets_url with "http:// localhost/tickets" in the snippet below), my cucumber steps execute as expected. However, when the resource URL resolves to the cucumber host I'm declaring, I get a socket error exception.

getaddrinfo: nodename nor servname provided, or not known (SocketError)

From the steps file:

When /^POS Adapter sends JSON data to the Tickets resource$/ do
  ticket = {
    :ticket => {
      ...
    }
  }

  host! "test.host"
  puts tickets_url
  RestClient.post tickets_url, ticket.to_json, :content_type => :json, :accepts => :json
end

(the "puts" statement prints "http://test.host/tickets")

Using the following gems:

  • cucumber-0.6.1
  • webrat-0.6.0
  • rest-client-1.2.0

I should also say I have a similar set up in another rails app, using test.host as my host, and it seems to work fine. I'd appreciate any insight on what I might be missing in my configuration or what this could be related to.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about cucumber