<br><br><div class="gmail_quote">On Nov 22, 2007 8:31 AM, aslak hellesoy &lt;<a href="mailto:aslak.hellesoy@gmail.com">aslak.hellesoy@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Nov 21, 2007 10:22 PM, David Chelimsky &lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt; On Nov 21, 2007 3:14 PM, Daniel N &lt;<a href="mailto:has.sox@gmail.com">
has.sox@gmail.com</a>&gt; wrote:<br>&gt; &gt; Hi,<br>&gt; &gt;<br>&gt; &gt; I want to be able to get at the described class in my shared behaviour. &nbsp;I&#39;m<br>&gt; &gt; sure an example will say it better than my words<br>
&gt; &gt;<br>&gt; &gt; describe &quot;my shared&quot;, :shared =&gt; true do<br>&gt; &gt;<br>&gt; &gt; &nbsp; it &quot;should tell me what the class is its describing&quot; do<br>&gt; &gt; &nbsp; &nbsp; how_do_i_get_the_user_class_here<br>
&gt; &gt; &nbsp;end<br>&gt; &gt;<br>&gt; &gt; end<br>&gt; &gt;<br>&gt; &gt; describe User do<br>&gt; &gt; &nbsp; it_should_behave_like &quot;my shared&quot;<br>&gt; &gt;<br>&gt; &gt; &nbsp; #...<br>&gt; &gt; end<br>&gt; &gt;<br>&gt; &gt; So in my shared behaviour, how do I get access to the User class?
<br>&gt;<br>&gt; There&#39;s no way to do this implicitly. i.e. rspec does not expose the<br>&gt; class. You&#39;d have to have a method like described_class or something:<br>&gt;<br>&gt; describe &quot;my shared&quot;, :shared =&gt; true do
<br>&gt;<br>&gt; &nbsp; it &quot;should tell me what the class is its describing&quot; do<br>&gt; &nbsp; &nbsp; described_class.should do_something_I_care_about<br>&gt; &nbsp;end<br>&gt;<br>&gt; end<br>&gt;<br>&gt; describe User do<br>&gt; &nbsp; def described_class
<br>&gt; &nbsp; &nbsp; User<br>&gt; &nbsp; end<br>&gt; &nbsp; ...<br>&gt; end<br>&gt;<br>&gt;<br><br></div></div>However, if you do this:<br><br>describe MyModule do # MyModule has a #hello method<br> &nbsp;it &quot;should be polite&quot; do<br> &nbsp; &nbsp;
hello.should == &#39;How do you do&#39;<br> &nbsp;end<br>end<br><br>Modules are automatically mixed into your examples<br><font color="#888888"><br>Aslak<br></font><div><div></div><div class="Wj3C7c">&gt;<br>&gt;<br>&gt;<br>&gt; &gt;
<br>&gt; &gt; Cheers<br>&gt; &gt; Daniel<br>&gt; &gt;<a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank"></a></div></div></blockquote><div><br>Aslak<br><br>Thanx.&nbsp; I was aware of that behaviour, but this module is being mixed into AR classes and relies on there being methods available to AR models.&nbsp; I really want to implemnet these specs as a shared behaviour on each implementing model.
<br><br>That way I can check to make sure that the model has the correct attributes for the mixin to function properly etc.<br><br>Thanx again.<br>Daniel<br></div></div><br>