Sha256: ccbff81869ce552e5a69304eae58b890d5a5771ef490353978df924fc76f32d8

Contents?: true

Size: 1.5 KB

Versions: 136

Compression:

Stored size: 1.5 KB

Contents

require_relative '../test_helper'

module Generator
  class ExerciseCaseTest < Minitest::Test
    def test_name
      subject = ExerciseCase.new(canonical: OpenStruct.new(description: 'foo'))
      assert_equal 'test_foo', subject.name
    end

    def test_name_with_trailing_whitespace
      subject = ExerciseCase.new(canonical: OpenStruct.new(description: 'foo '))
      assert_equal 'test_foo', subject.name
    end

    def test_name_with_leading_whitespace
      subject = ExerciseCase.new(canonical: OpenStruct.new(description: ' foo'))
      assert_equal 'test_foo', subject.name
    end

    def test_skipped_index_zero
      assert_equal '# skip', ExerciseCase.new(canonical: nil).skipped(0)
    end

    def test_skipped_index_nonzero
      assert_equal 'skip', ExerciseCase.new(canonical: nil).skipped(1)
    end

    def test_forwarding_to_canonical
      mock_canonical = Minitest::Mock.new
      mock_canonical.expect :key, 'fake value'
      subject = ExerciseCase.new(canonical: mock_canonical)
      subject.key
      mock_canonical.verify
    end

    def test_method_mising_calls_super
      subject = ExerciseCase.new(canonical: nil)
      assert_raises NoMethodError do
        subject.key
      end
    end

    def test_true_respond_to?
      subject = ExerciseCase.new(canonical: OpenStruct.new(key: 'value'))
      assert subject.respond_to?(:key)
    end

    def test_false_respond_to?
      subject = ExerciseCase.new(canonical: OpenStruct.new())
      refute subject.respond_to?(:key)
    end
  end
end

Version data entries

136 entries across 136 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.118 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.117 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.116 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.115 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.114 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.113 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.111 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.110 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.109 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.108 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.107 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.106 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.105 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.104 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.103 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.102 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.101 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.100 tracks/ruby/test/generator/exercise_case_test.rb
trackler-2.2.1.99 tracks/ruby/test/generator/exercise_case_test.rb