mock() vs mock(Some) vs mock('some')

24 views
Skip to first unread message

beagile

unread,
Nov 5, 2012, 8:48:58 AM11/5/12
to rs...@googlegroups.com
Couldn't find a clue in the rspec-mocks documentation what the difference is... The documentation always uses the mock('some')-variant.
So is there a difference and if then what exactly?

Govinda

David Chelimsky

unread,
Nov 5, 2012, 9:14:58 AM11/5/12
to rs...@googlegroups.com
The first arg is used for documentation/reporting purposes, that's all. Doesn't matter if it's a Symbol or String. If it's not there you'll just see "mock" in the output without any clarification of which mock failed.

This is admittedly not explained perfectly clearly on http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/ExampleMethods#double-instance_method, so we'll improve that doc.

Cheers,
David


--
You received this message because you are subscribed to the Google Groups "rspec" group.
To post to this group, send email to rs...@googlegroups.com.
To unsubscribe from this group, send email to rspec+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rspec/-/CwM_iJzzXFoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

dchel...@gmail.com

unread,
Nov 5, 2012, 10:07:09 PM11/5/12
to rs...@googlegroups.com
FYI - I updated the docs here: http://rubydoc.info/github/rspec/rspec-mocks/RSpec/Mocks/ExampleMethods#double-instance_method

Won't make it to http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/ExampleMethods#double-instance_method until the next release, but that should be coming soon.

Cheers,
David

On Monday, November 5, 2012 8:15:00 AM UTC-6, dchel...@gmail.com wrote:
The first arg is used for documentation/reporting purposes, that's all. Doesn't matter if it's a Symbol or String. If it's not there you'll just see "mock" in the output without any clarification of which mock failed.

This is admittedly not explained perfectly clearly on http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/ExampleMethods#double-instance_method, so we'll improve that doc.

Cheers,
David
On Mon, Nov 5, 2012 at 7:48 AM, beagile <govinda...@beagile.de> wrote:
Couldn't find a clue in the rspec-mocks documentation what the difference is... The documentation always uses the mock('some')-variant.
So is there a difference and if then what exactly?

Govinda

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To post to this group, send email to rs...@googlegroups.com.
To unsubscribe from this group, send email to rspec+unsubscribe@googlegroups.com.

beagile

unread,
Nov 6, 2012, 2:06:59 AM11/6/12
to rs...@googlegroups.com
Great. What confused me in the beginning was that I  could use a constant as first argument, too... Good to see this clarified in the docs.


Am Dienstag, 6. November 2012 04:07:09 UTC+1 schrieb dchel...@gmail.com:

On Monday, November 5, 2012 8:15:00 AM UTC-6, dchel...@gmail.com wrote:
The first arg is used for documentation/reporting purposes, that's all. Doesn't matter if it's a Symbol or String. If it's not there you'll just see "mock" in the output without any clarification of which mock failed.

This is admittedly not explained perfectly clearly on http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/ExampleMethods#double-instance_method, so we'll improve that doc.

Cheers,
David
On Mon, Nov 5, 2012 at 7:48 AM, beagile <govinda...@beagile.de> wrote:
Couldn't find a clue in the rspec-mocks documentation what the difference is... The documentation always uses the mock('some')-variant.
So is there a difference and if then what exactly?

Govinda

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To post to this group, send email to rs...@googlegroups.com.
To unsubscribe from this group, send email to rspec+un...@googlegroups.com.

David Chelimsky

unread,
Nov 6, 2012, 8:16:09 AM11/6/12
to rs...@googlegroups.com
Ruby is a permissive language. There are myriad cases in which you throw unintended arguments at methods and they just work, especially when they're just used as parts of Strings. So, while a constant isn't the intent, as long as it has a useful to_s implementation, there's no reason it won't work.


To view this discussion on the web visit https://groups.google.com/d/msg/rspec/-/L4gsTYGSG2AJ.
Reply all
Reply to author
Forward
0 new messages