Notes posted by vishnunarang

RSS feed
December 9, 2013 - (1.3.0 - 1.3.1)
0 thanks

description for described_class

Here is an example to understand described_class

If while describing the rspec, we use a Class name in the describe part, we can use described_class method to refer to that and use it as a class in the specs within that description.

Example:

describe MyClass do
  it "is available as described_class" do
    expect(described_class).to eq(MyClass)
  end
end

So in the above example, described_class method will return MyClass as a class.

It is a part of rspec core 3.0

Reference: http://www.relishapp.com/rspec/rspec-core/docs/metadata/described-class