I heard somebody mention described_type the other day, so I thought
I''d give it a spin.
It doesn''t seem to behave as I''m expecting though.
I have a method which generates examples to verify AR associations:
def it_should_have_many(klass, association, opts = {})
it "should relate to #{association}" do
klass.reflect_on_association(association).should_not be_nil
end
it "should have many #{association}" do
klass.reflect_on_association(association).macro.should
== :has_many
end
if opts[:as]
it "should relate to #{association} as :subject" do
klass.reflect_on_association(association).options[:as].should ==
opts[:as]
end
end
end
So at the moment, I have to call it like this:
it_should_have_many Post, :attachments, :as => :comments
Which is a bit ugly. I figured I could use described_type instead of
klass in the example-generating method, but it doesn''t work:
undefined local variable or method `described_type'' for
#<
Spec
::Rails
::Example
::ModelExampleGroup::Subclass_1::Subclass_1::Subclass_1:0x21518bc>
What dumb thing am I doing wrong?
cheers,
Matt