Sha256: 3683e442edfe1d2264a576b7be32041293cd88e40a2ddcc96f014e209a463305

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require_relative "base_integration_test"

include FileUtils

class TestLicense < BaseIntegrationTest
  test_that "omitting a license generates a warning" do
    When { _, @stderr, __ = methadone "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, __ = methadone "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 { methadone "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 { methadone "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 = methadone "newgem -l foobar", allow_failure: true }
    Then {
      refute @result.success?
    }
    And {
      assert_match(/invalid argument: -l foobar/,@stderr)
    }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
methadone-2.0.2 test/integration/test_license.rb
methadone-2.0.1 test/integration/test_license.rb
methadone-2.0.0 test/integration/test_license.rb