[rspec-users] Custom Example Groups
dchelimsky at gmail.com
Sun Apr 19 08:04:47 EDT 2009
On Sun, Apr 19, 2009 at 5:10 AM, Pat Maddox <pat.maddox at gmail.com> wrote:
> Check out http://gist.github.com/97967 - top one is a custom example
> group, and bottom one is accessing an example's instance var from
> within a matcher.
I forked this and modified it a bit: http://gist.github.com/98041
This shows how to set up class methods that you can access outside
examples (inside groups) and instance methods you can access inside
Also - just a word of caution - even though you *can* access instance
variables in matchers, it seems very brittle to me to attach matchers
to specifically named instance variables like that.
Can you show us what you're trying to do? Perhaps there are less
> On Sat, Apr 18, 2009 at 11:31 PM, Brandon Olivares
> <programmer2188 at gmail.com> wrote:
>> I want to build a custom example group, but there really aren't any examples
>> anywhere for how to do so. The new chapter in The RSpec Book talks about it,
>> but doesn't actually show an example, only how to register it.
>> Looking at rspec-rails, I can see a pattern, but I don't know if that's
>> specific to rspec-rails, or if it is what should be done. In rspec-rails, it
>> Class << self
>> Within the class, and all the methods are within that.
>> So, are there any examples anywhere for how to write an example group?
>> Also, if I set an instance variable within the example group, will the
>> matchers specific to that group be able to access it? That'll simplify my
>> design a bit.
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users