Sha256: 9227d7e16f4e88f6713c125de804cc834500d22f90e30d1135d4260fa9800016

Contents?: true

Size: 1.99 KB

Versions: 4

Compression:

Stored size: 1.99 KB

Contents

require 'assert'

require 'assert/rake_tasks/scope'

module Assert::RakeTasks

  class ScopeTests < Assert::Context
    desc "the scope rake tasks handler"
    setup do
      @scope_root = File.expand_path('../../../test/fixtures', __FILE__)
      @scope = Assert::RakeTasks::Scope.new(File.join(@scope_root, 'test_root'))
    end
    subject { @scope }

    should have_class_methods :test_file_suffixes
    should have_readers :path, :nested_files, :path_file_list, :test_tasks, :scopes
    should have_instance_methods :namespace, :to_test_task

    should "know its the test file suffix" do
      assert_equal ['_test.rb', '_tests.rb'], subject.class.test_file_suffixes
    end

    should "know its namespace" do
      assert_equal :test_root, subject.namespace
      assert_equal :shallow, Assert::RakeTasks::Scope.new(File.join(@scope_root, 'test_root/shallow')).namespace
    end

    should "know its nested files" do
      assert_equal 6, subject.nested_files.size
      assert_empty Assert::RakeTasks::Scope.new('/does/not/exist').nested_files

      h = Assert::RakeTasks::Scope.new("#{@scope_root}/test_root/shallow")
      assert_equal 2, h.nested_files.size
    end

    should "know its path file" do
      assert_empty subject.path_file_list

      h = Assert::RakeTasks::Scope.new("#{@scope_root}/test_root/shallow")
      assert_equal 1, h.path_file_list.size
    end

    should "convert to a test task" do
      assert_not Assert::RakeTasks::Scope.new('/does/not/exist').to_test_task

      tt = subject.to_test_task
      assert_kind_of TestTask, tt
      assert_equal subject.nested_files.size+subject.path_file_list.size, tt.files.size
    end

    should "have a test task for each standalone test file" do
      assert_equal 2, subject.test_tasks.size
      assert_kind_of TestTask, subject.test_tasks.first
    end

    should "have a scope for each immediate test dir or test dir/file in the scope" do
      assert_equal 2, subject.scopes.size
      assert_kind_of Scope, subject.scopes.first
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
assert-1.1.0 test/rake_tasks/scope_test.rb
assert-1.0.0 test/rake_tasks/scope_test.rb
assert-0.8.1 test/rake_tasks/scope_test.rb
assert-0.8.0 test/rake_tasks/scope_test.rb