Sha256: 786a06d738806048b1ff399c323ac333044e78d06b62113964185f07ef44492c

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

module RSpec::RailsApp::Directory
  module Matchers    
    class HaveRailsDirs    
      extend RailsAssist::UseMacro
      use_helper :directory
      
      attr_accessor :dir, :dir_name, :dirs

      def initialize *dirs
        @dirs = dirs
      end

      def matches?(obj, &block)   
        labels = dirs.to_strings          
        return false if labels.empty?
        labels.each do |dir_name|
          @dir_name = dir_name
          @dir = send :"#{dir_name}_dir"
          return false if !File.directory?(dir)
        end
        yield if block
        true
      end          
  
      def failure_message
        "Expected Rails app to have dir: #{dir_name}, but it didn't"
      end

      def negative_failure_message
        "Did not expected Rails app to have dir: #{dir_name}, but it did"
      end   
    end

    def have_rails_dirs *dirs
      HaveRailsDirs.new *dirs
    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/directory/have_rails_dirs.rb
rails-app-spec-0.4.0 lib/rails_app_spec/matchers/directory/have_rails_dirs.rb
rails-app-spec-0.3.3 lib/rails_app_spec/matchers/directory/have_rails_dirs.rb