Skip to content

Commit d7bcf99

Browse files
committed
Add description method to each class in Matcher
1 parent b1b81fc commit d7bcf99

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/generator_spec/matcher.rb

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ module Matcher
44
# https://github.com/carlhuda/beard
55

66
class File
7+
8+
def description
9+
'file attributes and content'
10+
end
11+
712
def initialize(name, &block)
813
@contents = []
914
@name = name
@@ -39,6 +44,10 @@ def check_contents(file)
3944
end
4045

4146
class Migration < File
47+
def description
48+
'valid migration file'
49+
end
50+
4251
def matches?(root)
4352
file_name = migration_file_name(root, @name)
4453

@@ -61,6 +70,10 @@ def migration_file_name(root, name) #:nodoc:
6170
class Directory
6271
attr_reader :tree
6372

73+
def description
74+
'has directory structure'
75+
end
76+
6477
def initialize(root = nil, &block)
6578
@tree = {}
6679
@negative_tree = []
@@ -110,6 +123,10 @@ def matches?(root)
110123
end
111124

112125
class Root < Directory
126+
def description
127+
'have specified directory structure'
128+
end
129+
113130
def failure_message
114131
if @failure.is_a?(Array) && @failure[0] == :not
115132
"Structure should not have had #{@failure[1]}, but it did"
@@ -131,7 +148,6 @@ def matches?(root)
131148
end
132149

133150
def have_structure(&block)
134-
description = "File and directory structure"
135151
error = 'You must pass a block to have_structure (Use {} instead of do/end!)'
136152
raise RuntimeError, error unless block_given?
137153
Root.new(&block)

0 commit comments

Comments
 (0)