Sha256: e77eb115e058978328c1c18c87bc0a4a8a94c52dd852ac4d476b77a981ab4e3a

Contents?: true

Size: 1.63 KB

Versions: 16

Compression:

Stored size: 1.63 KB

Contents

require File.expand_path('../../project/generator', __FILE__)

module IntegrationTests
  module Base
    class FailWithOutputMatcher < Struct.new(:pattern)
      def matches?(result)
        result.output =~ pattern
      end

      def description
        "fail with output #{pattern.inspect}"
      end

      def failure_message_for_should
        "Expected running the test to produce output #{pattern.inspect} but it didn't"
      end

      def failure_message_for_should_not
        "Expected running the test to not produce output #{pattern.inspect} but it did"
      end
    end

    class HaveErrorsOrFailuresMatcher
      def matches?(result)
        match = result.output.match(/(\d+) error|(\d+) failure/)
        match && match.captures.any? {|value| value && value.to_i > 0 }
      end

      def description
        "have errors or failures"
      end

      def failure_message_for_should
        "Expected running the test to result in errors or failures but it did not"
      end

      def failure_message_for_should_not
        "Expected running the test to not result in errors or failures, but it did "
      end
    end

    def build_project_generator
      Project::Generator.factory do |project_generator|
        configure_project_generator(project_generator)
        yield project_generator if block_given?
      end
    end

    def generate_project(&block)
      build_project_generator.call(&block)
    end

    def configure_project_generator(generator)
    end

    def fail_with_output(pattern)
      FailWithOutputMatcher.new(pattern)
    end

    def have_errors_or_failures
      HaveErrorsOrFailuresMatcher.new
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rr-3.1.1 spec/support/integration_tests/base.rb
rr-3.1.0 spec/support/integration_tests/base.rb
rr-3.0.9 spec/support/integration_tests/base.rb
rr-3.0.8 spec/support/integration_tests/base.rb
rr-3.0.7 spec/support/integration_tests/base.rb
rr-3.0.6 spec/support/integration_tests/base.rb
rr-3.0.5 spec/support/integration_tests/base.rb
rr-3.0.4 spec/support/integration_tests/base.rb
rr-3.0.3 spec/support/integration_tests/base.rb
rr-3.0.2 spec/support/integration_tests/base.rb
rr-3.0.1 spec/support/integration_tests/base.rb
rr-3.0.0 spec/support/integration_tests/base.rb
rr-1.2.1 spec/support/integration_tests/base.rb
rr-1.2.0 spec/support/integration_tests/base.rb
rr-1.1.2 spec/support/integration_tests/base.rb
rr-1.1.2.rc1 spec/support/integration_tests/base.rb