rspec-virtus icon indicating copy to clipboard operation
rspec-virtus copied to clipboard

Allow new RSpec matcher syntax

Open mikespokefire opened this issue 10 years ago • 1 comments

Currently We have to use old syntax for matching:

it { expect(described_class).to have_attribute(:title) }

It would be much nicer if we could keep the old implementation, as well as using the new and improved version:

it { is_expected.to have_attribute(:title) }

mikespokefire avatar Sep 10 '14 07:09 mikespokefire

There is a difference between these two examples, the former is a class level and the latter is an instance level expectation.

The latter one works if you define described_class as subject

context 'attributes' do
  subject { described_class }

  it { is_expected.to have_attribute(:title) }
end

legendetm avatar Mar 23 '16 15:03 legendetm