Sha256: 70ebc5bb65cbb2ad06f5d4902cf10d31006ed92c6b02a332762fa2ea482a8f30

Contents?: true

Size: 863 Bytes

Versions: 3

Compression:

Stored size: 863 Bytes

Contents

module GenSpec
  module Matchers
    class ResultMatcher < GenSpec::Matchers::Base
      attr_reader :filename
      
      def initialize(filename, &block)
        @filename = filename
        super(&block)
      end
      
      def generated
        if filename
          path = File.join(destination_root, filename)
          if File.exist?(path)
            match!
            spec_file_contents(path)
          end
        else
          # there was no error, so in the context of
          # "should generate", it most certainly
          # generated.
          match!
          if block
            block.call
          end
        end
      end
      
      def failure_message
        "Expected to generate #{filename}"
      end
        
      def failure_message_when_negated
        "Expected to not generate #{filename}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
genspec-0.3.2 lib/genspec/matchers/result_matcher.rb
genspec-0.3.1 lib/genspec/matchers/result_matcher.rb
genspec-0.3.0 lib/genspec/matchers/result_matcher.rb