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
webmock and cucumber
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Florian Rosenberg  
View profile  
 More options Feb 24 2012, 10:25 am
From: Florian Rosenberg <f.rosenb...@gmail.com>
Date: Fri, 24 Feb 2012 07:25:50 -0800 (PST)
Local: Fri, Feb 24 2012 10:25 am
Subject: webmock and cucumber
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bartosz Blimke  
View profile  
 More options Feb 24 2012, 10:33 am
From: Bartosz Blimke <bartosz.bli...@gmail.com>
Date: Fri, 24 Feb 2012 16:33:03 +0100
Local: Fri, Feb 24 2012 10:33 am
Subject: Re: webmock and cucumber

What do you mean by Webmock not doing anything?

Are you getting errors or is webmock not intercepting any requests at all?

What http client lib are you using?

It's difficult to say without having a code to reproduce the problem.

Bartosz

2012/2/24 Florian Rosenberg <f.rosenb...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Florian Rosenberg  
View profile  
 More options Feb 24 2012, 10:40 am
From: Florian Rosenberg <f.rosenb...@gmail.com>
Date: Fri, 24 Feb 2012 10:40:22 -0500
Local: Fri, Feb 24 2012 10:40 am
Subject: Re: webmock and cucumber

I was not very clear, sorry. I mean I don't see my requests be intercepted. I use the rest-client gem, so I presume standard Ruby HTTP libs.

In RSpec, I saw all my non-intercepted requests being printed out to the console with a suggested stubbing code. This is also not happening with Cucumber, I see all my requests going out to the actual REST resources. I'm using the same stubbing code as in my "old" RSpect tests, but I have no luck.

Is there any debug options I can try in cucumber?

--Florian

On Feb 24, 2012, at 10:33 AM, Bartosz Blimke wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bartosz Blimke  
View profile  
 More options Feb 24 2012, 10:45 am
From: Bartosz Blimke <bartosz.bli...@gmail.com>
Date: Fri, 24 Feb 2012 16:45:11 +0100
Local: Fri, Feb 24 2012 10:45 am
Subject: Re: webmock and cucumber

Weird. If WebMock is required it should reject all unstubbed requests by
default.

WebMock is enabled in the process cucumber is running right? Is it possible
you are making these requests from a separate process/server without
webmock?

Bartosz

2012/2/24 Florian Rosenberg <f.rosenb...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Florian Rosenberg  
View profile  
 More options Feb 24 2012, 11:36 am
From: Florian Rosenberg <f.rosenb...@gmail.com>
Date: Fri, 24 Feb 2012 11:36:26 -0500
Local: Fri, Feb 24 2012 11:36 am
Subject: Re: webmock and cucumber

Ouch, I guess I found the problem. I'm testing a CLI tool with cucumber and it run it in a separate process, that is why Webmock is not intercepting. Currently, I'm calling my cmd line took (based on Thor) like this:

system("#{CLI_TOOL} deploy #{@description} -c #{@cloud_id} -p #{@properties}")

The CLI tools calls out via the REST client and I would like to stub these request. Is there a way to make that happen?

Regards,
-Florian

On Feb 24, 2012, at 10:45 AM, Bartosz Blimke wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bartosz Blimke  
View profile  
 More options Feb 24 2012, 12:20 pm
From: Bartosz Blimke <bartosz.bli...@gmail.com>
Date: Fri, 24 Feb 2012 18:20:10 +0100
Local: Fri, Feb 24 2012 12:20 pm
Subject: Re: webmock and cucumber

I would test these two processes separately.

In your cucumber I'd just ensure you are correctly invoking the other
process with "system".

Then I would test the other process separately using Webmock.

Bartosz

2012/2/24 Florian Rosenberg <f.rosenb...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »