Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion webmock and cucumber

Received: by 10.50.209.99 with SMTP id ml3mr1177272igc.3.1330097189243;
        Fri, 24 Feb 2012 07:26:29 -0800 (PST)
X-BeenThere: webmock-users@googlegroups.com
Received: by 10.50.77.199 with SMTP id u7ls1355325igw.3.gmail; Fri, 24 Feb
 2012 07:26:29 -0800 (PST)
Received: by 10.42.80.15 with SMTP id t15mr1085631ick.8.1330097189028;
        Fri, 24 Feb 2012 07:26:29 -0800 (PST)
Received: by 10.50.209.5 with SMTP id mi5msigc;
        Fri, 24 Feb 2012 07:25:51 -0800 (PST)
MIME-Version: 1.0
Received: by 10.52.38.231 with SMTP id j7mr224892vdk.5.1330097150792; Fri, 24
 Feb 2012 07:25:50 -0800 (PST)
Authentication-Results: ls.google.com; spf=pass (google.com: domain of
 f.rosenb...@gmail.com designates internal as permitted sender)
 smtp.mail=f.rosenb...@gmail.com; dkim=pass
 header...@gmail.com
Received: by db5g2000vbb.googlegroups.com with HTTP; Fri, 24 Feb 2012 07:25:50
 -0800 (PST)
Date: Fri, 24 Feb 2012 07:25:50 -0800 (PST)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8)
 AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11,gzip(gfe)
Message-ID: <a3c0ab07-2617-4ef4-9f4c-74620d128a9c@db5g2000vbb.googlegroups.com>
Subject: webmock and cucumber
From: Florian Rosenberg <f.rosenb...@gmail.com>
To: webmock-users <webmock-users@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

i'm having some troubles getting Webmock to work with Cucumber. I've
been using webmock with RSpec successfully and I think it is a great
framework. Now, I have some cucumber scenarios need some request
stubbing. However, for some reason, webmock doesn't "do" anything or I
may have missed something.

I have the following setup (cucumber 1.1.9 and webmock 1.8)

support/env.rb

require 'webmock/cucumber'

also tried (did not make a difference)
World(WebMock::API, WebMock::Matchers)
WebMock.disable_net_connect!

I my steps file has this:

Given /^I want to deploy a new system "([^"]*)"$/ do |arg1|

  # read json files
  creation_request_json =  File.read(File.join(File.dirname(__FILE__),
'../../data/json_files/creation_request.json'))
  creation_response_json = File.read(File.join(File.dirname(__FILE__),
'../../data/json_files/creation_response.json'))
  url = '...'

  stub_request(:post, url).
  with(:body => creation_request_json,
  :headers => {'Accept'=>'application/json',
    'Accept-Language'=>'en',
    'Authorization'=>'Basic ZGV2T3BzMTpkZXZPcHMx',
    'Content-Type'=>'application/json'}).
  to_return(:status => 201, :body => creation_response_json, :headers
=> {})

  # call out to new system

end

I'm using the same code successfully in Rspec. I invoke cucumber via
rake with the following definition:

require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |task|
  task.cucumber_opts = ["test/features"]
end

Any pointers appreciated.