Module: Matchy::Modals

Defined in:
lib/matchy/modals.rb

Instance Method Summary collapse

Instance Method Details

#should(expectation = nil) ⇒ Object Also known as: will

Tests an expectation against the given object.

Examples

"hello".should eql("hello")
13.should equal(13)
lambda { raise "u r doomed" }.should raise_error


11
12
13
14
15
16
17
# File 'lib/matchy/modals.rb', line 11

def should(expectation = nil)
  if expectation
    match_expectation(expectation, true)
  else
    return Matchy::Expectations::OperatorExpectation.new(self, true)
  end
end

#should_not(expectation = nil) ⇒ Object Also known as: will_not, wont

Tests that an expectation doesn't match the given object.

Examples

"hello".should_not eql("hi")
41.should_not equal(13)
lambda { "savd bai da bell" }.should_not raise_error


29
30
31
32
33
34
35
# File 'lib/matchy/modals.rb', line 29

def should_not(expectation = nil)
  if expectation
    match_expectation(expectation, false)
  else
    return Matchy::Expectations::OperatorExpectation.new(self, false)
  end
end