Sha256: 7b73d1cb9eec1a16c794fc3b9c01ed0908377e8300359338cc0e0110f28008c8

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

require "assert"
require "assert/view"

require "stringio"
require "assert/config_helpers"
require "assert/suite"
require "assert/view_helpers"

class Assert::View
  class UnitTests < Assert::Context
    desc "Assert::View"
    subject { Assert::View }

    should have_instance_method :require_user_view

    should "include the config helpers" do
      assert_includes Assert::ConfigHelpers, subject
    end

    should "include the view helpers" do
      assert_includes Assert::ViewHelpers, subject
    end
  end

  class InitTests < UnitTests
    desc "when init"
    setup do
      @io     = StringIO.new("", "w+")
      @config = Factory.modes_off_config

      @view = Assert::View.new(@config, @io)
    end
    subject{ @view }

    should have_readers :config
    should have_imeths :view, :is_tty?
    should have_imeths :before_load, :after_load
    should have_imeths :on_start, :on_finish, :on_info, :on_interrupt
    should have_imeths :before_test, :after_test, :on_result

    should "default its style options" do
      assert_false subject.styled

      assert_nil subject.pass_styles
      assert_nil subject.fail_styles
      assert_nil subject.error_styles
      assert_nil subject.skip_styles
      assert_nil subject.ignore_styles
    end

    should "default its result abbreviations" do
      assert_equal ".", subject.pass_abbrev
      assert_equal "F", subject.fail_abbrev
      assert_equal "I", subject.ignore_abbrev
      assert_equal "S", subject.skip_abbrev
      assert_equal "E", subject.error_abbrev
    end

    should "know its config" do
      assert_equal @config, subject.config
    end

    should "override the config helper's view value with itself" do
      assert_equal subject, subject.view
    end

    should "know if it is a tty" do
      assert_equal !!@io.isatty, subject.is_tty?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assert-2.18.2 test/unit/view_tests.rb
assert-2.18.1 test/unit/view_tests.rb
assert-2.18.0 test/unit/view_tests.rb