[rspec-users] Accessing the model class from within an rspec-rails spec

Zach Dennis zach.dennis at gmail.com
Wed Oct 29 17:05:52 EDT 2008

On Wed, Oct 29, 2008 at 12:01 PM, Nick Hoffman <nick at deadorange.com> wrote:

> On 2008-10-28, at 09:09, Cameron Booth wrote:
>> describe User do
>>  it_should_validate_presence_of :name
>> end
>> I can get it working if I pass in User as an argument:
>> describe User do
>>  it_should_validate_presence_of User, :name
>> end
> Hi Cameron. I haven't played with RSpec's internals at all, but considering
> that
>    #it_should_validate_presence_of
> is nested within
>    describe User do
> I would imagine that there's a way to grab "User". Have a look at the
> structure of the Example, ExampleGroup, etc classes. It'll be stored in one
> of those, somewhere.

described_type is what you want. This represents the object being described,

Zach Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081029/1aa1c079/attachment.html>

More information about the rspec-users mailing list