Sha256: 1a3d9e0387b3c5b7b62a0d10878f5efe31048122ae2e63d95bcc6ca44f6431dc
Contents?: true
Size: 1.84 KB
Versions: 9
Compression:
Stored size: 1.84 KB
Contents
require 'rails-app-spec' module RSpec::RubyContentMatchers module LicenseFile class HaveLicenseFile include ::Rails3::Assist::Artifact::Directory include ::Rails3::Assist::Directory attr_reader :name def initialize name @name = name end def license_dir File.join(app_dir, 'licenses') end def license_file name File.join(license_dir, "#{name}_license.rb") end def matches? obj, &block file_name = license_file(name) found = File.file? file_name yield File.read(file_name) if block && found found end def failure_message "No license file found for #{name} in #{license_dir} as expected" end def negative_failure_message "License file #{name} found in #{license_dir} but was not expected" end end def have_license_file name HaveLicenseFile.new name end class HaveLicenseFiles include ::Rails3::Assist::Artifact::Directory include ::Rails3::Assist::Directory attr_reader :names def initialize *names @names = names.flatten end def license_dir File.join(app_dir, 'licenses') end def license_file name File.join(license_dir, "#{name}_license.rb") end def matches? obj, &block names.flatten.each do |name| return false if !File.file? license_file(name) end true end def failure_message "License files #{names} not found in #{license_dir} as expected" end def negative_failure_message "License files #{names} found in #{license_dir} but was not expected" end end def have_license_files *names HaveLicenseFiles.new names end end end
Version data entries
9 entries across 9 versions & 1 rubygems