Sha256: 6db6613ed60f980f3ebb5489289a716c03babdfc4db7450a9638ae28ce5ea730

Contents?: true

Size: 915 Bytes

Versions: 9

Compression:

Stored size: 915 Bytes

Contents

module RSpec::RailsApp::Directory
  module Matchers    
    class HaveRailsDirs    
      extend Rails3::Assist::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

9 entries across 9 versions & 1 rubygems

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