Module: Clowne::RSpec::Helpers

Included in:
Matchers::CloneAssociation, Matchers::CloneAssociations
Defined in:
lib/clowne/rspec/helpers.rb

Overview

:nodoc: all

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clonerObject (readonly)

Returns the value of attribute cloner.



6
7
8
# File 'lib/clowne/rspec/helpers.rb', line 6

def cloner
  @cloner
end

Instance Method Details

#matches?(actual) ⇒ Boolean

Raises:

  • (ArgumentError)


13
14
15
16
17
18
# File 'lib/clowne/rspec/helpers.rb', line 13

def matches?(actual)
  raise ArgumentError, non_cloner_message unless actual <= ::Clowne::Cloner

  @cloner = actual
  super
end

#non_cloner_messageObject



29
30
31
32
# File 'lib/clowne/rspec/helpers.rb', line 29

def non_cloner_message
  "expected a cloner to be passed to `expect(...)`, " \
  "but got #{actual_formatted}"
end

#planObject



20
21
22
23
24
25
26
27
# File 'lib/clowne/rspec/helpers.rb', line 20

def plan
  @plan ||=
    if @traits.nil?
      cloner.default_plan
    else
      cloner.plan_with_traits(@traits)
    end
end

#with_traits(*traits) ⇒ Object



8
9
10
11
# File 'lib/clowne/rspec/helpers.rb', line 8

def with_traits(*traits)
  @traits = traits
  self
end