Class: Tengu::ItBlock

Inherits:
Object
  • Object
show all
Includes:
Matchers
Defined in:
lib/tengu/it_block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Matchers

#be, #be_false, #be_instance_of, #be_kind_of, #be_nil, #be_true, #eq, #eql, #equal, #have_received, #include, #match

Constructor Details

#initialize(description, block) ⇒ ItBlock

Returns a new instance of ItBlock.



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

def initialize(description, block)
  @description = description
  @block = block
  @success = true
  @pending = false
  @expectations = []
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



9
10
11
# File 'lib/tengu/it_block.rb', line 9

def description
  @description
end

#expectationsObject (readonly)

Returns the value of attribute expectations.



9
10
11
# File 'lib/tengu/it_block.rb', line 9

def expectations
  @expectations
end

Instance Method Details

#pending?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/tengu/it_block.rb', line 32

def pending?
  @pending
end

#run(runner, listeners = []) ⇒ Object



19
20
21
22
23
24
# File 'lib/tengu/it_block.rb', line 19

def run(runner, listeners = [])
  @runner = runner
  instance_eval(&@block)
  @runner.reset_overrides
  notify(listeners)
end

#success?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/tengu/it_block.rb', line 26

def success?
  unless pending?
    @expectations.all? { |expectation| expectation.success? }
  end
end