Class: GeneratorSpec::Matcher::Root

Inherits:
Directory
  • Object
show all
Defined in:
lib/generator_spec/matcher.rb

Instance Attribute Summary

Attributes inherited from Directory

#tree

Instance Method Summary collapse

Methods inherited from Directory

#directory, #file, #initialize, #location, #migration, #no_file

Constructor Details

This class inherits a constructor from GeneratorSpec::Matcher::Directory

Instance Method Details

#descriptionObject



137
138
139
# File 'lib/generator_spec/matcher.rb', line 137

def description
  'have specified directory structure'
end

#failure_messageObject



141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/generator_spec/matcher.rb', line 141

def failure_message
  if @failure.is_a?(Array) && @failure[0] == :not
    if @failure.length > 2
      "Structure should have #{@failure[1]} without #{@failure[2]}. It had:\n#{@failure[3]}"
    else
      "Structure should not have had #{@failure[1]}, but it did"
    end
  elsif @failure.is_a?(Array)
    "Structure should have #{@failure[0]} with #{@failure[1]}. It had:\n#{@failure[2]}"
  else
    "Structure should have #{@failure}, but it didn't"
  end
end

#matches?(root) ⇒ Boolean

Returns:

  • (Boolean)


155
156
157
158
159
160
161
162
# File 'lib/generator_spec/matcher.rb', line 155

def matches?(root)
  root = Pathname.new(root) unless root.is_a?(Pathname)
  @failure = catch :failure do
    super
  end

  !@failure
end