[Note] Is `` () `` or `` {} `` after `` ʻexpect``? (Module: RSpec :: Matchers)

Main story

A personal note about the format of RSpec matchers.

RSpec version

RSpec 3.9
  - rspec-core 3.9.2
  - rspec-expectations 3.9.2
  - rspec-mocks 3.9.1
  - rspec-rails 4.0.0.beta3
  - rspec-support 3.9.3

Is () or {} after ```expect``?

Conclusion

The gem (rspec-expectations (3.9.2)) documentation below lists the notation for each matcher on the Mothers page. Many examples are also posted. (#change etc.)

Module: RSpec::Matchers — Documentation for rspec-expectations (3.9.2)

An example of misusing {..} in ```expect (..). to be_xxx``

This is an error message when the test is actually executed by writing (..) as {..} in the system spec file. It tells me that to use the be successful matcher, you have to pass arguments instead of blocks.

You must pass an argument rather than a block to `expect` to use the provided matcher (be successful), or the matcher must implement `supports_block_expectations?`.
     
./spec/system/doing_edit_spec.rb:11:in `block (2 levels) in <top (required)>'

Recommended Posts

[Note] Is `` () `` or `` {} `` after `` ʻexpect``? (Module: RSpec :: Matchers)