Class: RSpec::RubyContentMatchers::LicenseFile::HaveLicenseFiles

Inherits:
Object
  • Object
show all
Includes:
RailsAssist::Artifact::Directory, RailsAssist::Directory
Defined in:
lib/cancan-permits/rspec/matchers/have_license_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*names) ⇒ HaveLicenseFiles

Returns a new instance of HaveLicenseFiles.



50
51
52
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 50

def initialize *names
  @names = names.flatten
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



48
49
50
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 48

def names
  @names
end

Instance Method Details

#failure_messageObject



69
70
71
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 69

def failure_message
  "License files #{names} not found in #{license_dir} as expected"
end

#license_dirObject



54
55
56
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 54

def license_dir
  File.join(app_dir, 'licenses')
end

#license_file(name) ⇒ Object



58
59
60
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 58

def license_file name
  File.join(license_dir, "#{name}_license.rb")
end

#matches?(obj, &block) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 62

def matches? obj, &block
  names.flatten.each do |name|
    return false if !File.file? license_file(name)
  end        
  true
end

#negative_failure_messageObject



73
74
75
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 73

def negative_failure_message
  "License files #{names} found in #{license_dir} but was not expected"
end