Class: Surrogate::RSpec::WithFilter::BlockAsserter

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/rspec/with_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(definition_block) ⇒ BlockAsserter

Returns a new instance of BlockAsserter.



6
7
8
9
# File 'lib/surrogate/rspec/with_filter.rb', line 6

def initialize(definition_block)
  @call_with = Invocation.new []
  definition_block.call self
end

Instance Method Details

#after(&block) ⇒ Object



23
24
25
# File 'lib/surrogate/rspec/with_filter.rb', line 23

def after(&block)
  @after = block
end

#arity(n) ⇒ Object



27
28
29
# File 'lib/surrogate/rspec/with_filter.rb', line 27

def arity(n)
  @arity = n
end

#before(&block) ⇒ Object



19
20
21
# File 'lib/surrogate/rspec/with_filter.rb', line 19

def before(&block)
  @before = block
end

#call_with(*args, &block) ⇒ Object



11
12
13
# File 'lib/surrogate/rspec/with_filter.rb', line 11

def call_with(*args, &block)
  @call_with = Invocation.new args, &block
end

#matches?(block_to_test) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/surrogate/rspec/with_filter.rb', line 31

def matches?(block_to_test)
  matches   = before_matches? block_to_test
  matches &&= return_value_matches? block_to_test
  matches &&= arity_matches? block_to_test
  matches &&= after_matches? block_to_test
  matches
end

#returns(value = nil, &block) ⇒ Object



15
16
17
# File 'lib/surrogate/rspec/with_filter.rb', line 15

def returns(value=nil, &block)
  @returns = block || lambda { |returned| returned.should == value }
end