[rspec-users] Options Hash explanation ?

mortench mortench at gmail.com
Wed May 13 15:36:02 EDT 2009


On 13 Maj, 07:28, David Chelimsky <dchelim... at gmail.com> wrote:
> You can access the group and example options from within an example:
>
> describe "group options hash", :defined_in => :group do
>   it "is available in examples via self.class.options" do
>     self.class.options[:defined_in].should == :group
>   end
> end

Yes, I got this to work too but not for nested describes as below:

describe "group options hash", :defined_in => :group do
   ..
   describe "nested describe wont work"
    it "is available in examples via self.class.options" do
     self.class.options[:defined_in].should == :group # WONT work
    end
   end

end

BTW. I am actually accessing the hash from within a common helper
files in a before action setup by Spec::Runner.configure. Hence it is
important that accessing the Hash work regardless of how the describes
are nested.



More information about the rspec-users mailing list