-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This is the list of pending matchers based on RSpec's Built in Matchers
Object identity
- expect(actual).to be(expected) # passes if actual.equal?(expected)
Object equivalence
- expect(actual).to eq(expected) # passes if actual == expected
Optional APIs for identity/equivalence
- expect(actual).to eql(expected) # passes if actual.eql?(expected)
- expect(actual).to equal(expected) # passes if actual.equal?(expected)
Comparisons
- expect(actual).to be > expected
- expect(actual).to be >= expected
- expect(actual).to be <= expected
- expect(actual).to be < expected
- expect(actual).to be_between(minimum, maximum).inclusive
- expect(actual).to be_between(minimum, maximum).exclusive
- expect(actual).to match(/expression/)
- expect(actual).to be_within(delta).of(expected)
- expect(actual).to start_with expected
- expect(actual).to end_with expected
Types/classes/response
- expect(actual).to be_instance_of(expected)
- expect(actual).to be_kind_of(expected)
- expect(actual).to respond_to(expected)
Truthiness and existentialism
- expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
- expect(actual).to be true # passes if actual == true
- expect(actual).to be_falsey # passes if actual is falsy (nil or false)
- expect(actual).to be false # passes if actual == false
- expect(actual).to be_nil # passes if actual is nil
- expect(actual).to exist # passes if actual.exist? and/or actual.exists? are truthy
- expect(actual).to exist(_args) # passes if actual.exist?(_args) and/or actual.exists?(*args) are truthy
Expecting errors
- expect { ... }.to raise_error
- expect { ... }.to raise_error(ErrorClass)
- expect { ... }.to raise_error("message")
- expect { ... }.to raise_error(ErrorClass, "message")
Expecting throws
- expect { ... }.to throw_symbol
- expect { ... }.to throw_symbol(:symbol)
- expect { ... }.to throw_symbol(:symbol, 'value')
Predicate matchers
- expect(actual).to be_xxx # passes if actual.xxx?
- expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
Collection membership
- expect(actual).to include(expected)
- expect(array).to match_array(expected_array)
- expect(array).to contain_exactly(individual, elements)
Ranges
- expect(1..10).to cover(3)
Change observation
- expect { object.action }.to change(object, :value).from(old).to(new)
- expect { object.action }.to change(object, :value).by(delta)
- expect { object.action }.to change(object, :value).by_at_least(minimum_delta)
- expect { object.action }.to change(object, :value).by_at_most(maximum_delta)
Satisfy
- expect(actual).to satisfy { |value| value == expected }
Output capture
- expect { actual }.to output("some output").to_stdout
- expect { actual }.to output("some error").to_stderr
Block expectation
- expect { |b| object.action(&b) }.to yield_control
- expect { |b| object.action(&b) }.to yield_with_no_args # only matches no args
- expect { |b| object.action(&b) }.to yield_with_args # matches any args
- expect { |b| object.action(&b) }.to yield_successive_args(*args) # matches args against multiple yields
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels