If you configure RSpec to disable the should
syntax, you can still use the old one-liner syntax, since that doesn't involve should
being added to every object:
describe User do
it { should be_valid }
end
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:
RSpec.configure do |c|
c.alias_example_to :expect_it
end
RSpec::Core::MemoizedHelpers.module_eval do
alias to should
alias to_not should_not
end
With this in place, you could write this as:
describe User do
expect_it { to be_valid }
end
RSpec::Core::Subject::ExampleMethods
no longer exists. Instead useRSpec::Core::MemoizedHelpers
– Bohunk