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
Need help testing response status codes
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
 
Ray  
View profile  
 More options May 9 2012, 7:43 am
From: Ray <ticktricktr...@gmail.com>
Date: Wed, 9 May 2012 04:43:48 -0700 (PDT)
Local: Wed, May 9 2012 7:43 am
Subject: Need help testing response status codes
I have had no luck at all to get any useful behaviour out of WebMock.
Here is what I have in my Specs.

stub_request(:get, "https://example.com/some_name").
  to_return(:status => 503, :body => "", :headers => {})

response = HTTParty.get( "https://example.com/some_name" )
=> nil

response = Net::HTTP.get(URI.parse("https://example.com/some_name")
=> ""
response.class
=> String

Environment:
Rails 3.2.3, Ruby 1.9.3-p125, OS X, Webmock '1.8.6'


 
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.
Pete Higgins  
View profile  
 More options May 9 2012, 11:15 am
From: Pete Higgins <p...@peterhiggins.org>
Date: Wed, 9 May 2012 08:15:17 -0700
Local: Wed, May 9 2012 11:15 am
Subject: Re: Need help testing response status codes

What version of HTTParty are you using? With the latest release of it and
Webmock I am not seeing the same behavior:

$ irb

>> require 'webmock'
=> true
>> include WebMock::API
=> Object
>> require 'httparty'
=> true
>> stub_request(:get, "https://example.com/some_name").to_return(:status =>

503, :body => "", :headers => {})
=> GET https:examplecomsome_name
>> response = HTTParty.get("https://example.com/some_name")

=> #<HTTParty::Response:0x8 parsed_response=nil,
@response=#<Net::HTTPServiceUnavailable 503  readbody=true>, headers{}
>> response.class

=> HTTParty::Response
>> WebMock::VERSION
=> "1.8.6"
>> HTTParty::VERSION

=> "0.8.3"

pete


 
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.
Ray  
View profile  
 More options May 9 2012, 11:32 am
From: Ray <ticktricktr...@gmail.com>
Date: Wed, 9 May 2012 08:32:29 -0700 (PDT)
Local: Wed, May 9 2012 11:32 am
Subject: Re: Need help testing response status codes
I'm using gem 'httparty', '0.8.3'
gem 'webmock', '1.8.6', :group => :test

It runs fine in IRB, but not in RAILS_ENV=test rails console.

I'm guessing it's either a conflict with another gem or possibly a
load order issue.
I created a blank rails project and I'm trying to home in on the error
source.

On May 9, 4:15 pm, Pete Higgins <p...@peterhiggins.org> 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.
Ray  
View profile  
 More options May 9 2012, 12:35 pm
From: Ray <ticktricktr...@gmail.com>
Date: Wed, 9 May 2012 09:35:55 -0700 (PDT)
Local: Wed, May 9 2012 12:35 pm
Subject: Re: Need help testing response status codes
I have figured the culprit, but I don't have a solution yet.

Try running that again and using pry instead of irb.

On May 9, 4:15 pm, Pete Higgins <p...@peterhiggins.org> 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.
Ray  
View profile  
 More options May 9 2012, 1:25 pm
From: Ray <ticktricktr...@gmail.com>
Date: Wed, 9 May 2012 10:25:45 -0700 (PDT)
Local: Wed, May 9 2012 1:25 pm
Subject: Re: Need help testing response status codes
Removing pry from the gem file makes it work in the Rails console,
sadly in the specs it still gives me a nil.
For now, I can't spare any more time to dwell on this.
I will come back to this issue later this month because I really want
to test against that. Maybe a better way to start would be to make the
WebMock specs fail, rather than trying to make mine pass.

On May 9, 5:35 pm, Ray <ticktricktr...@gmail.com> 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.
Ray  
View profile  
 More options May 9 2012, 1:58 pm
From: Ray <ticktricktr...@gmail.com>
Date: Wed, 9 May 2012 10:58:38 -0700 (PDT)
Local: Wed, May 9 2012 1:58 pm
Subject: Re: Need help testing response status codes
So it seems to be working,
stub_request(:any, "www.example.com").to_return(:status => [500,
"Internal Server Error"])
response = HTTParty.get( "http://www.example.com/" )

response returns nil when you ask it

response
=> nil

However, response.response is still there, it's just a matter of
output, the underlying stuff is still working. Man, not one of my most
productive days. I will put some more time into this when I can, at
least I can use WebMock, so for now I'm happy.

Ray

On May 9, 6:25 pm, Ray <ticktricktr...@gmail.com> 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 »