I'm starting a new Rails project for the first time in a while. When scaffolding a model, Rspec creates describe blocks predicated with "RSpec"
RSpec.describe MyModel do
...
end
vs the old style:
describe MyModel do
...
end
I've perused the change log but must be missing the rational for the change?
As of RSpec 3 you can disable the global availability of describe
by limiting the domain specific language (dsl).
Prefixing with RSpec.describe
ensures tests will still run after implementing the limitation.
Note: you still don't need the prefix, unless you turn off the availability with config.expose_dsl_globally = false
Edit: link to dsl wikipedia
Via the commit:
In a concerted effort to keep monkey patching to a minimum. The default Rails spec generators should not use the monkey patched version of
describe
.Always using only the non-monkey patched
RSpec.describe
, instead of inspecting the configuration, has the benefits of:
- not requiring RSpec to be loaded when the generators are run by Rails
- not introducing extra logic and state to handle the different states
- Resolve #1048
https://github.com/rspec/rspec-rails/commit/ca0d249858903949052e06884e8e7f9d596cdc79
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With