Sha256: 4987cdd8fd3611c7690ebf101bc36a803dbd020f5b5a0a1ff89cea94d87b2b58

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'rails_app_spec/matchers/file/rails_file_helper'

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

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

    def have_rails_file(name, type=nil)
      HaveRailsFile.new(name, 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

3 entries across 3 versions & 1 rubygems

Version Path
rails-app-spec-0.5.0 lib/rails_app_spec/matchers/file/have_rails_file.rb
rails-app-spec-0.4.0 lib/rails_app_spec/matchers/file/have_rails_file.rb
rails-app-spec-0.3.3 lib/rails_app_spec/matchers/file/have_rails_file.rb