Class: BaconExpect::Expectation

Inherits:
Object
  • Object
show all
Defined in:
lib/bacon-expect/expectation.rb

Defined Under Namespace

Modules: BaconContext

Instance Method Summary collapse

Constructor Details

#initialize(subject, &subject_block) ⇒ Expectation

Returns a new instance of Expectation.



9
10
11
12
# File 'lib/bacon-expect/expectation.rb', line 9

def initialize(subject, &subject_block)
  @subject = subject
  @subject_block = subject_block
end

Instance Method Details

#assertObject



33
34
35
# File 'lib/bacon-expect/expectation.rb', line 33

def assert
  true.should == true
end

#fail(matcher, negated) ⇒ Object



29
30
31
# File 'lib/bacon-expect/expectation.rb', line 29

def fail(matcher, negated)
  raise matcher.fail!(@subject, negated, &@subject_block)
end

#matcher_passes(matcher) ⇒ Object



25
26
27
# File 'lib/bacon-expect/expectation.rb', line 25

def matcher_passes(matcher)
  matcher.matches?(@subject, &@subject_block)
end

#not_to(matcher) ⇒ Object Also known as: to_not



19
20
21
22
# File 'lib/bacon-expect/expectation.rb', line 19

def not_to(matcher)
  fail(matcher, true) if matcher_passes(matcher)
  assert
end

#to(matcher) ⇒ Object



14
15
16
17
# File 'lib/bacon-expect/expectation.rb', line 14

def to(matcher)
  fail(matcher, false) unless matcher_passes(matcher)
  assert
end