Myron - thanks very much. I didn't think my post actually posted, hence my delay.
On Monday, 14 July 2014 21:00:16 UTC+1, Myron Marston wrote: > > On Friday, July 11, 2014 4:13:11 PM UTC-7, Kris Leech wrote: >> >> I'm writing a custom matcher to allow testing of the exit status of code. >> >> I've written the matcher as an object using the bits of information I >> could find. >> >> I'm using `config.include(Rspec::ExitMatchers)` to include a module >> which has one method which creates an instance of my matcher, however this >> method receives the expected value, not the block passed to `expect`, so >> how do I create an instance of my matcher since the initializer needs the >> block (actual), not the expected value which should be passed to >> `matches?`... >> >> >> https://github.com/krisleech/rspec-exit_matchers/blob/master/lib/rspec/exit_matchers.rb#L38 >> >> >> https://github.com/krisleech/rspec-exit_matchers/blob/master/spec/rspec/exit_matchers_spec.rb#L3 >> >> Any helps/pointers would be great. Thanks, Kris. >> > > I've put a gist together showing you how to do this: > > https://gist.github.com/myronmarston/6b8116224e7ec0b00650 > > The key is that your `exit_with_status` method receives a `status` > argument, not a block, and forwards that on to your class's `initialize`. > `matches?` is then passed the `expect` block. > > HTH, > Myron > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/c8299d78-f5c9-4f2e-8f25-727e9fe6a21d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
