Class: RSpec::RailsApp::Directory::Matchers::HaveArtifactDirs

Inherits:
Object
  • Object
show all
Extended by:
RailsAssist::UseMacro
Defined in:
lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(artifact_type, *dirs) ⇒ HaveArtifactDirs

Returns a new instance of HaveArtifactDirs.



9
10
11
12
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 9

def initialize artifact_type, *dirs
  @artifact_type = artifact_type
  @dirs = dirs
end

Instance Attribute Details

#artifact_typeObject

Returns the value of attribute artifact_type.



7
8
9
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 7

def artifact_type
  @artifact_type
end

#dirObject

Returns the value of attribute dir.



7
8
9
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 7

def dir
  @dir
end

#dir_nameObject

Returns the value of attribute dir_name.



7
8
9
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 7

def dir_name
  @dir_name
end

#dirsObject

Returns the value of attribute dirs.



7
8
9
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 7

def dirs
  @dirs
end

Instance Method Details

#failure_messageObject



28
29
30
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 28

def failure_message
  "Expected #{msg}"
end

#matches?(obj, &block) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 14

def matches?(obj, &block)
  dirs.to_strings.each do |dir_name|
    @dir_name = dir_name
    @dir = File.join(send :"#{artifact_type}_dir", dir_name)
    return false if !File.directory?(dir)
  end
  yield if block
  true
end

#msgObject



24
25
26
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 24

def msg
  "Rails app to have the #{artifact_type} dir: #{dir_name}"
end

#negative_failure_messageObject



32
33
34
# File 'lib/rails_app_spec/matchers/directory/have_artifact_dirs.rb', line 32

def negative_failure_message
  "Did not expect #{msg}"
end