Sha256: 2f3a96827c8ab092f9c340c80e323b7ce9278b0a84a5da6123c9d0db4660b031

Contents?: true

Size: 1.99 KB

Versions: 12

Compression:

Stored size: 1.99 KB

Contents

## Object identity

    actual.should equal(expected) # passes if actual.equal?(expected)
    
## Object equivalence

    actual.should == expected   # passes if actual == expected
    actual.should eql(expected) # passes if actual.eql?(expected)

## Optional APIs for identity/equivalence

    actual.should eq(expected)  # passes if actual == expected
    actual.should be(expected)  # passes if actual.equal?(expected)

## Comparisons

    actual.should be >  expected
    actual.should be >= expected
    actual.should be <= expected
    actual.should be <  expected
    actual.should =~ /expression/
    actual.should match(/expression/)
    actual.should be_within(delta).of(expected)

## Types/classes

    actual.should be_instance_of(expected)
    actual.should be_kind_of(expected)

## Truthiness and existentialism

    actual.should be_true  # passes if actual is truthy (not nil or false)
    actual.should be_false # passes if actual is falsy (nil or false)
    actual.should be_nil   # passes if actual is nil
    actual.should be       # passes if actual is truthy (not nil or false)

## 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

    actual.should be_xxx         # passes if actual.xxx?
    actual.should have_xxx(:arg) # passes if actual.has_xxx?(:arg)

### Examples

    [].should be_empty # passes because [].empty? returns true
    { :a => 1 }.should have_key(:a) # passes because the hash has the key :a

## Collection membership

    actual.should include(expected)

### Examples

    [1,2,3].should include(1)
    [1,2,3].should include(1, 2)
    {:a => 'b'}.should include(:a => 'b')
    "this string".should include("is str")

## Ranges (1.9 only)

    (1..10).should cover(3)

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
horseman-0.0.2 vendor/ruby/1.9.1/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
nutshell-crm-0.0.6.alpha vendor/bundle/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
nutshell-crm-0.0.5 vendor/bundle/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
nutshell-crm-0.0.4 vendor/bundle/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
nutshell-crm-0.0.3 vendor/bundle/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
nutshell-crm-0.0.2 vendor/bundle/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
nutshell-crm-0.0.1 vendor/bundle/gems/rspec-expectations-2.7.0/features/built_in_matchers/README.md
rspec-expectations-2.8.0.rc1 features/built_in_matchers/README.md
rspec-expectations-2.7.0 features/built_in_matchers/README.md
rspec-expectations-2.7.0.rc1 features/built_in_matchers/README.md