Sha256: 4178a103f16f17449496e77439e03fbbab6fb6a3c03cfcf059ef67c23b12b50d

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

module ArtifactFile
  module Matcher
  end
end

module ArtifactFile::Matcher
  module Helper
    attr_accessor :name, :artifact_type, :artifact_name
    attr_accessor :folder, :action, :view_ext
    attr_reader :names, :root_path    
    
    def set_view name
      view_options  = name
      self.folder   = view_options[:folder]
      self.action   = view_options[:action] 
      self.view_ext = view_options[:view_ext] 
      self.artifact_type = :view
    end
    
    def handle_view artifact_type, names
      if artifact_type == :view
        lang_option = last_arg({:lang => 'erb.html'}, names)
        raise ArgumentException, ':folder option must be specified in the last hash argument for #have_views' if !lang_option[:folder]          
        self.folder = lang_option[:folder]
        self.view_ext = lang_option[:lang] || {:lang => 'erb.html'}
      end
    end
    
    def get_artifact_name
      case artifact_type
      when :view                                           
        find_view_method = "#{artifact_type}_file_name"
        File.expand_path(send find_view_method, folder, action, view_ext, :root_path => root_path)          
      else                                                     
        find_existing_artifact_method = "existing_#{artifact_type}_file"
        if respond_to? find_existing_artifact_method
          send find_existing_artifact_method, artifact_name, artifact_type, :root_path => root_path 
        else
          raise "The method ##{find_existing_artifact_method} to find the artifact was not available"
        end
      end
    end
    
    def msg
      "the #{artifact_type} #{artifact_name} to exist"
    end

    def failure_message
      "Expected #{msg}"
    end

    def negative_failure_message
      "Did not expect #{msg}"
    end          
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-app-spec-0.2.7 lib/rails_app_spec/matchers/artifact/shared/artifact_file_helper.rb