Sha256: 1a5d6c94bab166bfb62d525aaf48510b1f65e6e541ec7963982bba10af230314

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module RSpec::RailsApp::ArtifactFile
  module Matchers
    class HaveRailsArtifactFile
      include ::Rails3::Assist::Artifact::FileName
    
      attr_accessor :name, :artifact_type, :artifact_name
      attr_accessor :folder, :action, :view_ext

      include ArtifactFile::Matcher::Helper

      def initialize(name, artifact_type = nil)
        self.artifact_type = artifact_type

        extend "Rails3::Assist::Artifact::#{artifact_type.to_s.camelize}".constantize
        
        if name.kind_of? Hash                  
          set_view name
          return nil
        end        
        self.artifact_name = name.to_s
      end

      def matches?(root_path, &block)
        begin
          self.artifact_name = get_artifact_name
          match = File.file? artifact_name      
          if block && match
            yield File.read(artifact_name)
          end
          match        
        rescue
          false
        end
      end        
    end

    def have_rails_artifact_file(relative, artifact_type = nil)
      HaveRailsArtifactFile.new(relative, artifact_type)
    end
    alias_method :contain_rails_artifact_file, :have_rails_artifact_file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-app-spec-0.2.10 lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb