02:41
beawesomeinstead joined
05:28
technicalpickl joined
09:00
technicalpickles joined
09:00
technicalpickles joined
09:13
bradgonesurfing joined
09:17
<bradgonesurfing>
I just started using mocks and they are wonderful. However I was wondering if it is possible to create mock expectations on an instance but still let those methods those expectations are applied against execute? I know this sounds heretical but I am just curious.
09:19
<technicalpickles>
bradgonesurfing: that's called 'proxying' in the mock/stub world iirc. I don't recall offhand if rspec mocking supports it
09:20
<bradgonesurfing>
technicalpickles: proxying. that was the word I was looking for. I'll go google a bit on it. Ta.
09:20
<technicalpickles>
I know rr support it for example, but I don't seem to think rspec's mocking does
09:22
<technicalpickles>
I'm not sure if you can get acces to the original unstubbed method though
09:22
<technicalpickles>
if you could, maybe you could call it in that block
09:24
<bradgonesurfing>
technicalpickles: I could first alias the method and then call it through the block I guess.
09:25
<technicalpickles>
yeah, but omghax :)
09:26
<bradgonesurfing>
I know. Yuck but first hax and then monkey patch then happiness.
09:28
<technicalpickles>
fair point
09:28
<technicalpickles>
maybe that'd make sense to alias the method of stubbed stuff in general?
09:29
<technicalpickles>
or maybe foo.should_receive(:blah).and_proxy !?!
09:36
<bradgonesurfing>
I'm thinking foo.should_recieve!(:blah)
09:38
<technicalpickles>
interesting take. I'm not sure it makes it obvious that it'd proxy to the original method though
09:38
<technicalpickles>
should_proxy maybe?
09:48
<bradgonesurfing>
technicalpickes: metaprogramming question. How to alias a method on an instance. Say I have object foo with method bar and I want to alias bar to sheep.
09:48
<bradgonesurfing>
If I can do that then I think I can make the proxy.
09:54
<technicalpickles>
bradgonesurfing: hmm... not sure offhand
09:54
<technicalpickles>
you might be able to do it on an instance straight up. did you try yet?
11:02
<bradgonesurfing>
technicalpickles: Ok here is the monkey patch and the spec to test it. It look ugly and my metaprogramming skills are not rock star quality but it seems to work. Any comments?
11:03
<technicalpickles>
bradgonesurfing: first off, edit the gist to make the spec end in .rb or tell it otherwise tell it its ruby ;)
11:03
<bradgonesurfing>
done
11:04
<technicalpickles>
niice :)
11:04
<technicalpickles>
I don't think you need to keep __rspec_sym__ around
11:04
<technicalpickles>
it's just used in the class_eval
11:05
<technicalpickles>
one good pattern I've seen in rails with the metaprogramming is to make comments with what the generated code might look like
11:05
<technicalpickles>
ie fill in the vars for a particular example
11:07
<bradgonesurfing>
How to remove a class var. @@__rspec_sym__ = nil gives the same effect but I don't think get's rid of it.
11:09
<technicalpickles>
is that a rspec thing that was there?
11:09
<technicalpickles>
I'm just saying I don't see it used in the class_eval where it isn't interpolated
11:11
<bradgonesurfing>
No it is not used except in the interpolation. Couldn't figure out another way to get it in scope. Explicit set to nil at the end would clarify this.
11:14
<technicalpickles>
I'm just not sure why it's a class var in the first place. couldn't you jsut interpolate #{sym}?
11:16
<bradgonesurfing>
Doesn't work. Ruby scoping issue.
11:16
<technicalpickles>
ohhh, I get it now, sorry
11:17
<bradgonesurfing>
NameError in 'Foo is a monkey' undefined local variable or method `sym' for #>
11:17
<technicalpickles>
right. I think you can probably do an instance_eval instead of class << self and class_eval
11:17
<technicalpickles>
not sure if that'd help
11:18
<bradgonesurfing>
alias only works on the class level.
11:18
<bradgonesurfing>
so i think i have to open the singleton class.
11:18
<technicalpickles>
drat
11:19
<bradgonesurfing>
also it would be nice to use define_method and use a closure for the method but ruby 1.8 doesn't allow block parameters to closures so I can't properly forward the method call that way. So I am left with the hack of pushing in the class variable ( and hoping for no name collisions )
11:21
<bradgonesurfing>
However I think the code is buggy because I have a more complex example that is failing.
11:33
<technicalpickles>
haha, nice
11:33
<technicalpickles>
oh metaclass, how we adore thee
11:34
<bradgonesurfing>
Yeah.... I have to introduce a bunch of guys at work to ruby on monday. I think I'll steer clear of ( class<<self;self;end ) this
11:42
technicalpickles joined
11:42
technicalpickles joined
11:50
<bradgonesurfing>
technicalpickles: If you are still there and still interested. The final working version.
http://gist.github.com/337835 I needed a guard to stop multiple defining of the proxy method. Now the orderd matcher work as well. Would anybody want this in rspec?
11:52
<technicalpickles>
bradgonesurfing: looks good
11:52
<technicalpickles>
it's hard to tell :)
11:52
<technicalpickles>
I'm sure it'd be useful as a gem at least. I did that for test spies
11:59
<technicalpickles>
bradgonesurfing: just use jeweler to make a quick gem ;) would make it easier for peeps to try it
11:59
<bradgonesurfing>
You wrote that right ?
12:00
<bradgonesurfing>
Jeweler that is?
12:00
<technicalpickles>
one case I was thinking about is... what does the error look like when it fails? I suspect that because you use that placeholder @__rspec_obj__ ... it may say that object expected to have the method called on it, rather than the object your calling should_receive! on
12:00
<technicalpickles>
guilty </plug>
12:00
<bradgonesurfing>
:).. I think your concern is right. Hang on a tick let me check.
12:01
<bradgonesurfing>
# expected :bar with (any args) twice, but received it once ./apricocentral/ruby/pspec/app_server_service_spec.rb:104:in `should_receive!'
12:01
<bradgonesurfing>
whoops. sorry cut and paste foobar.
12:02
<bradgonesurfing>
#<Object:0xb717f400> expected :bar with (any args) twice.
12:03
<bradgonesurfing>
I guess I can override the class method on Object to return the wrong class. Evil ?
12:03
<technicalpickles>
heh
12:04
<technicalpickles>
I think this is good for a first pass. might want to look at how expectations get set with should_receive for the next pass though
12:05
<technicalpickles>
anyone know how to add methods for particular types of specs? ie controller vs model vs integration?
12:07
<technicalpickles>
ah-ha!
12:07
<technicalpickles>
config.include(ControllerExampleHelpers, :type => :controller)
12:28
technicalpickles joined
12:28
technicalpickles joined
12:33
<bradgonesurfing>
technicalpickles; I've got jeweler almost working but i get the error. "There was a problem saving your gem: Number is invalid" when it was trying to push to gemcutter ( I am an account )
12:33
<bradgonesurfing>
( I have an account ) I mean
12:34
<bradgonesurfing>
missing version file. Working now.
12:39
<bradgonesurfing>
technicalpickles: Your jeweler is nice. I now have a gem on gemcutter called proxymock. Thanks.
13:11
bradgonesurfing joined
13:22
<technicalpickles>
bradgonesurfing: sweeet
14:31
<BobFunk>
is it just me or are there no specs for rspec-rails?
14:31
<BobFunk>
found a bug and was looking for a way to add a spec and replicate it
15:01
bradgonesurfing joined
15:23
ashley_moran joined
15:55
<dchelimsky>
BobFunk: which version of rspec-rails?
15:55
<dchelimsky>
there are no specs right now for rspec-rails-2.x
15:55
<dchelimsky>
we're basically smoke testing it by generating a bunch of specs and running them
15:56
<dchelimsky>
but rspec-rails-1 has a comprehensive suite of specs
16:12
<BobFunk>
rspec-rails-2.x
16:13
<BobFunk>
found the rspec-dev repo now - is that the place to generate and run specs?
17:56
<GitHub106>
rspec-core: master Rob Sanheim * 779d64c (1 files in 1 dirs): Clean up some describes names: ...
17:56
<GitHub106>
rspec-core: master Rob Sanheim * 06c227e (2 files in 2 dirs): Bugfix: rspec shouldn't blow up if spec files don't match "_spec.rb" convention: ...
17:56
<GitHub106>
rspec-core: master Rob Sanheim * 8e213d5 (3 files in 2 dirs): Format elasped time a little bit cleaner -- we do need exponential precision: ...
19:58
technicalpickles joined
19:58
technicalpickles joined
22:37
technicalpickles joined
22:37
technicalpickles joined