Class: RSpec::RailsApp::File::Matchers::HaveRailsFile

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

Instance Attribute Summary

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(name, type = nil) ⇒ HaveRailsFile

Returns a new instance of HaveRailsFile.



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

def initialize(name, type = nil)
  @type = type if type
  @name = name
end

Instance Method Details

#matches?(obj, &block) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 15

def matches?(obj, &block)
  begin
    @file = type ? send(:"#{type}_file", name) : send(:"#{name}_file")
    File.file? file
  rescue
    false
  end
end