rspec to be true code example

Example: rspec to be false

# Asserts that the tested-against expression literally equals true or false (respectively).

it { expect(true).to be true }      # passes
it { expect("abc").to be true }     # fails
it { expect(nil).to be true }       # fails
 
it { expect(false).to be false }    # passes
it { expect("abc").to be false}     # fails
it { expect(nil).to be false}       # fails

# Asserts that the tested-against expression evaluates to true or false (respectively).

it { expect(true).to be_true }      # passes
it { expect("abc").to be_true }     # passes
it { expect(nil).to be_true }       # fails
 
it { expect(false).to be_false }    # passes
it { expect("abc").to be_false}     # fails
it { expect(nil).to be_false }      # passes

Tags:

Ruby Example