Florian Rosenberg
unread,Feb 24, 2012, 10:25:50 AM2/24/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to webmock-users
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.