Class: RSpec::RailsApp::ArtifactFile::Matchers::HaveRailsArtifactFile

Inherits:
Object
  • Object
show all
Extended by:
RailsAssist::UseMacro
Includes:
ArtifactFile::Matcher::Helper
Defined in:
lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb

Instance Attribute Summary collapse

Attributes included from ArtifactFile::Matcher::Helper

#names, #root_path

Instance Method Summary collapse

Methods included from ArtifactFile::Matcher::Helper

#failure_message, #get_artifact_name, #get_view_ext, #handle_view, #msg, #negative_failure_message, #set_view

Constructor Details

#initialize(name, artifact_type = nil) ⇒ HaveRailsArtifactFile

Returns a new instance of HaveRailsArtifactFile.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 12

def initialize(name, artifact_type = nil)
  self.artifact_type = artifact_type

  extend "RailsAssist::Artifact::#{artifact_type.to_s.camelize}".constantize
  
  if name.kind_of? Hash                  
    set_view name
    return nil
  end        
  self.artifact_name = name.to_s
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



8
9
10
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 8

def action
  @action
end

#artifact_nameObject

Returns the value of attribute artifact_name.



7
8
9
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 7

def artifact_name
  @artifact_name
end

#artifact_typeObject

Returns the value of attribute artifact_type.



7
8
9
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 7

def artifact_type
  @artifact_type
end

#folderObject

Returns the value of attribute folder.



8
9
10
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 8

def folder
  @folder
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 7

def name
  @name
end

#view_extObject

Returns the value of attribute view_ext.



8
9
10
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 8

def view_ext
  @view_ext
end

Instance Method Details

#matches?(root_path, &block) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 24

def matches?(root_path, &block)
  begin
    self.artifact_name = get_artifact_name
    match = File.file? artifact_name      
    if block && match
      yield File.read(artifact_name)
    end
    match        
  rescue
    false
  end
end