Sha256: 7259066f3f4fd7e53179597da61be308feeefea6382648cd5c0f01c1ea58341d

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

module RSpec::RailsApp::File
  module Matchers
    class HaveRailsFile
      include ::Rails::Assist::App
    
      attr_accessor :name, :type, :artifact_name

      def initialize(name, type = nil)
        self.name = name
        self.type = type
      end

      def matches?(generator, &block)
        self.artifact_name = send :"#{type}_file_name", name
        match = File.file? artifact_name      
        if block && match
          yield File.read(artifact_name)
        end
        match        
      end          
  
      def failure_message
        "Expected the #{type} #{artifact_name} to exist, but it didn't"
      end

      def negative_failure_message
        "Did not expect the #{type} #{artifact_name} to exist, but it did"
      end
    
    end

    def have_rails_file(relative, type = nil)
      HaveRailsFile.new(relative, type)
    end
    alias_method :contain_rails_file, :have_rails_file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-app-spec-0.1.0 lib/rails_app_spec/matchers/file/have_rails_file.rb