Class: Surrogate::RSpec::WithFilter

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

Defined Under Namespace

Classes: BlockAsserter, RSpecMatchAsserter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], filter_name = :default_filter, &block) ⇒ WithFilter

Returns a new instance of WithFilter.



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

def initialize(args=[], filter_name=:default_filter, &block)
  self.expected_invocation = Invocation.new args.dup, &block
  self.block = block
  self.pass = send filter_name
  self.filter_name = filter_name
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



31
32
33
# File 'lib/surrogate/rspec/with_filter.rb', line 31

def block
  @block
end

#expected_invocationObject

Returns the value of attribute expected_invocation.



31
32
33
# File 'lib/surrogate/rspec/with_filter.rb', line 31

def expected_invocation
  @expected_invocation
end

#filter_nameObject

Returns the value of attribute filter_name.



31
32
33
# File 'lib/surrogate/rspec/with_filter.rb', line 31

def filter_name
  @filter_name
end

#passObject

Returns the value of attribute pass.



31
32
33
# File 'lib/surrogate/rspec/with_filter.rb', line 31

def pass
  @pass
end

Instance Method Details

#default?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/surrogate/rspec/with_filter.rb', line 44

def default?
  filter_name == :default_filter
end

#filter(invocations) ⇒ Object



40
41
42
# File 'lib/surrogate/rspec/with_filter.rb', line 40

def filter(invocations)
  invocations.select &pass
end