Sha256: d18f39b0cd7fdcd40263a3981e730e748c6873dfcc6d6e423af0090ee5bfdfc5

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

require 'rails_app_spec/matchers/file/rails_file_helper'

module RSpec::RailsApp::File
  module Matchers    
    class HaveRailsFile
      include ::Rails3::Assist::Artifact
      include RailsFile::Matcher::Helper
    
      def initialize(name, type = nil)
        @type = type if type
        @name = name
      end

      def matches?(obj, &block)
        @file = type ? send(:"#{type}_file", name) : send(:"#{name}_file")
        File.file? file
      end  
    end

    def have_rails_file(type = nil)
      HaveRailsFile.new(type)
    end

    [:initializer, :db, :migration, :locale, :javascript, :stylesheet].each do |name|
      class_eval %{
        def have_#{name}_file name
          have_rails_file name, :#{name}
        end    
      }
    end

    [:application, :seed, :environment].each do |name|
      class_eval %{
        def have_#{name}_file
          have_rails_file #{name}
        end    
      }
    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/file/have_rails_file.rb