Class: RSpec::RubyContentMatchers::LicenseFile::HaveLicenseFile
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::LicenseFile::HaveLicenseFile
- Includes:
- RailsAssist::Artifact::Directory, RailsAssist::Directory
- Defined in:
- lib/cancan-permits/rspec/matchers/have_license_file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(name) ⇒ HaveLicenseFile
constructor
A new instance of HaveLicenseFile.
- #license_dir ⇒ Object
- #license_file(name) ⇒ Object
- #matches?(obj) {|File.read(file_name)| ... } ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(name) ⇒ HaveLicenseFile
Returns a new instance of HaveLicenseFile.
11 12 13 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 11 def initialize name @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 9 def name @name end |
Instance Method Details
#failure_message ⇒ Object
30 31 32 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 30 def "No license file found for #{name} in #{license_dir} as expected" end |
#license_dir ⇒ Object
15 16 17 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 15 def license_dir File.join(app_dir, 'licenses') end |
#license_file(name) ⇒ Object
19 20 21 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 19 def license_file name File.join(license_dir, "#{name}_license.rb") end |
#matches?(obj) {|File.read(file_name)| ... } ⇒ Boolean
23 24 25 26 27 28 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 23 def matches? obj, &block file_name = license_file(name) found = File.file? file_name yield File.read(file_name) if block && found found end |
#negative_failure_message ⇒ Object
34 35 36 |
# File 'lib/cancan-permits/rspec/matchers/have_license_file.rb', line 34 def "License file #{name} found in #{license_dir} but was not expected" end |