Commit 54de2719 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Fix url and version mutually exclusive options

Check url and version options are not both in options
parent 923b95eb
...@@ -39,7 +39,7 @@ url ...@@ -39,7 +39,7 @@ url
version version
rubygems version, if not specified, recipe will try to find most recent rubygems version, if not specified, recipe will try to find most recent
version. version. Mutually exclusive with url option.
ruby-executable ruby-executable
A path to a Ruby executable. Gems will be installed using this executable. A path to a Ruby executable. Gems will be installed using this executable.
......
...@@ -44,6 +44,10 @@ class Recipe(object): ...@@ -44,6 +44,10 @@ class Recipe(object):
"Configuration error, 'gems' option is missing") "Configuration error, 'gems' option is missing")
self.url = options.get('url') self.url = options.get('url')
if(self.url and options.get('version')):
raise zc.buildout.UserError(
"Configuration error, 'url' and 'version' options are mutually exclusive")
# Allow to define specific ruby executable. If not, take just 'ruby' # Allow to define specific ruby executable. If not, take just 'ruby'
self.ruby_executable = options.get('ruby-executable', 'ruby') self.ruby_executable = options.get('ruby-executable', 'ruby')
......
...@@ -288,6 +288,20 @@ class RubyGemsDefaultTestCase(RubyGemsTestCase): ...@@ -288,6 +288,20 @@ class RubyGemsDefaultTestCase(RubyGemsTestCase):
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
recipe.install() recipe.install()
@fixture({'recipe': {
'gems': 'sass',
'url': 'https://rubygems.org/rubygems/rubygems-%s.zip'
% RUBYGEMS_DEFAULT_VERSION,
'version': RUBYGEMS_DEFAULT_VERSION,
}})
def test_version_and_url(self, path, patches, buildout, name, options, version):
self.assertRaisesRegexp(
zc.buildout.UserError,
"Configuration error, 'url' and 'version' options are mutually exclusive",
rubygems.Recipe, buildout, name, options
)
class deployment_fixture(fixture): class deployment_fixture(fixture):
def check_output_mock(self, cmd, **kwargs): def check_output_mock(self, cmd, **kwargs):
super(deployment_fixture, self).check_output_mock(cmd) super(deployment_fixture, self).check_output_mock(cmd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment