Class: Obsidian::Spec::MappingMatcher
- Inherits:
-
Object
- Object
- Obsidian::Spec::MappingMatcher
show all
- Includes:
- Obsidian::Spec
- Defined in:
- lib/obsidian/spec/map_spec_helper.rb
Instance Method Summary
collapse
#args_to_set, #find_calling_line, #read_calling_line
Constructor Details
Returns a new instance of MappingMatcher.
7
8
9
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 7
def initialize(object)
@object = object.to_set
end
|
Instance Method Details
#error_message(set) ⇒ Object
34
35
36
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 34
def error_message(set)
(set.size == 1 ? set.to_a.first : set).inspect
end
|
#in(*other, &blk) ⇒ Object
24
25
26
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 24
def in(*other, &blk)
test("in", *other, &blk)
end
|
#map ⇒ Object
10
11
12
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 10
def map
self
end
|
#test(method, *other, &blk) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 27
def test(method, *other, &blk)
other = args_to_set(*other)
@object.each do |obj|
assert(other.include?(blk.call(obj)),
"Expected #{obj} to map to #{error_message(other)} at\n\t#{read_calling_line(caller,method)}")
end
end
|
#to(*args, &blk) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 13
def to(*args, &blk)
case args.size
when 0 then self
when 1 then test("to", args.first, &blk)
else raise ArgumentError, "wrong number of arguments (#{args.size} for 0-1)"
end
end
|
#values ⇒ Object
21
22
23
|
# File 'lib/obsidian/spec/map_spec_helper.rb', line 21
def values
self
end
|