Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Eliminate the old DSL

  • Loading branch information...
commit cef61aae6cd5de3de60eb63ed2b5988f9712cc68 1 parent c268834
@njonsson authored
View
48 features/dsl/mirror_rake_tasks/with_defined_task_and_environment_variables.feature
@@ -4,29 +4,6 @@ Feature: The #mirror_rake_tasks DSL method with a defined task and environment v
As a developer using Cape,
I want to use the Cape DSL.
- @deprecated
- Scenario: mirror only the matching Rake task (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks :with_period do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap -vT`
- Then the output should contain:
- """
- cap with_period # Ends with period.
- """
- And the output should not contain "without_period"
- And the output should not contain "my_namespace"
- And the output should contain:
- """
- *** DEPRECATED: Referencing Capistrano variables from Cape without wrapping them in a block, a lambda, or another callable object
- """
-
Scenario: mirror only the matching Rake task
Given a full-featured Rakefile
And a Capfile with:
@@ -44,30 +21,6 @@ Feature: The #mirror_rake_tasks DSL method with a defined task and environment v
"""
And the output should not contain "without_period"
And the output should not contain "my_namespace"
- And the output should not contain "DEPRECATED"
-
- @deprecated
- Scenario: mirror the matching Rake task with its implementation (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- set :current_path, '/current/path'
- set :rails_env, 'rails-env'
-
- Cape do
- mirror_rake_tasks 'with_period' do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap with_period`
- Then the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks("with_period") { |env| env["RAILS_ENV"] = "rails-env" }`. Use this instead: `mirror_rake_tasks("with_period") { |recipes| recipes.env["RAILS_ENV"] = "rails-env" }`
- * executing `with_period'
- * executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\""
- `with_period' is only run for servers matching {}, but no servers matched
- """
Scenario: mirror the matching Rake task with its implementation
Given a full-featured Rakefile
@@ -89,4 +42,3 @@ Feature: The #mirror_rake_tasks DSL method with a defined task and environment v
* executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\""
`with_period' is only run for servers matching {}, but no servers matched
"""
- And the output should not contain "DEPRECATED"
View
43 features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options.feature
@@ -4,27 +4,6 @@ Feature: The #mirror_rake_tasks DSL method with a defined task and valid options
As a developer using Cape,
I want to use the Cape DSL.
- @deprecated
- Scenario: mirror only the matching Rake task (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks :with_period, :roles => :app
- end
- """
- When I run `cap -vT`
- Then the output should contain:
- """
- cap with_period # Ends with period.
- """
- And the output should not contain "without_period"
- And the output should not contain "my_namespace"
- And the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks :with_period, :roles => :app`. Use this instead: `mirror_rake_tasks(:with_period) { |recipes| recipes.options[:roles] = :app }`
- """
-
Scenario: mirror only the matching Rake task
Given a full-featured Rakefile
And a Capfile with:
@@ -42,27 +21,6 @@ Feature: The #mirror_rake_tasks DSL method with a defined task and valid options
"""
And the output should not contain "without_period"
And the output should not contain "my_namespace"
- And the output should not contain "DEPRECATED"
-
- @deprecated
- Scenario: mirror the matching Rake task with its implementation (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- set :current_path, '/current/path'
-
- Cape do
- mirror_rake_tasks 'with_period', :roles => :app
- end
- """
- When I run `cap with_period`
- Then the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks "with_period", :roles => :app`. Use this instead: `mirror_rake_tasks("with_period") { |recipes| recipes.options[:roles] = :app }`
- * executing `with_period'
- * executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
- `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
- """
Scenario: mirror the matching Rake task with its implementation
Given a full-featured Rakefile
@@ -83,4 +41,3 @@ Feature: The #mirror_rake_tasks DSL method with a defined task and valid options
* executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
"""
- And the output should not contain "DEPRECATED"
View
52 features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_environment_variables.feature
@@ -4,33 +4,6 @@ Feature: The #mirror_rake_tasks DSL method with a defined task, valid options, a
As a developer using Cape,
I want to use the Cape DSL.
- @deprecated
- Scenario: mirror only the matching Rake task (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks :with_period, :roles => :app do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap -vT`
- Then the output should contain:
- """
- cap with_period # Ends with period.
- """
- And the output should not contain "without_period"
- And the output should not contain "my_namespace"
- And the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks :with_period, :roles => :app`. Use this instead: `mirror_rake_tasks(:with_period) { |recipes| recipes.options[:roles] = :app }`
- """
- And the output should contain:
- """
- *** DEPRECATED: Referencing Capistrano variables from Cape without wrapping them in a block, a lambda, or another callable object
- """
-
Scenario: mirror only the matching Rake task
Given a full-featured Rakefile
And a Capfile with:
@@ -49,30 +22,6 @@ Feature: The #mirror_rake_tasks DSL method with a defined task, valid options, a
"""
And the output should not contain "without_period"
And the output should not contain "my_namespace"
- And the output should not contain "DEPRECATED"
-
- @deprecated
- Scenario: mirror the matching Rake task with its implementation (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- set :current_path, '/current/path'
- set :rails_env, 'rails-env'
-
- Cape do
- mirror_rake_tasks 'with_period', :roles => :app do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap with_period`
- Then the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks("with_period", :roles => :app) { |env| env["RAILS_ENV"] = "rails-env" }`. Use this instead: `mirror_rake_tasks("with_period") { |recipes| recipes.options[:roles] = :app; recipes.env["RAILS_ENV"] = "rails-env" }`
- * executing `with_period'
- * executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\""
- `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
- """
Scenario: mirror the matching Rake task with its implementation
Given a full-featured Rakefile
@@ -95,4 +44,3 @@ Feature: The #mirror_rake_tasks DSL method with a defined task, valid options, a
* executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\""
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
"""
- And the output should not contain "DEPRECATED"
View
57 features/dsl/mirror_rake_tasks/with_environment_variables.feature
@@ -4,62 +4,6 @@ Feature: The #mirror_rake_tasks DSL method with environment variables
As a developer using Cape,
I want to use the Cape DSL.
- @deprecated
- Scenario: mirror a Rake task (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap -vT`
- And the output should contain:
- """
- *** DEPRECATED: Referencing Capistrano variables from Cape without wrapping them in a block, a lambda, or another callable object
- """
-
- Scenario: mirror a Rake task
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks do |recipes|
- recipes.env['RAILS_ENV'] = lambda { rails_env }
- end
- end
- """
- When I run `cap -vT`
- And the output should not contain "DEPRECATED"
-
- @deprecated
- Scenario: mirror a Rake task with its implementation (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- set :current_path, '/current/path'
- set :rails_env, 'rails-env'
-
- Cape do
- mirror_rake_tasks do |env|
- env['RAILS_ENV'] = rails_env
- env[nil] = 'foo'
- env['FOO'] = nil
- env['SOME_OTHER'] = 'var'
- end
- end
- """
- When I run `cap with_period`
- Then the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks { |env| env["RAILS_ENV"] = "rails-env"; env[nil] = "foo"; env["FOO"] = nil; env["SOME_OTHER"] = "var" }`. Use this instead: `mirror_rake_tasks { |recipes| recipes.env["RAILS_ENV"] = "rails-env"; recipes.env[nil] = "foo"; recipes.env["FOO"] = nil; recipes.env["SOME_OTHER"] = "var" }`
- * executing `with_period'
- * executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\" SOME_OTHER=\"var\""
- `with_period' is only run for servers matching {}, but no servers matched
- """
-
Scenario: mirror a Rake task with its implementation
Given a full-featured Rakefile
And a Capfile with:
@@ -83,4 +27,3 @@ Feature: The #mirror_rake_tasks DSL method with environment variables
* executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\" SOME_OTHER=\"var\""
`with_period' is only run for servers matching {}, but no servers matched
"""
- And the output should not contain "DEPRECATED"
View
21 features/dsl/mirror_rake_tasks/with_valid_options.feature
@@ -4,26 +4,6 @@ Feature: The #mirror_rake_tasks DSL method with valid options
As a developer using Cape,
I want to use the Cape DSL.
- @deprecated
- Scenario: mirror a Rake task with its implementation (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- set :current_path, '/current/path'
-
- Cape do
- mirror_rake_tasks :roles => :app
- end
- """
- When I run `cap with_period`
- Then the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks :roles => :app`. Use this instead: `mirror_rake_tasks { |recipes| recipes.options[:roles] = :app }`
- * executing `with_period'
- * executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
- `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
- """
-
Scenario: mirror a Rake task with its implementation
Given a full-featured Rakefile
And a Capfile with:
@@ -43,4 +23,3 @@ Feature: The #mirror_rake_tasks DSL method with valid options
* executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
"""
- And the output should not contain "DEPRECATED"
View
24 features/dsl/mirror_rake_tasks/with_valid_options_and_environment_variables.feature
@@ -4,29 +4,6 @@ Feature: The #mirror_rake_tasks DSL method with valid options and environment va
As a developer using Cape,
I want to use the Cape DSL.
- @deprecated
- Scenario: mirror a Rake task with its implementation (deprecated)
- Given a full-featured Rakefile
- And a Capfile with:
- """
- set :current_path, '/current/path'
- set :rails_env, 'rails-env'
-
- Cape do
- mirror_rake_tasks :roles => :app do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap with_period`
- Then the output should contain:
- """
- *** DEPRECATED: `mirror_rake_tasks(:roles => :app) { |env| env["RAILS_ENV"] = "rails-env" }`. Use this instead: `mirror_rake_tasks { |recipes| recipes.options[:roles] = :app; recipes.env["RAILS_ENV"] = "rails-env" }`
- * executing `with_period'
- * executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\""
- `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
- """
-
Scenario: mirror a Rake task with its implementation
Given a full-featured Rakefile
And a Capfile with:
@@ -48,4 +25,3 @@ Feature: The #mirror_rake_tasks DSL method with valid options and environment va
* executing "cd /current/path && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"rails-env\""
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
"""
- And the output should not contain "DEPRECATED"
View
1  lib/cape.rb
@@ -6,7 +6,6 @@
module Cape
extend DSL
- extend DSLDeprecated
end
View
165 lib/cape/capistrano_deprecated.rb
@@ -1,165 +0,0 @@
-require 'cape/capistrano'
-require 'cape/deprecation/capistrano_deprecated_define_rake_wrapper'
-require 'cape/recipe_definition_deprecated'
-require 'cape/xterm'
-
-module Cape
-
- # Implements {Capistrano} with deprecated methods.
- #
- # @api private
- class CapistranoDeprecated < Capistrano
-
- # Defines a wrapper in Capistrano around the specified Rake _task_.
- #
- # @deprecated Use {Capistrano#define_rake_wrapper} instead.
- #
- # @param [Hash] task metadata for a Rake task
- # @param [Hash] named_arguments named arguments, including options to pass to
- # the Capistrano +task+ method
- #
- # @option task [String] :name the name of the Rake task
- # @option task [Array of String, nil] :parameters the names of the Rake
- # task's parameters, if any
- # @option task [String] :description documentation for the Rake
- # task
- #
- # @option named_arguments [Binding] :binding the Binding of your
- # Capistrano recipes
- # file
- #
- # @yield [env] a block that defines environment variables for the Rake task;
- # optional
- # @yieldparam [Hash] env the environment variables to set before executing
- # the Rake task
- #
- # @return [CapistranoDeprecated] the object
- #
- # @raise [ArgumentError] +named_arguments[:binding]+ is missing
- #
- # @note Any parameters that the Rake task has are integrated via environment variables, since Capistrano does not support recipe parameters per se.
- #
- # @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/configuration/actions/invocation.rb#L99-L144 Valid Capistrano 'task' method options
- #
- # @api public
- def define_rake_wrapper(task, named_arguments, &block)
- unless (binding = named_arguments[:binding])
- raise ::ArgumentError, ':binding named argument is required'
- end
-
- deprecation.task = task
- deprecation.named_arguments = named_arguments
-
- capistrano_context = binding.eval('self', __FILE__, __LINE__)
- options = named_arguments.reject do |key, value|
- key == :binding
- end
- describe task, capistrano_context
- implement(task, capistrano_context, options, &block)
- end
-
- # The object in which deprecated API usage is recorded.
- #
- # @return [Deprecation::Base]
- def deprecation
- @deprecation ||= Deprecation::CapistranoDeprecatedDefineRakeWrapper.new
- end
-
- private
-
- def capture_recipe_definition(recipe_definition, &recipe_definition_block)
- begin
- super
- rescue NoMethodError
- unless @warned
- deprecation.stream.puts XTerm.bold_and_foreground_red('*** DEPRECATED:') +
- ' ' +
- XTerm.bold('Referencing Capistrano variables ' +
- 'from Cape without wrapping them in ' +
- 'a block, a lambda, or another ' +
- 'callable object')
- @warned = true
- end
- return false
- end
- true
- end
-
- def implement(task, capistrano_context, options, &env_block)
- return super(task, capistrano_context, &env_block) if options.empty?
-
- name_tokens = tokenize_name(task)
- recipe_definition = new_recipe_definition(deprecation)
- env = nil
- if capture_recipe_definition(recipe_definition, &env_block)
- env_strings = recipe_definition.env.collect do |var_name, var_value|
- if var_name.nil? || var_value.nil?
- nil
- else
- var_value = var_value.call if var_value.is_a?(Proc)
- "#{var_name}=#{var_value.inspect}"
- end
- end.compact
- env = env_strings.empty? ? nil : (' ' + env_strings.join(' '))
- end
- this = env ? nil : self
- rake = self.rake
- block = lambda { |context|
- recipe_name = name_tokens.last
- if recipe_definition.rename
- recipe_name = recipe_definition.rename.call(name_tokens.last)
- end
- context.task recipe_name, options do
- arguments = Array(task[:parameters]).collect do |a|
- if (value = ENV[a.upcase])
- value = value.inspect
- end
- value
- end
- if arguments.empty?
- arguments = nil
- else
- arguments = "[#{arguments.join ','}]"
- end
-
- unless env
- if this.instance_eval { capture_recipe_definition(recipe_definition, &env_block) }
- env_strings = recipe_definition.env.collect do |var_name, var_value|
- if var_name.nil? || var_value.nil?
- nil
- else
- var_value = var_value.call if var_value.is_a?(Proc)
- "#{var_name}=#{var_value.inspect}"
- end
- end.compact
- env = env_strings.empty? ? nil : (' ' + env_strings.join(' '))
- this = nil
- end
- end
-
- path = recipe_definition.cd || context.current_path
- path = path.call if path.respond_to?(:call)
- command = "cd #{path} && #{rake.remote_executable} " +
- "#{task[:name]}#{arguments}#{env}"
- context.run command
- end
- }
- # Nest the recipe inside its containing namespaces.
- name_tokens[0...-1].reverse.each do |namespace_token|
- inner_block = block
- block = lambda { |context|
- context.namespace(namespace_token, &inner_block)
- }
- end
- block.call capistrano_context
- self
- end
-
- def new_recipe_definition(*arguments)
- arguments << deprecation if arguments.empty?
- RecipeDefinitionDeprecated.new(*arguments)
- end
-
- end
-
-end
View
12 lib/cape/deprecation.rb
@@ -1,12 +0,0 @@
-::Dir.glob(::File.expand_path('../deprecation/*.rb', __FILE__)) do |f|
- require "cape/deprecation/#{::File.basename f, '.rb'}"
-end
-
-module Cape
-
- # Contains implementations of deprecation stream printers.
- #
- # @api private
- module Deprecation; end
-
-end
View
59 lib/cape/deprecation/base.rb
@@ -1,59 +0,0 @@
-require 'cape/xterm'
-
-module Cape
-
- module Deprecation
-
- # Prints to a stream a message related to deprecated API usage.
- #
- # @abstract
- class Base
-
- # Sets the value of {#stream}.
- #
- # @param [IO] value a new value for {#stream}
- #
- # @return [IO] _value_
- attr_writer :stream
-
- # Formats {#message_content} for display.
- #
- # @return [String] the full message
- def formatted_message
- [].tap do |fragments|
- fragments << XTerm.bold_and_foreground_red('*** DEPRECATED:')
- fragments << ' '
- fragments << XTerm.bold(message_content)
- end.join
- end
-
- # Prepares a message based on deprecated API usage.
- #
- # @raise [NotImplementedError]
- #
- # @abstract
- def message_content
- raise ::NotImplementedError
- end
-
- # The stream to which deprecation messages are printed. Defaults to
- # $stderr.
- #
- # @return [IO]
- def stream
- @stream ||= $stderr
- end
-
- # Writes {#formatted_message} to {#stream}.
- #
- # @return [Base] the object
- def write_formatted_message_to_stream
- stream.puts formatted_message
- self
- end
-
- end
-
- end
-
-end
View
168 lib/cape/deprecation/capistrano_deprecated_define_rake_wrapper.rb
@@ -1,168 +0,0 @@
-require 'cape/deprecation/base'
-require 'cape/hash_list'
-
-module Cape
-
- module Deprecation
-
- # Prints to a stream a message related to deprecated usage of
- # {CapistranoDeprecated#define_rake_wrapper}.
- class CapistranoDeprecatedDefineRakeWrapper < Base
-
- # The _task_ argument to {CapistranoDeprecated#define_rake_wrapper}.
- #
- # @return [Symbol, String]
- attr_accessor :task
-
- # Environment variable names and values set in a call to
- # {CapistranoDeprecated#define_rake_wrapper}.
- #
- # @return [HashList]
- def env
- @env ||= HashList.new
- end
-
- # Prepares a message based on deprecated usage of
- # {CapistranoDeprecated#define_rake_wrapper}.
- #
- # @return [String] a deprecation message
- def message_content
- [].tap do |fragments|
- fragments << message_content_actual
- fragments << '. '
- fragments << message_content_expected
- end.join
- end
-
- # The _named_arguments_ argument to
- # {CapistranoDeprecated#define_rake_wrapper}.
- #
- # @return [HashList]
- def named_arguments
- @named_arguments ||= HashList.new
- end
-
- # Sets the value of {#named_arguments}.
- #
- # @param [Hash] value a new value for {#named_arguments}
- #
- # @return [HashList] _value_
- def named_arguments=(value)
- @named_arguments = HashList.new(value)
- end
-
- private
-
- def binding_named_arguments
- named_arguments.select do |name, value|
- name == :binding
- end
- end
-
- def message_content_env_actual
- [].tap do |fragments|
- env_entries = env.collect do |name, value|
- "env[#{name.inspect}] = #{value.inspect}"
- end
- unless env_entries.empty?
- fragments << ' { |env| '
- fragments << env_entries.join('; ')
- fragments << ' }'
- end
- end.join
- end
-
- def message_content_options_and_env_expected
- [].tap do |fragments|
- unless named_arguments.empty? && env.empty?
- fragments << ' { |recipes| '
-
- options_entries = options.collect do |name, value|
- "recipes.options[#{name.inspect}] = #{value.inspect}"
- end
- env_entries = env.collect do |name, value|
- "recipes.env[#{name.inspect}] = #{value.inspect}"
- end
- fragments << (options_entries + env_entries).join('; ')
-
- fragments << ' }'
- end
- end.join
- end
-
- def message_content_actual
- [].tap do |fragments|
- fragments << '`'
- fragments << message_content_method_name
- fragments << message_content_task_and_named_arguments_actual
- fragments << message_content_env_actual
- fragments << '`'
- end.join
- end
-
- def message_content_expected
- [].tap do |fragments|
- fragments << 'Use this instead: '
- fragments << '`'
- fragments << message_content_method_name
- fragments << message_content_task_and_named_arguments_expected
- fragments << message_content_options_and_env_expected
- fragments << '`'
- end.join
- end
-
- def message_content_method_name
- 'define_rake_wrapper'
- end
-
- def message_content_task_and_named_arguments_actual
- [].tap do |fragments|
- arguments = []
- arguments << task.inspect unless task.nil?
- named_arguments_entries = named_arguments.collect do |name, value|
- "#{name.inspect} => #{value.inspect}"
- end
- unless named_arguments_entries.empty?
- arguments << named_arguments_entries.join(', ')
- end
- unless arguments.empty?
- if env.empty?
- fragments << " #{arguments.join ', '}"
- else
- fragments << "(#{arguments.join ', '})"
- end
- end
- end.join
- end
-
- def message_content_task_and_named_arguments_expected
- [].tap do |fragments|
- arguments = []
- arguments << task.inspect unless task.nil?
- binding_named_arguments_entries = binding_named_arguments.collect do |name, value|
- "#{name.inspect} => #{value.inspect}"
- end
- unless binding_named_arguments_entries.empty?
- arguments << binding_named_arguments_entries.join(', ')
- end
- unless arguments.empty?
- if options.empty? && env.empty?
- fragments << " #{arguments.join ', '}"
- else
- fragments << "(#{arguments.join ', '})"
- end
- end
- end.join
- end
-
- def options
- named_arguments.reject do |name, value|
- name == :binding
- end
- end
-
- end
-
- end
-
-end
View
145 lib/cape/deprecation/dsl_deprecated_mirror_rake_tasks.rb
@@ -1,145 +0,0 @@
-require 'cape/deprecation/base'
-require 'cape/hash_list'
-
-module Cape
-
- module Deprecation
-
- # Prints to a stream a message related to deprecated usage of
- # {DSLDeprecated#mirror_rake_tasks}.
- class DSLDeprecatedMirrorRakeTasks < Base
-
- # The _task_expression_ argument to {DSLDeprecated#mirror_rake_tasks}.
- #
- # @return [Symbol, String]
- attr_accessor :task_expression
-
- # Environment variable names and values set in a call to
- # {DSLDeprecated#mirror_rake_tasks}.
- #
- # @return [HashList]
- def env
- @env ||= HashList.new
- end
-
- # Prepares a message based on deprecated usage of
- # {DSLDeprecated#mirror_rake_tasks}.
- #
- # @return [String] a deprecation message
- def message_content
- [].tap do |fragments|
- fragments << message_content_actual
- fragments << '. '
- fragments << message_content_expected
- end.join
- end
-
- # The _options_ argument to {DSLDeprecated#mirror_rake_tasks}.
- #
- # @return [HashList]
- def options
- @options ||= HashList.new
- end
-
- # Sets the value of {#options}.
- #
- # @param [Hash] value a new value for {#options}
- #
- # @return [HashList] _value_
- def options=(value)
- @options = HashList.new(value)
- end
-
- private
-
- def message_content_env_actual
- [].tap do |fragments|
- env_entries = env.collect do |name, value|
- "env[#{name.inspect}] = #{value.inspect}"
- end
- unless env_entries.empty?
- fragments << ' { |env| '
- fragments << env_entries.join('; ')
- fragments << ' }'
- end
- end.join
- end
-
- def message_content_options_and_env_expected
- [].tap do |fragments|
- unless options.empty? && env.empty?
- fragments << ' { |recipes| '
-
- options_entries = options.collect do |name, value|
- "recipes.options[#{name.inspect}] = #{value.inspect}"
- end
- env_entries = env.collect do |name, value|
- "recipes.env[#{name.inspect}] = #{value.inspect}"
- end
- fragments << (options_entries + env_entries).join('; ')
-
- fragments << ' }'
- end
- end.join
- end
-
- def message_content_actual
- [].tap do |fragments|
- fragments << '`'
- fragments << message_content_method_name
- fragments << message_content_task_expression_and_options_actual
- fragments << message_content_env_actual
- fragments << '`'
- end.join
- end
-
- def message_content_expected
- [].tap do |fragments|
- fragments << 'Use this instead: '
- fragments << '`'
- fragments << message_content_method_name
- fragments << message_content_task_expression_expected
- fragments << message_content_options_and_env_expected
- fragments << '`'
- end.join
- end
-
- def message_content_method_name
- 'mirror_rake_tasks'
- end
-
- def message_content_task_expression_and_options_actual
- [].tap do |fragments|
- arguments = []
- arguments << task_expression.inspect unless task_expression.nil?
- options_entries = options.collect do |name, value|
- "#{name.inspect} => #{value.inspect}"
- end
- arguments << options_entries.join(', ') unless options_entries.empty?
- unless arguments.empty?
- if env.empty?
- fragments << " #{arguments.join ', '}"
- else
- fragments << "(#{arguments.join ', '})"
- end
- end
- end.join
- end
-
- def message_content_task_expression_expected
- [].tap do |fragments|
- unless task_expression.nil?
- if options.empty? && env.empty?
- fragments << " #{task_expression.inspect}"
- else
- fragments << "(#{task_expression.inspect})"
- end
- end
- end.join
- end
-
- end
-
- end
-
-end
View
157 lib/cape/dsl_deprecated.rb
@@ -1,157 +0,0 @@
-require 'cape/capistrano_deprecated'
-require 'cape/deprecation/capistrano_deprecated_define_rake_wrapper'
-require 'cape/deprecation/dsl_deprecated_mirror_rake_tasks'
-
-module Cape
-
- # Implements deprecated methods of {DSL}.
- #
- # @api private
- module DSLDeprecated
-
- # The stream to which deprecation messages are printed.
- #
- # @return [Deprecation::Base]
- def deprecation
- @deprecation ||= Deprecation::DSLDeprecatedMirrorRakeTasks.new
- end
-
- # Defines Rake tasks as Capistrano recipes.
- #
- # @overload mirror_rake_tasks(task_expression=nil)
- # Defines Rake tasks as Capistrano recipes.
- #
- # @param [String, Symbol] task_expression the full name of a Rake task or
- # namespace to filter
- #
- # @yield [env] a block that defines environment variables for the Rake
- # task; optional
- # @yieldparam [RecipeDefinitionDeprecated] env the environment variables to
- # set before executing the
- # Rake task
- #
- # @return [DSLDeprecated] the object
- #
- # @overload mirror_rake_tasks(capistrano_task_options={})
- # Defines all Rake tasks as Capistrano recipes with options.
- #
- # @deprecated Use {RecipeDefinition#options} instead.
- #
- # @param [Hash] capistrano_task_options options to pass to the Capistrano
- # +task+ method
- #
- # @yield [env] a block that defines environment variables for the Rake
- # task; optional
- # @yieldparam [RecipeDefinitionDeprecated] env the environment variables to
- # set before executing the
- # Rake task
- #
- # @return [DSLDeprecated] the object
- #
- # @overload mirror_rake_tasks(task_expression, capistrano_task_options={})
- # Defines specific Rake tasks as Capistrano recipes with options.
- #
- # @deprecated Use {RecipeDefinition#options} instead.
- #
- # @param [String, Symbol] task_expression the full name of a Rake
- # task or namespace to
- # filter
- # @param [Hash] capistrano_task_options options to pass to the
- # Capistrano +task+ method
- #
- # @yield [env] a block that defines environment variables for the Rake
- # task; optional
- # @yieldparam [RecipeDefinitionDeprecated] env the environment variables to
- # set before executing the
- # Rake task
- #
- # @return [DSLDeprecated] the object
- #
- # @note Any parameters that the Rake tasks have are integrated via environment variables, since Capistrano does not support recipe parameters per se.
- #
- # @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/configuration/actions/invocation.rb#L99-L144 Valid Capistrano 'task' method options
- #
- # @example Mirroring all Rake tasks
- # # config/deploy.rb
- #
- # require 'cape'
- #
- # Cape do
- # mirror_rake_tasks
- # end
- #
- # @example Mirroring some Rake tasks, but not others
- # # config/deploy.rb
- #
- # require 'cape'
- #
- # Cape do
- # # Create Capistrano recipes for the Rake task 'foo' and/or for the
- # # tasks in the 'foo' namespace.
- # mirror_rake_tasks :foo
- # end
- #
- # @example Mirroring Rake tasks that require Capistrano recipe options and/or environment variables
- # # config/deploy.rb
- #
- # require 'cape'
- #
- # Cape do
- # # Display defined Rails routes on application server remote machines
- # # only.
- # mirror_rake_tasks :routes, :roles => :app
- #
- # # Execute database migration on application server remote machines
- # # only, and set the 'RAILS_ENV' environment variable to the value of
- # # the Capistrano variable 'rails_env'.
- # mirror_rake_tasks 'db:migrate', :roles => :app do |env|
- # env['RAILS_ENV'] = rails_env
- # end
- # end
- #
- # @example Mirroring Rake tasks into a Capistrano namespace
- # # config/deploy.rb
- #
- # require 'cape'
- #
- # namespace :rake_tasks do
- # Cape do |cape|
- # cape.mirror_rake_tasks
- # end
- # end
- #
- # @api public
- def mirror_rake_tasks(*arguments, &block)
- arguments_count = arguments.length
- options = arguments.last.is_a?(::Hash) ? arguments.pop.dup : {}
- deprecation.task_expression = arguments.first
- deprecation.options = options.dup
- unless arguments.length <= 1
- raise ::ArgumentError,
- ("wrong number of arguments (#{arguments_count} for 0 or 1, " +
- 'plus an options hash)')
- end
-
- task_expression = arguments.first
- options[:binding] = binding
- rake.each_task task_expression do |t|
- deployment_library.define_rake_wrapper(t, options, &block)
- end
- deployment_library.deprecation.env.each do |name, value|
- deprecation.env[name] = value
- end
- unless deprecation.options.empty? && deprecation.env.empty?
- deprecation.write_formatted_message_to_stream
- end
- self
- end
-
- private
-
- def new_capistrano(*arguments)
- CapistranoDeprecated.new(*arguments)
- end
-
- end
-
-end
View
41 lib/cape/recipe_definition_deprecated.rb
@@ -1,41 +0,0 @@
-require 'cape/recipe_definition'
-
-module Cape
-
- # Implements {RecipeDefinition} with deprecated methods.
- #
- # @api private
- class RecipeDefinitionDeprecated < RecipeDefinition
-
- # The object in which deprecated API usage is recorded.
- #
- # @return [Deprecation::Base]
- attr_reader :deprecation
-
- # Constructs a new RecipeDefinitionDeprecated with the specified
- # _deprecation_.
- #
- # @param [Deprecation::Base] deprecation the value of {#deprecation}
- def initialize(deprecation)
- @deprecation = deprecation
- end
-
- # Sets a remote environment variable.
- #
- # @param [String] name the name of a remote environment variable
- # @param [String] value a value for the remote environment variable
- #
- # @return [RecipeDefinitionDeprecated] the object
- #
- # @deprecated Use {RecipeDefinition#env} instead.
- #
- # @api public
- def []=(name, value)
- env[name] = value
- deprecation.env[name] = value
- self
- end
-
- end
-
-end
View
18 spec/cape/deprecation/base_sharedspec.rb
@@ -1,18 +0,0 @@
-require 'spec_helper'
-require 'cape/deprecation/base'
-
-shared_examples_for "a #{Cape::Deprecation::Base.name}" do
- describe '-- without specified attributes --' do
- its(:stream) { should == $stderr }
- end
-
- describe '-- with a different #stream --' do
- before :each do
- subject.stream = different_stream
- end
-
- let(:different_stream) { StringIO.new }
-
- its(:stream) { should == different_stream }
- end
-end
View
157 spec/cape/deprecation/capistrano_deprecated_define_rake_wrapper_spec.rb
@@ -1,157 +0,0 @@
-require 'spec_helper'
-require 'cape/deprecation/capistrano_deprecated_define_rake_wrapper'
-require 'cape/deprecation/base_sharedspec'
-require 'cape/xterm'
-
-describe Cape::Deprecation::CapistranoDeprecatedDefineRakeWrapper do
- it_should_behave_like "a #{Cape::Deprecation::Base.name}"
-
- let(:deprecation_preamble) {
- Cape::XTerm.bold_and_foreground_red('*** DEPRECATED:') + ' '
- }
-
- describe '-- without specified attributes --' do
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`define_rake_wrapper`. ' +
- 'Use this instead: `define_rake_wrapper`')
- }
- end
-
- describe '-- with #task' do
- before :each do
- subject.task = {:name => :foo}
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`define_rake_wrapper {:name=>:foo}`. ' +
- 'Use this instead: ' +
- '`define_rake_wrapper {:name=>:foo}`')
- }
-
- describe 'and with #named_arguments' do
- before :each do
- subject.named_arguments = {:bar => :baz}
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'define_rake_wrapper {:name=>:foo}, ' +
- ':bar => :baz' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'define_rake_wrapper({:name=>:foo}) { |recipes| ' +
- 'recipes.options[:bar] = :baz ' +
- '}' +
- '`')
- }
-
- describe 'and with #env --' do
- before :each do
- subject.env['QUX'] = 'quux'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'define_rake_wrapper({:name=>:foo}, ' +
- ':bar => :baz) { |env| ' +
- 'env["QUX"] = "quux" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'define_rake_wrapper({:name=>:foo}) { |recipes| ' +
- 'recipes.options[:bar] = :baz; ' +
- 'recipes.env["QUX"] = "quux" ' +
- '}' +
- '`')
- }
- end
- end
-
- describe 'and with #env --' do
- before :each do
- subject.env['BAR'] = 'baz'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'define_rake_wrapper({:name=>:foo}) { |env| ' +
- 'env["BAR"] = "baz" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'define_rake_wrapper({:name=>:foo}) { |recipes| ' +
- 'recipes.env["BAR"] = "baz" ' +
- '}' +
- '`')
- }
- end
- end
-
- describe '-- with #named_arguments' do
- before :each do
- subject.named_arguments = {:foo => :bar}
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`define_rake_wrapper :foo => :bar`. ' +
- 'Use this instead: ' +
- '`' +
- 'define_rake_wrapper { |recipes| ' +
- 'recipes.options[:foo] = :bar ' +
- '}' +
- '`')
- }
-
- describe 'and with #env --' do
- before :each do
- subject.env['BAZ'] = 'qux'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'define_rake_wrapper(:foo => :bar) { |env| ' +
- 'env["BAZ"] = "qux" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'define_rake_wrapper { |recipes| ' +
- 'recipes.options[:foo] = :bar; ' +
- 'recipes.env["BAZ"] = "qux" ' +
- '}' +
- '`')
- }
- end
- end
-
- describe '-- with #env --' do
- before :each do
- subject.env['FOO'] = 'bar'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'define_rake_wrapper { |env| ' +
- 'env["FOO"] = "bar" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'define_rake_wrapper { |recipes| ' +
- 'recipes.env["FOO"] = "bar" ' +
- '}' +
- '`')
- }
- end
-end
View
153 spec/cape/deprecation/dsl_deprecated_mirror_rake_tasks_spec.rb
@@ -1,153 +0,0 @@
-require 'spec_helper'
-require 'cape/deprecation/dsl_deprecated_mirror_rake_tasks'
-require 'cape/deprecation/base_sharedspec'
-require 'cape/xterm'
-
-describe Cape::Deprecation::DSLDeprecatedMirrorRakeTasks do
- it_should_behave_like "a #{Cape::Deprecation::Base.name}"
-
- let(:deprecation_preamble) {
- Cape::XTerm.bold_and_foreground_red('*** DEPRECATED:') + ' '
- }
-
- describe '-- without specified attributes --' do
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`mirror_rake_tasks`. ' +
- 'Use this instead: `mirror_rake_tasks`')
- }
- end
-
- describe '-- with #task_expression' do
- before :each do
- subject.task_expression = :foo
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`mirror_rake_tasks :foo`. ' +
- 'Use this instead: `mirror_rake_tasks :foo`')
- }
-
- describe 'and with #options' do
- before :each do
- subject.options = {:bar => :baz}
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`mirror_rake_tasks :foo, :bar => :baz`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks(:foo) { |recipes| ' +
- 'recipes.options[:bar] = :baz ' +
- '}' +
- '`')
- }
-
- describe 'and with #env --' do
- before :each do
- subject.env['QUX'] = 'quux'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks(:foo, ' +
- ':bar => :baz) { |env| ' +
- 'env["QUX"] = "quux" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks(:foo) { |recipes| ' +
- 'recipes.options[:bar] = :baz; ' +
- 'recipes.env["QUX"] = "quux" ' +
- '}' +
- '`')
- }
- end
- end
-
- describe 'and with #env --' do
- before :each do
- subject.env['BAR'] = 'baz'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks(:foo) { |env| ' +
- 'env["BAR"] = "baz" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks(:foo) { |recipes| ' +
- 'recipes.env["BAR"] = "baz" ' +
- '}' +
- '`')
- }
- end
- end
-
- describe '-- with #options' do
- before :each do
- subject.options = {:foo => :bar}
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`mirror_rake_tasks :foo => :bar`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks { |recipes| ' +
- 'recipes.options[:foo] = :bar ' +
- '}' +
- '`')
- }
-
- describe 'and with #env --' do
- before :each do
- subject.env['BAZ'] = 'qux'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks(:foo => :bar) { |env| ' +
- 'env["BAZ"] = "qux" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks { |recipes| ' +
- 'recipes.options[:foo] = :bar; ' +
- 'recipes.env["BAZ"] = "qux" ' +
- '}' +
- '`')
- }
- end
- end
-
- describe '-- with #env --' do
- before :each do
- subject.env['FOO'] = 'bar'
- end
-
- its(:formatted_message) {
- should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks { |env| ' +
- 'env["FOO"] = "bar" ' +
- '}' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks { |recipes| ' +
- 'recipes.env["FOO"] = "bar" ' +
- '}' +
- '`')
- }
- end
-end
View
307 spec/cape/dsl_deprecated_spec.rb
@@ -1,307 +0,0 @@
-require 'spec_helper'
-require 'cape/dsl'
-require 'cape/dsl_deprecated'
-require 'cape/capistrano'
-require 'cape/core_ext/hash'
-require 'cape/core_ext/symbol'
-require 'cape/rake'
-require 'cape/xterm'
-
-describe Cape::DSLDeprecated do
- subject do
- Object.new.tap do |o|
- o.extend Cape::DSL
- o.extend described_class
- end
- end
-
- let(:mock_capistrano) { mock(Cape::Capistrano).as_null_object }
-
- let(:mock_rake) { mock(Cape::Rake).as_null_object }
-
- let(:task_expression) { 'task:expression' }
-
- before :each do
- Cape::Capistrano.stub!(:new).and_return mock_capistrano
- Cape::Rake. stub!(:new).and_return mock_rake
- subject.deprecation.stream = StringIO.new
- end
-
- describe '-- when sent #each_rake_task --' do
- def do_each_rake_task(&block)
- subject.each_rake_task(task_expression, &block)
- end
-
- it 'should delegate to Rake#each_task' do
- mock_rake.should_receive(:each_task).
- with(task_expression).
- and_yield({:name => task_expression})
- do_each_rake_task do |t|
- t.should == {:name => task_expression}
- end
- end
-
- it 'should return itself' do
- do_each_rake_task.should == subject
- end
- end
-
- describe '-- when sent #mirror_rake_tasks' do
- before :each do
- mock_rake.stub!(:each_task).and_yield({:name => task_expression})
- subject.stub! :raise_unless_capistrano
- end
-
- def do_mirror_rake_tasks(*arguments, &block)
- subject.mirror_rake_tasks(*arguments, &block)
- end
-
- let(:deprecation_preamble) {
- Cape::XTerm.bold_and_foreground_red('*** DEPRECATED:') + ' '
- }
-
- describe 'with two scalar arguments --' do
- specify do
- lambda {
- do_mirror_rake_tasks task_expression, task_expression
- }.should raise_error(ArgumentError,
- 'wrong number of arguments (2 for 0 or 1, plus ' +
- 'an options hash)')
- end
- end
-
- shared_examples_for "a successful call (#{Cape::DSLDeprecated.name})" do |task_expression_in_use,
- options_in_use|
- specify 'by collecting Rake#each_task' do
- mock_rake.should_receive(:each_task).with task_expression_in_use
- do_mirror_rake_tasks
- end
-
- specify 'by verifying that Capistrano is in use' do
- subject.should_receive :raise_unless_capistrano
- do_mirror_rake_tasks
- end
-
- describe 'by sending Capistrano#define_rake_wrapper for Rake#each_task' do
- specify 'with the expected task' do
- mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
- named_arguments|
- task == {:name => task_expression}
- end
- do_mirror_rake_tasks
- end
-
- specify 'with the expected named options' do
- mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
- named_arguments|
- named_arguments.keys.sort == ([:binding] + options_in_use.keys).sort
- end
- do_mirror_rake_tasks
- end
-
- specify 'with a :binding option' do
- mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
- named_arguments|
- named_arguments[:binding].is_a? Binding
- end
- do_mirror_rake_tasks
- end
-
- specify 'with any provided extra options' do
- mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
- named_arguments|
- named_arguments.slice(*options_in_use.keys) == options_in_use
- end
- do_mirror_rake_tasks
- end
- end
-
- specify 'by returning itself' do
- do_mirror_rake_tasks.should == subject
- end
- end
-
- describe 'with one scalar argument, an options hash, and a block --' do
- def do_mirror_rake_tasks
- super 'task:expression', :bar => :baz do |env|
- env['AN_ENV_VAR'] = 'an environment variable'
- end
- end
-
- should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
- 'task:expression',
- :bar => :baz
-
- it 'should print the expected deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks "task:expression", ' +
- ':bar => :baz' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks("task:expression") { |recipes| ' +
- 'recipes.options[:bar] = :baz ' +
- '}' +
- '`') +
- "\n"
- end
- end
-
- describe 'with one scalar argument and an options hash --' do
- def do_mirror_rake_tasks
- super 'task:expression', :bar => :baz
- end
-
- should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
- 'task:expression',
- :bar => :baz
-
- it 'should print the expected deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks "task:expression", ' +
- ':bar => :baz' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks("task:expression") { |recipes| ' +
- 'recipes.options[:bar] = :baz ' +
- '}' +
- '`') +
- "\n"
- end
- end
-
- describe 'with an options hash and a block --' do
- def do_mirror_rake_tasks
- super :bar => :baz do |env|
- env['AN_ENV_VAR'] = 'an environment variable'
- end
- end
-
- should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
- nil,
- :bar => :baz
-
- it 'should print the expected deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks :bar => :baz' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks { |recipes| ' +
- 'recipes.options[:bar] = :baz ' +
- '}' +
- '`') +
- "\n"
- end
- end
-
- describe 'with an options hash --' do
- def do_mirror_rake_tasks
- super :bar => :baz
- end
-
- should_behave_like "a successful call (#{Cape::DSLDeprecated.name})",
- nil,
- :bar => :baz
-
- it 'should print the expected deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should == deprecation_preamble +
- Cape::XTerm.bold('`' +
- 'mirror_rake_tasks :bar => :baz' +
- '`. ' +
- 'Use this instead: ' +
- '`' +
- 'mirror_rake_tasks { |recipes| ' +
- 'recipes.options[:bar] = :baz ' +
- '}' +
- '`') +
- "\n"
- end
- end
-
- describe 'with one scalar argument and a block --' do
- def do_mirror_rake_tasks
- super 'task:expression' do |env|
- env['AN_ENV_VAR'] = 'an environment variable'
- end
- end
-
- should_behave_like("a successful call (#{Cape::DSLDeprecated.name})",
- 'task:expression',
- {})
-
- it 'should print no deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should be_empty
- end
- end
-
- describe 'with one scalar argument --' do
- def do_mirror_rake_tasks
- super 'task:expression'
- end
-
- should_behave_like("a successful call (#{Cape::DSLDeprecated.name})",
- 'task:expression',
- {})
-
- it 'should print no deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should be_empty
- end
- end
-
- describe 'without arguments --' do
- def do_mirror_rake_tasks
- super
- end
-
- should_behave_like("a successful call (#{Cape::DSLDeprecated.name})",
- nil,
- {})
-
- it 'should print no deprecation messages to stderr' do
- do_mirror_rake_tasks
- subject.deprecation.stream.string.should be_empty
- end
- end
- end
-
- describe '-- when sent #local_rake_executable --' do
- before :each do
- mock_rake.stub!(:local_executable).and_return 'foo'
- end
-
- it 'should delegate to Rake#local_executable' do
- mock_rake.should_receive :local_executable
- subject.local_rake_executable
- end
-
- it 'should return the result of Rake#local_executable' do
- subject.local_rake_executable.should == 'foo'
- end
- end
-
- describe '-- when sent #remote_rake_executable --' do
- before :each do
- mock_rake.stub!(:remote_executable).and_return 'foo'
- end
-
- it 'should delegate to Rake#remote_executable' do
- mock_rake.should_receive :remote_executable
- subject.remote_rake_executable
- end
-
- it 'should return the result of Rake#remote_executable' do
- subject.remote_rake_executable.should == 'foo'
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.