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
Feature request: should_request expectation
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
  5 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
 
Evgeniy Dolzhenko  
View profile  
 More options Feb 23 2011, 1:45 pm
From: Evgeniy Dolzhenko <dolze...@gmail.com>
Date: Wed, 23 Feb 2011 10:45:19 -0800 (PST)
Local: Wed, Feb 23 2011 1:45 pm
Subject: Feature request: should_request expectation
Hi all,

First of all - thanks a lot to all you guys who developed
this great tool!

Now I have a simple feature request, in RSpec we could
write spec code like this:

it 'should fetch page' do
  Net::HTTP.should_receive(:get_response).with('http://example.com')
  fetch('http://example.com') # or anything else which fetches the
page
end

now if my understanding is correct with WebMock we'd
have to do something like:

it 'should fetch page' do
  stub_request(:any, "http://example.com")

  fetch('http://example.com')

  a_request(:get, "http://example.com").should_not have_been_made
end

now I would like to write this instead:

it 'should fetch page' do
  WebMock.should_request(:get, "http://example.com")
  fetch('http://example.com')
end

i.e. set up stub and expectation in the same line,
is that a reasonable feature to have? Or is it possible
to do that already?

Sincerely,
Evgeniy


 
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.
Thibaut Barrère  
View profile  
 More options Nov 22 2011, 8:22 am
From: Thibaut Barrère <thibaut.barr...@gmail.com>
Date: Tue, 22 Nov 2011 05:22:37 -0800 (PST)
Local: Tues, Nov 22 2011 8:22 am
Subject: Re: Feature request: should_request expectation

Hello!

I have exactly the same question but could not yet figure this out (I'm
only getting started with WebMock): how to stub a request and put an
expectation at the same time? Is it currently possible using a built-in
function in WebMock, or should I just use two statements or a quick helper
of mine?

Thanks for any hint,

-- Thibaut


 
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.
Evgeniy Dolzhenko  
View profile  
 More options Nov 22 2011, 8:30 am
From: Evgeniy Dolzhenko <dolze...@gmail.com>
Date: Tue, 22 Nov 2011 17:30:57 +0400
Local: Tues, Nov 22 2011 8:30 am
Subject: Re: Feature request: should_request expectation
We're using something like

stub_request(:any, //)

do_work

a_request(:get, "http://example.com/").should have_been_made

HTH,
Evgeniy

On 11/22/2011 5:22 PM, Thibaut Barrère 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 Nov 22 2011, 8:35 am
From: Bartosz Blimke <bartosz.bli...@gmail.com>
Date: Tue, 22 Nov 2011 14:35:44 +0100
Local: Tues, Nov 22 2011 8:35 am
Subject: Re: Feature request: should_request expectation

Webmock by design follows stub-execute-verify paradigm and it separates
stubs
from expectations. Each of them can be used independently.

You can however set expectations on already created stub if you want to
avoid duplication.

stub = stub_request(:get, "www.example.com")
# ... make requests ...
stub.should have_been_requested

Bartosz

2011/11/22 Thibaut Barrère <thibaut.barr...@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.
Evgeniy Dolzhenko  
View profile  
 More options Nov 22 2011, 8:37 am
From: Evgeniy Dolzhenko <dolze...@gmail.com>
Date: Tue, 22 Nov 2011 17:37:06 +0400
Local: Tues, Nov 22 2011 8:37 am
Subject: Re: Feature request: should_request expectation
Hey, that's handy, thanks!

On 11/22/2011 5:35 PM, 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.
End of messages
« Back to Discussions « Newer topic     Older topic »