Sha256: 164eee468c64c17f6e9664ad541127edb47fd40d02bc1aa4dde84afd16481419

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'minitest/autorun'
require_relative './test_helper'

class TestEasyOptionParser < MiniTest::Test
  def test_contains_a_title
    title = 'My title'
    options = given_options
    parser = EasyOptionParser.new(title, options)

    assert_equal(parser.title, title)
  end

  def test_options_cannot_be_nil
    assert_raises do
      EasyOptionParser.new('title', nil)
    end
  end

  def test_options_cannot_be_empty
    assert_raises do
      EasyOptionParser.new('title', [])
    end
  end

  def test_options_cannot_be_a_hash
    assert_raises do
      EasyOptionParser.new('title', {name: 'path'})
    end
  end

  def test_contains_an_option
    options = given_options
    parser = EasyOptionParser.new('title', options)

    assert parser.contains?('path')
  end

  def test_raise_error_when_options_has_duplicated_name
    options = given_duplicated_options_by_name

    assert_raises do
      EasyOptionParser.new('title', options)
    end
  end

  def test_raise_error_when_options_has_duplicated_short
    options = given_duplicated_options_by_short

    assert_raises do
      EasyOptionParser.new('title', options)
    end
  end

  def test_raise_error_when_options_has_duplicated_long
    options = given_duplicated_options_by_long

    assert_raises do
      EasyOptionParser.new('title', options)
    end
  end

  def test_required_option_contains_required_mark
    required_option = given_a_required_option
    assert_includes(required_option.description, '*')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easy_opt_parser-0.0.1 tests/test_easy_options_parser.rb