<    March 2010    >
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
00:26 damnpepe joined
00:27 bakineggs joined
00:31 jxie joined
01:05 path[l] joined
01:06 jxie joined
01:09 beilabs joined
01:25 damnpepe joined
01:55 pietia joined
02:10 tvw joined
02:26 benlovell joined
02:40 path[l] joined
02:41 beawesomeinstead joined
03:01 robholland joined
03:01 robholland joined
03:02 elliotcm joined
03:03 magpieuk joined
03:04 elliotcm joined
03:23 komi joined
03:37 josephwilk joined
03:54 path[l] joined
04:04 jomz joined
04:11 beilabs joined
04:14 path[l] joined
04:30 josephwilk joined
04:53 elliotcm joined
04:53 fermion joined
05:08 komi_ joined
05:23 foca_ joined
05:24 catch23 joined
05:28 technicalpickl joined
05:30 path[l]_ joined
05:30 textarcana joined
05:34 charleyb joined
05:39 robholland joined
05:39 robholland joined
06:10 path[l] joined
06:16 merboutpost joined
06:39 nevans joined
06:47 elliotcm joined
06:58 bcardarella joined
07:09 komi joined
07:37 textarcana joined
07:40 stepheneb joined
07:48 jhenderson joined
07:48 mabes joined
08:09 nevans joined
08:11 mixandgo joined
08:14 bcardarella joined
08:21 j_dana joined
08:28 elliotcm joined
08:28 egunderson joined
08:30 bcardarella joined
08:39 disturb joined
08:49 bnferguson joined
08:51 boodle joined
08:55 mabes joined
08:57 dchelimsky 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> http://rspec.info/documentation/mocks/message_expectations.html -> Arbitrary Handling of Received Messages
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:49 bakineggs joined
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?
09:56 komi joined
10:08 amerine joined
10:13 patmaddox joined
10:21 pietia joined
10:40 elliotcm joined
10:54 WALoeIII joined
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:02 <bradgonesurfing> http://gist.github.com/337835
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:25 bdimcheff joined
11:32 <bradgonesurfing> technipickles: I figured out how to get rid of the class var. Much cleaner. http://gist.github.com/337835
11:33 <technicalpickles> haha, nice
11:33 <technicalpickles> oh metaclass, how we adore thee
11:34 zodiak joined
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:41 zodiak joined
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:57 <bradgonesurfing> I might package it up later. For the moment I just tucked it away http://xtargets.heroku.com/2010/03/19/proxy-mocks-with-rspec/ for safe keeping. Thanks for the help and review.
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:27 dchelimsky joined
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:36 j_dana joined
12:38 owen1 joined
12:39 <bradgonesurfing> technicalpickles: Your jeweler is nice. I now have a gem on gemcutter called proxymock. Thanks.
12:52 s_dana joined
13:11 bradgonesurfing joined
13:22 <technicalpickles> bradgonesurfing: sweeet
13:29 spicycode joined
14:15 murilass1 joined
14:15 Remear joined
14:15 jamuraa joined
14:15 aussiegeek joined
14:15 kakutani joined
14:28 hgimenez joined
14:29 BobFunk joined
14:30 josephwilk joined
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
14:42 ashley_m_ joined
14:52 spicycode joined
15:01 bradgonesurfing joined
15:23 ashley_moran joined
15:49 dchelimsky 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?
16:14 s_dana joined
16:29 bcardarella joined
16:43 bcardarella joined
17:00 eddanger joined
17:05 textarcana joined
17:06 textarcana left
17:08 jpoz joined
17:12 stepheneb joined
17:39 zodiak joined
17:56 GitHub106 joined
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: ...
17:56 <GitHub106> rspec-core: master commits bb574fe...8e213d5 - http://bit.ly/c0nqQ2
17:56 GitHub106 left
18:04 mabes joined
18:11 jpoz joined
18:26 TomV-415 joined
19:46 textarcana joined
19:52 stepheneb joined
19:58 technicalpickles joined
19:58 technicalpickles joined
20:18 bdimcheff joined
20:31 BobFunk joined
22:08 bdimcheff joined
22:28 patmaddox joined
22:37 technicalpickles joined
22:37 technicalpickles joined
22:55 ashley_m_ joined
23:07 mabes joined
23:28 blankslate joined
23:52 patmaddox joined