How to test block parameters which is sending to method with arguments?

Hai

I would like to know how to test block parameters send to method with
arguments…

Problem:

Here i would like to get weather report basing on city_name.

here my method name is request and i am sending :get_cities_weather
as argument to that method.

@cities_weather = request(:get_cities_weather) do

soap.body = { weather_request =>{:city_name => “Banglore” } }

end

Issue:

Here My problem is with block and i would like to know how to test
block params i.e

soap.body = { weather_request =>{:city_name => “Banglore” } }

Here i need to test soap.body key name i.e “weather_request”
wheather i am sending exact key name or not??

Could u please help me how to test it???

On Jul 16, 2011, at 8:35 AM, kevin peter wrote:

as argument to that method.

Here i need to test soap.body key name i.e “weather_request” whether i am
sending exact key name or not??

Could u please help me how to test it???

Hey Kevin,

It’s difficult to know how to go about this without more context. Would
you post the full content (https://gist.github.com or http://pastie.org
please) of the file where this code lives? If not the full file, at
least the method it is in and notes about any instance variables and/or
methods (i.e. I can guess what ‘soap’ might be in this case, but I have
no way of knowing for certain, and that will make a big difference in
how to proceed).

Thx,
David

Hi David
i have given detailed explanation about my problem. with below link
http://pastie.org/2230103
Could u please help me???

Thanks in advance

On 18 Jul 2011, at 07:04, kevin peter wrote:

Hi David
i have given detailed explanation about my problem. with below link
http://pastie.org/2230103
Could u please help me???

Thanks in advance

I had a quick look at this, and I have three bits of advice:

  1. Hire a consultant like @JBrains to come and give you and your team
    some training in how to solve these kinds of problems for yourselves
  2. Buy Michael Feathers’ “Working Effectively With Legacy Code” and read
    it.
  3. Buy Steve Freeman & Nat Pryce’s “Growing Object Oriented Software,
    Guided By Tests” and read it.

What you need to understand about here is how to create a “Seam” between
your code and the SOAP library you’re using. The reason it’s painful for
you to mock against this library is that is wasn’t designed with that in
mind. Both the Feathers book and the Freeman / Pryce book will teach you
how to do that.

cheers,
Matt


Freelance programmer & coach
Author, http://pragprog.com/books/hwcuc/the-cucumber-book (with Aslak
Hellesy)
Founder, http://relishapp.com
+44(0)7974430184 | http://twitter.com/mattwynne