expect() in RSpec?expect() is used to define an expectation in RSpec. It wraps the actual value you want to test, so you can check if it meets certain conditions using matchers.
eq check for in RSpec?The eq matcher checks if the actual value is equal to the expected value using Ruby's == operator.
You use expect { ... }.to raise_error(ErrorClass). The block contains the code that should raise the error, and raise_error matcher checks for it.
eq and eql matchers?eq checks for value equality (==), while eql checks for both value and type equality (eql? method).
Use expect(array).to include(element). The include matcher tests if the element is present in the array.
The equal matcher checks if two values are the same object (identity), unlike eq or eql which check value equality.
The change matcher is used with a block to check if a value changes by a certain amount after running code.
expect(value).not_to eq(5) mean?The not_to negates the expectation, so it expects the value to NOT be equal to 5.
The match matcher checks if a string matches a regular expression pattern.
Use expect { ... }.to raise_error with a block to test if any error is raised.