Class: RSpec::RailsApp::Directory::Matchers::HaveRailsDirs

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*dirs) ⇒ HaveRailsDirs

Returns a new instance of HaveRailsDirs.



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

def initialize *dirs
  @dirs = dirs
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



7
8
9
# File 'lib/rails_app_spec/matchers/directory/have_rails_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_rails_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_rails_dirs.rb', line 7

def dirs
  @dirs
end

Instance Method Details

#failure_messageObject



25
26
27
# File 'lib/rails_app_spec/matchers/directory/have_rails_dirs.rb', line 25

def failure_message
  "Expected Rails app to have dir: #{dir_name}, but it didn't"
end

#matches?(obj, &block) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#negative_failure_messageObject



29
30
31
# File 'lib/rails_app_spec/matchers/directory/have_rails_dirs.rb', line 29

def negative_failure_message
  "Did not expected Rails app to have dir: #{dir_name}, but it did"
end