Re: [rspec-users] Problems with array mock

2007-08-07 Thread Don Petersen
Have a look at this: http://pastie.textmate.org/85317 That should work out. Don On Aug 6, 2007, at 2:04 PM, Gaston Ramos wrote: El lun, 06 de ago de 2007, a las 11:52:28 -0500, David Chelimsky dijo: On 8/6/07, Gaston Ramos [EMAIL PROTECTED] wrote: Hi everyone, I'm trying this in my

[rspec-users] Rspec controller test

2007-08-07 Thread Shaker
Great Hi to everybody! I am currently working on a project which tests the controllers using rspec. I came across some methods in the controller which do not generate any actions at all. However, they still need testing! Some of these methods do require parameters. I am wondering how I can pass

Re: [rspec-users] Rspec controller test

2007-08-07 Thread David Chelimsky
On 8/7/07, Shaker [EMAIL PROTECTED] wrote: Great Hi to everybody! I am currently working on a project which tests the controllers using rspec. I came across some methods in the controller which do not generate any actions at all. However, they still need testing! Some of these methods do

[rspec-users] stubs which yield and return

2007-08-07 Thread Scott Taylor
Is there any reason why a stub couldn't both yield and return? I'm looking for a way to mock out a class I've made named AnonymousClass: class AnonymousClass def initialize(blk) @klass = Class.new @klass.instance_eval(blk) if block_given? end def new @klass.new

Re: [rspec-users] stubs which yield and return

2007-08-07 Thread Scott Taylor
On Aug 7, 2007, at 12:54 PM, David Chelimsky wrote: On 8/7/07, Scott Taylor [EMAIL PROTECTED] wrote: Is there any reason why a stub couldn't both yield and return? Yes. Nobody ever asked for it :) Again - this simply hasn't come up. Please add an RFE and feel free to submit a patch.

[rspec-users] Problems with raising errors on a mocked object

2007-08-07 Thread Eivind Uggedal
I'm trying to mock a object to raise a certain error. By doing so I get a ArgumentError on ActiveRecord's save! method: http://pastie.caboo.se/85628 I've tried to debug it but just can't seem to find what I'm doing wrong. Any help is greatly appreciated. Cheers, Eivind Uggedal

[rspec-users] and_yield + instance_eval(block)

2007-08-07 Thread Scott Taylor
I have the following code, which yields instance eval's the block given: class Foo def bar(blk) instance_eval blk end def baz yield end end The effect of this is that self is reassigned: Foo.new.bar do # here, self is the instance of Foo # created by new end

Re: [rspec-users] and_yield + instance_eval(block)

2007-08-07 Thread Scott Taylor
Duh. I should be using and_return(), not and_yield(), since I am actually returning the value of the instance eval. The method in question takes one parameter, a proc obj (as block). But how can I get a handle on that object (since it is anonymous)? Scott On Aug 7, 2007, at 9:14 PM, Scott

Re: [rspec-users] Problems with raising errors on a mocked object

2007-08-07 Thread David Chelimsky
On 8/7/07, Eivind Uggedal [EMAIL PROTECTED] wrote: I'm trying to mock a object to raise a certain error. By doing so I get a ArgumentError on ActiveRecord's save! method: http://pastie.caboo.se/85628 I've tried to debug it but just can't seem to find what I'm doing wrong. Any help is

[rspec-users] Failed to pass arguments to controller method

2007-08-07 Thread Shaker
Good morning to everyone: So weird!! I got a method called apply_settings(arg1, arg2) in the controller to be tested. In the controller spec, I of course called the method. In the controller: def apply_settings(arg1, arg2) #where arg1 is a hash, and arg2 is an array of object

Re: [rspec-users] Failed to pass arguments to controller method

2007-08-07 Thread David Chelimsky
On 8/7/07, Shaker [EMAIL PROTECTED] wrote: Good morning to everyone: So weird!! I got a method called apply_settings(arg1, arg2) in the controller to be tested. In the controller spec, I of course called the method. In the controller: def apply_settings(arg1, arg2) #where arg1

Re: [rspec-users] Problems with raising errors on a mocked object

2007-08-07 Thread Eivind Uggedal
Here you go: http://pastie.caboo.se/85876 Eivind On 8/8/07, David Chelimsky [EMAIL PROTECTED] wrote: On 8/7/07, Eivind Uggedal [EMAIL PROTECTED] wrote: I'm trying to mock a object to raise a certain error. By doing so I get a ArgumentError on ActiveRecord's save! method: