Re: [rspec-users] Mocking and specing command line (cli) execution, file operations etc. ?

2010-06-07 Thread Ben Mabey
Kristian Mandrup wrote: What are the options for creating specs for file operations, executing commands in the CLI etc.? If I build a generator or something which runs a lot of things in the command line, how do I check the results of these operations, fx mocking file system updates and/or mocki

Re: [rspec-users] How to test the assignment of current_user

2010-06-07 Thread Vinícius Baggio Fuentes
Oh yes, forgot to add that, if you do self.current_user = user, it will call your mock as expected. Sorry for the multitude of emails. 2010/6/7 Vinícius Baggio Fuentes > If current_user is an instance variable (as if you did attr_accessor > :current_user), you should try: > @current_user = @us

Re: [rspec-users] How to test the assignment of current_user

2010-06-07 Thread Vinícius Baggio Fuentes
If current_user is an instance variable (as if you did attr_accessor :current_user), you should try: @current_user = @user If not, you should try invoking with self: self.current_user = @user because ruby is creating a local variable named current_user instead of invoking #current_user=. When you

[rspec-users] How to test the assignment of current_user

2010-06-07 Thread Marcelo de Moraes Serpa
Hello, This could be rephrased as -- How to test calls of special assigment (setter) methods? I am trying to test the assigmnet of a user object to the current_user=(new_user) method. It is part of an authentication process and finally the object is assigned to the session through this method. I

Re: [rspec-users] mock assertions on block parameters

2010-06-07 Thread Matt Wynne
On 7 Jun 2010, at 16:52, Ben Butler-Cole wrote: > On 7 June 2010 16:34, Matt Wynne wrote: > > I'm still not quite clear what you're trying to achieve. Do you want to > assert that a specific block is passed to the collaborator, or do you want to > assert that any old block with a particular b

Re: [rspec-users] mock assertions on block parameters

2010-06-07 Thread Ben Butler-Cole
On 7 June 2010 16:34, Matt Wynne wrote: I'm still not quite clear what you're trying to achieve. Do you want to > assert that a specific block is passed to the collaborator, or do you want > to assert that any old block with a particular behaviour is passed to the > collaborator? > > If it's the

Re: [rspec-users] mock assertions on block parameters

2010-06-07 Thread Matt Wynne
On 7 Jun 2010, at 15:56, Ben Butler-Cole wrote: > On 7 June 2010 15:25, Matt Wynne wrote: > > Have you seen and_yield? I can't quite get my head around what you're trying > to do, but it might help anyway > > Thank you, I have. My understanding is that #and_yield has much the same use > as #

Re: [rspec-users] mock assertions on block parameters

2010-06-07 Thread Ben Butler-Cole
On 7 June 2010 15:25, Matt Wynne wrote: Have you seen and_yield? I can't quite get my head around what you're trying > to do, but it might help anyway > Thank you, I have. My understanding is that #and_yield has much the same use as #and_return (in its non-bastardized-by-me-form). That is, you s

Re: [rspec-users] (no subject)

2010-06-07 Thread Matt Wynne
On 7 Jun 2010, at 15:13, Ben Butler-Cole wrote: > Hello. > > I'm trying to use RSpec's mocks to describe code which passes a block to a > collaborator. I want to write an assertion against the value returned by the > block. I can't find any explicit support for this in RSpec, but perhaps I >

[rspec-users] (no subject)

2010-06-07 Thread Ben Butler-Cole
Hello. I'm trying to use RSpec's mocks to describe code which passes a block to a collaborator. I want to write an assertion against the value returned by the block. I can't find any explicit support for this in RSpec, but perhaps I have missed something. I have come up with a hack which almost d