Sha256: 49c68fedc00e60202bf9e17089f03b47dd3826a269b93cc2931ba6def17ed871

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require 'assert'
require 'qs/test_helpers'

require 'qs/job_handler'
require 'test/support/runner_spy'

module Qs::TestHelpers

  class UnitTests < Assert::Context
    desc "Qs::TestHelpers"
    setup do
      @test_helpers = Qs::TestHelpers
    end
    subject{ @test_helpers }

  end

  class MixinTests < UnitTests
    desc "as a mixin"
    setup do
      context_class = Class.new{ include Qs::TestHelpers }
      @context = context_class.new
    end
    subject{ @context }

    should have_imeths :test_runner, :test_handler

  end

  class HandlerTestRunnerTests < MixinTests
    desc "for handler testing"
    setup do
      @handler_class = Class.new
      @args = { Factory.string => Factory.string }

      @runner_spy = nil
      Assert.stub(Qs::TestRunner, :new) do |*args|
        @runner_spy = RunnerSpy.new(*args)
      end
    end

    should "build a test runner for a given handler" do
      result = subject.test_runner(@handler_class, @args)

      assert_not_nil @runner_spy
      assert_equal @handler_class, @runner_spy.handler_class
      assert_equal @args, @runner_spy.args
      assert_equal @runner_spy, result
    end

    should "return an initialized handler instance" do
      result = subject.test_handler(@handler_class, @args)

      assert_not_nil @runner_spy
      assert_equal @runner_spy.handler, result
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qs-0.3.0 test/unit/test_helper_tests.rb
qs-0.2.0 test/unit/test_helper_tests.rb
qs-0.1.0 test/unit/test_helper_tests.rb