Class: RSpec::RubyContentMatchers::LicenseFile::HaveLicenseFiles
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::LicenseFile::HaveLicenseFiles
- Includes:
- RailsAssist::Artifact::Directory, RailsAssist::Directory
- Defined in:
- lib/cancan-permits/rspec/matchers/have_license_file.rb
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(*names) ⇒ HaveLicenseFiles
constructor
A new instance of HaveLicenseFiles.
- #license_dir ⇒ Object
- #license_file(name) ⇒ Object
- #matches?(obj, &block) ⇒ Boolean
- #negative_failure_message ⇒ Object
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
#names ⇒ Object (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_message ⇒ Object
69 70 71 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 69 def "License files #{names} not found in #{license_dir} as expected" end |
#license_dir ⇒ Object
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
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_message ⇒ Object
73 74 75 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 73 def "License files #{names} found in #{license_dir} but was not expected" end |