Sha256: cc0d4c9e150f68c85e2b67061bbe66e31142da2aad014feb4dbcb5c51a90957c

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require_relative "base_integration_test"

include FileUtils

class TestLicense < BaseIntegrationTest
  test_that "omitting a license generates a warning" do
    When { _, @stderr, __ = optparse_plus "newgem" }
    Then {
      assert_match(/warning: your app has no license/,@stderr)
    }
  end

  test_that "explicitly omitting a license does not generate a warning" do
    When { _, @stderr, __ = optparse_plus "newgem -l NONE" }
    Then {
      refute_match(/warning: your app has no license/,@stderr)
    }
  end

  [
    "apache",
    "mit",
    "gplv2",
    "gplv3",
  ].each do |license|
    test_that "the #{license} license can be included" do
      When { optparse_plus "newgem -l #{license}" }
      Then {
        assert File.exist?("newgem/LICENSE.txt")
      }
      And {
        assert_file("newgem/newgem.gemspec", contains: /#{license.upcase}/)
      }
    end
  end

  test_that "a custom license can be included" do
    When { optparse_plus "newgem -l custom" }
    Then {
      assert File.exist?("newgem/LICENSE.txt")
    }
    And {
      assert_equal "", File.read("newgem/LICENSE.txt").strip
    }
  end

  test_that "a non-custom non-supported license causes an error" do
    When { _, @stderr, @result = optparse_plus "newgem -l foobar", allow_failure: true }
    Then {
      refute @result.success?
    }
    And {
      assert_match(/invalid argument: -l foobar/,@stderr)
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
optparse-plus-3.0.1 test/integration/test_license.rb
optparse-plus-3.0.0 test/integration/test_license.rb