Sha256: 8cee84328694d4681dc92743b3b6a2155d2ff2519e19e52614c5ca4c13c5baa1

Contents?: true

Size: 1012 Bytes

Versions: 1

Compression:

Stored size: 1012 Bytes

Contents

require 'rails_app_spec/matchers/file/rails_file_helper'

module RSpec::RailsApp::File
  module Matchers    
    class HaveRailsFiles
      include ::Rails3::Assist::Artifact
      include ::Rails3::Assist::File
      include RailsFile::Matcher::Helper
    
      attr_reader :names

      def initialize(type, *names)
        @type = type
        @names = names
      end

      def matches?(obj, &block)
        puts "type: #{type}"
        names.to_strings.each do |name|
          @name = name
          puts "name: #{name}"
          @file = send(:"#{type}_file", name)
          return false if !File.file?(file)
        end
        yield if block
        true
      end          
    end

    def have_rails_files(type, *names)
      HaveRailsFiles.new(type, *names)
    end

    [:initializer, :db, :migration, :locale, :javascript, :stylesheet].each do |name|
      class_eval %{
        def have_#{name}_files *names
          have_rails_files :#{name}, *names
        end    
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-app-spec-0.2.8 lib/rails_app_spec/matchers/file/have_rails_files.rb