Sha256: 1dbbf1dccef0ffda4c297a9b09d0d1e1177640a7fbb544e9e24ae635b641fc8a

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe AktionTest::Matchers::FileSystem::DirectoryExistanceMatcher do
  context "an existing directory" do
    let(:dir) { File.expand_path(File.join(__FILE__, '..')) }

    it "will be accepeted" do
      dir.should be_a_directory
    end

    it "provides a negative failure message" do
      matcher = described_class.new
      matcher.matches?(dir)
      matcher.negative_failure_message.should == <<-MSG.strip_heredoc.strip
        Did not expect #{dir} to be a directory.
      MSG
    end

    it "provides a failure message with an unknown problem" do
      matcher = described_class.new
      matcher.matches?(dir)
      matcher.failure_message.should == <<-MSG.strip_heredoc.strip
        Expected #{dir} to be a directory.
        Unknown
      MSG
    end
  end

  context "a non-existant directory" do
    let(:dir) { File.expand_path(File.join(__FILE__, '..', 'foo')) }

    it "will not be accepted" do
      dir.should_not be_a_directory
    end

    it "explains that the subject does not exist" do
      matcher = described_class.new
      matcher.matches?(dir)
      matcher.failure_message.should == <<-MSG.strip_heredoc.strip
        Expected #{dir} to be a directory.
        #{dir} does not exist.
      MSG
    end
  end

  context "a file" do
    let(:dir) { __FILE__ }

    it "will not be accepted" do
      dir.should_not be_a_directory
    end

    it "explains that the subject is a file" do
      matcher = described_class.new
      matcher.matches?(dir)
      matcher.failure_message.should == <<-MSG.strip_heredoc.strip
        Expected #{dir} to be a directory.
        #{dir} is not a directory.
      MSG
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aktion_test-0.1.2 spec/matchers/be_a_directory_spec.rb
aktion_test-0.1.1 spec/matchers/be_a_directory_spec.rb