Class: RSpec::RailsApp::File::Matchers::HaveRailsFiles

Inherits:
Object
  • Object
show all
Includes:
RailsAssist::Artifact, RailsAssist::File, RailsFile::Matcher::Helper
Defined in:
lib/rails_app_spec/matchers/file/have_rails_files.rb

Instance Attribute Summary collapse

Attributes included from RailsFile::Matcher::Helper

#file, #name, #type

Instance Method Summary collapse

Methods included from RailsFile::Matcher::Helper

#failure_message, #msg, #negative_failure_message

Constructor Details

#initialize(type, *names) ⇒ HaveRailsFiles

Returns a new instance of HaveRailsFiles.



12
13
14
15
# File 'lib/rails_app_spec/matchers/file/have_rails_files.rb', line 12

def initialize(type, *names)
  @type = type
  @names = names
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



10
11
12
# File 'lib/rails_app_spec/matchers/file/have_rails_files.rb', line 10

def names
  @names
end

Instance Method Details

#matches?(obj, &block) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_app_spec/matchers/file/have_rails_files.rb', line 17

def matches?(obj, &block)
  begin
    labels = names.to_strings          
    return false if labels.empty?
    labels.each do |name| 
      @name = name
      @file = send(:"#{type}_file", name)
      return false if !File.file?(file)
    end
    yield if block
    true
  rescue
    false
  end
end