def file_spec(spec_dir, based_on: nil, &block)
      raise ArgumentError.new("Spec directory is missing!") if spec_dir.nil?

      shared_name = spec_dir

      shared shared_name do
        file_tree_spec_context.spec(spec_dir, based_on: based_on).run do |spec|
          break unless instance_eval &block

          formatter = spec.formatter.lazy

          spec.compare do |diff|
            it diff.relative_path.to_s do
              diff.produced.should.satisfy(formatter.describe_missing_file(diff.relative_path)) do
                diff.produced.exist?
              end

              diff.produced.should.satisfy(formatter.describe_file_diff(diff)) do
                diff.is_equal?
              end
            end
          end

          spec.check_unexpected_files do |files|
            it "should not produce unexpected files" do
              files.should.satisfy(formatter.describe_unexpected_files(files)) do
                files.size == 0
              end
            end
          end
        end
      end

      shared_name
    end
def file_spec(spec_dir, based_on: nil, &block)
      raise ArgumentError.new("Spec directory is missing!") if spec_dir.nil?

      shared_name = spec_dir

      shared shared_name do
        file_tree_spec_context.spec(spec_dir, based_on: based_on).run do |spec|
          break unless instance_eval &block

          formatter = spec.formatter.lazy

          spec.compare do |diff|
            it diff.relative_path.to_s do
              diff.produced.should.satisfy(formatter.describe_missing_file(diff.relative_path)) do
                diff.produced.exist?
              end

              diff.produced.should.satisfy(formatter.describe_file_diff(diff)) do
                diff.is_equal?
              end
            end
          end

          spec.check_unexpected_files do |files|
            it "should not produce unexpected files" do
              files.should.satisfy(formatter.describe_unexpected_files(files)) do
                files.size == 0
              end
            end
          end
        end
      end

      shared_name
    end
Ad-hoc defines a set of shared expectations to be consumed directly by `behaves_like`.
 See the following example for usage:

   behaves_like file_spec('my_spec_dir') do
     # do some changes to the current dir
   end

 @note    This expects that a method `file_tree_spec_context` is defined, which is
          returning an instance of {FileTreeSpecContext}.

 @param   [String] spec_dir
          the concrete directory of the spec to be passed to
          {FileTreeSpecContext.spec}

 @param   [String] based_on
          Allows to specify an optional base spec, whose after directory will be used
          as before directory.

 @param   [Block<() -> ()>] block
          the block which will be executed after the before state is laid out in the
          temporary directory, which normally will make modifications to file system,
          which will be compare to the state given in the after directory.

 @return  [String]
          name of the set of shared expectations