With the new expect syntax in rspec-2.11, how is it possible to use the implicit subject? Is there a better way than explicitly referencing subject, like below?
describe User do
it 'is valid' do
expect(subject).to be_valid # <<< can `subject` be implicit?
end
end
If you configure RSpec to disable the
shouldsyntax, you can still use the old one-liner syntax, since that doesn’t involveshouldbeing added to every object:We briefly discussed an alternate one-liner syntax, but decided against it since it wasn’t needed and we felt like it might add confusion. You can, however, easily add this yourself if you prefer how it reads:
With this in place, you could write this as: