Sha256: 2a26b9dace43cf16a3f20fb76ae00b8506b083e37a47a7507f06500ea2118dfd

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

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)
        begin
          labels = names.to_strings          
          return false if labels.empty?
          labels.each do |name| 
            @name = name
            @file = send(:"#{type}_file", name)
            return false if !File.file?(file)
          end
          yield if block
          true
        rescue
          false
        end
      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

9 entries across 9 versions & 1 rubygems

Version Path
rails-app-spec-0.3.2 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.3.1 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.3.0 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.2.16 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.2.15 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.2.14 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.2.13 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.2.12 lib/rails_app_spec/matchers/file/have_rails_files.rb
rails-app-spec-0.2.10 lib/rails_app_spec/matchers/file/have_rails_files.rb