From 8ae29f76934a8e33a451f876a27fdfaaa1b29cea Mon Sep 17 00:00:00 2001 From: Yuji Nakayama Date: Wed, 14 May 2014 20:46:56 +0900 Subject: [PATCH] Rename Configuration to Config --- lib/transpec/cli.rb | 16 +- lib/transpec/{configuration.rb => config.rb} | 2 +- lib/transpec/converter.rb | 90 ++-- lib/transpec/option_parser.rb | 26 +- lib/transpec/syntax/rspec_configure.rb | 10 +- ...modification.rb => config_modification.rb} | 28 +- .../syntax/rspec_configure/framework.rb | 14 +- lib/transpec/syntax/rspec_configure/mocks.rb | 2 +- .../{configuration_spec.rb => config_spec.rb} | 26 +- spec/transpec/converter_spec.rb | 420 +++++++++--------- spec/transpec/option_parser_spec.rb | 50 +-- 11 files changed, 342 insertions(+), 342 deletions(-) rename lib/transpec/{configuration.rb => config.rb} (99%) rename lib/transpec/syntax/rspec_configure/{configuration_modification.rb => config_modification.rb} (69%) rename spec/transpec/{configuration_spec.rb => config_spec.rb} (81%) diff --git a/lib/transpec/cli.rb b/lib/transpec/cli.rb index cbc8120..4b4967d 100644 --- a/lib/transpec/cli.rb +++ b/lib/transpec/cli.rb @@ -1,7 +1,7 @@ # coding: utf-8 require 'transpec/commit_message' -require 'transpec/configuration' +require 'transpec/config' require 'transpec/converter' require 'transpec/dynamic_analyzer' require 'transpec/option_parser' @@ -13,7 +13,7 @@ module Transpec class CLI - attr_reader :project, :configuration, :report + attr_reader :project, :config, :report def self.run(args = ARGV) new.run(args) @@ -21,13 +21,13 @@ def self.run(args = ARGV) def initialize @project = Project.new - @configuration = Configuration.new + @config = Config.new @report = Report.new end def run(args) begin - paths = OptionParser.new(configuration).parse(args) + paths = OptionParser.new(config).parse(args) fail_if_should_not_continue! rescue => error warn error.message @@ -51,7 +51,7 @@ def run(args) def process(paths) runtime_data = nil - unless configuration.skip_dynamic_analysis? + unless config.skip_dynamic_analysis? runtime_data = run_dynamic_analysis(paths) end @@ -70,7 +70,7 @@ def process(paths) def convert_spec(spec, spec_suite) puts "Converting #{spec.path}" - converter = Converter.new(spec_suite, configuration, project.rspec_version) + converter = Converter.new(spec_suite, config, project.rspec_version) converter.convert_file!(spec) warn_annotations(converter.report) @@ -83,7 +83,7 @@ def convert_spec(spec, spec_suite) private def fail_if_should_not_continue! - unless configuration.forced? + unless config.forced? if Git.command_available? && Git.inside_of_repository? && !Git.clean? fail 'The current Git repository is not clean. Aborting. ' \ 'If you want to proceed forcibly, use -f/--force option.' @@ -101,7 +101,7 @@ def run_dynamic_analysis(paths) puts 'Copying the project for dynamic analysis...' - DynamicAnalyzer.new(rspec_command: configuration.rspec_command) do |analyzer| + DynamicAnalyzer.new(rspec_command: config.rspec_command) do |analyzer| puts "Running dynamic analysis with command #{analyzer.rspec_command.inspect}..." runtime_data = analyzer.analyze(paths) end diff --git a/lib/transpec/configuration.rb b/lib/transpec/config.rb similarity index 99% rename from lib/transpec/configuration.rb rename to lib/transpec/config.rb index ad59126..d1a8417 100644 --- a/lib/transpec/configuration.rb +++ b/lib/transpec/config.rb @@ -1,7 +1,7 @@ # coding: utf-8 module Transpec - class Configuration + class Config NEGATIVE_FORMS_OF_TO = ['not_to', 'to_not'].freeze FORMS_OF_BE_FALSEY = ['be_falsey', 'be_falsy'].freeze BOOLEAN_MATCHER_TYPES = [:conditional, :exact].freeze diff --git a/lib/transpec/converter.rb b/lib/transpec/converter.rb index e3fff9f..5eb09ce 100644 --- a/lib/transpec/converter.rb +++ b/lib/transpec/converter.rb @@ -1,7 +1,7 @@ # coding: utf-8 require 'transpec/base_rewriter' -require 'transpec/configuration' +require 'transpec/config' require 'transpec/report' require 'transpec/rspec_version' require 'transpec/spec_suite' @@ -13,15 +13,15 @@ module Transpec class Converter < BaseRewriter # rubocop:disable ClassLength include Syntax::Dispatcher - attr_reader :spec_suite, :configuration, :rspec_version, :report + attr_reader :spec_suite, :config, :rspec_version, :report alias_method :convert_file!, :rewrite_file! alias_method :convert_source, :rewrite_source alias_method :convert, :rewrite - def initialize(spec_suite = nil, configuration = nil, rspec_version = nil) + def initialize(spec_suite = nil, config = nil, rspec_version = nil) @spec_suite = spec_suite || SpecSuite.new - @configuration = configuration || Configuration.new + @config = config || Config.new @rspec_version = rspec_version || Transpec.required_rspec_version @report = Report.new end @@ -44,161 +44,161 @@ def process(ast, source_rewriter) end def process_should(should) - return unless configuration.convert_should? - should.expectize!(configuration.negative_form_of_to) + return unless config.convert_should? + should.expectize!(config.negative_form_of_to) end def process_oneliner_should(oneliner_should) - negative_form = configuration.negative_form_of_to - should_convert_have_items = configuration.convert_have_items? && + negative_form = config.negative_form_of_to + should_convert_have_items = config.convert_have_items? && oneliner_should.have_matcher.conversion_target? if should_convert_have_items - if configuration.convert_should? + if config.convert_should? oneliner_should.convert_have_items_to_standard_expect!(negative_form) else oneliner_should.convert_have_items_to_standard_should! end - elsif configuration.convert_oneliner? && rspec_version.oneliner_is_expected_available? + elsif config.convert_oneliner? && rspec_version.oneliner_is_expected_available? oneliner_should.expectize!(negative_form) end end def process_should_receive(should_receive) if should_receive.useless_expectation? - if configuration.convert_deprecated_method? - if configuration.convert_stub? - should_receive.allowize_useless_expectation!(configuration.negative_form_of_to) + if config.convert_deprecated_method? + if config.convert_stub? + should_receive.allowize_useless_expectation!(config.negative_form_of_to) else should_receive.stubize_useless_expectation! end - elsif configuration.convert_should_receive? - should_receive.expectize!(configuration.negative_form_of_to) + elsif config.convert_should_receive? + should_receive.expectize!(config.negative_form_of_to) end - elsif configuration.convert_should_receive? - should_receive.expectize!(configuration.negative_form_of_to) + elsif config.convert_should_receive? + should_receive.expectize!(config.negative_form_of_to) end end def process_double(double) - double.convert_to_double! if configuration.convert_deprecated_method? + double.convert_to_double! if config.convert_deprecated_method? end def process_method_stub(method_stub) - if configuration.convert_stub? + if config.convert_stub? if !method_stub.hash_arg? || rspec_version.receive_messages_available? || - configuration.convert_stub_with_hash_to_allow_to_receive_and_return? + config.convert_stub_with_hash_to_allow_to_receive_and_return? method_stub.allowize!(rspec_version) - elsif configuration.convert_deprecated_method? + elsif config.convert_deprecated_method? method_stub.convert_deprecated_method! end - elsif configuration.convert_deprecated_method? + elsif config.convert_deprecated_method? method_stub.convert_deprecated_method! end - method_stub.remove_no_message_allowance! if configuration.convert_deprecated_method? + method_stub.remove_no_message_allowance! if config.convert_deprecated_method? end def process_operator(operator) - return unless configuration.convert_should? + return unless config.convert_should? return if operator.expectation.is_a?(Syntax::OnelinerShould) && !rspec_version.oneliner_is_expected_available? - operator.convert_operator!(configuration.parenthesize_matcher_arg?) + operator.convert_operator!(config.parenthesize_matcher_arg?) end def process_be_boolean(be_boolean) return unless rspec_version.be_truthy_available? - return unless configuration.convert_deprecated_method? + return unless config.convert_deprecated_method? - case configuration.boolean_matcher_type + case config.boolean_matcher_type when :conditional - be_boolean.convert_to_conditional_matcher!(configuration.form_of_be_falsey) + be_boolean.convert_to_conditional_matcher!(config.form_of_be_falsey) when :exact be_boolean.convert_to_exact_matcher! end end def process_be_close(be_close) - be_close.convert_to_be_within! if configuration.convert_deprecated_method? + be_close.convert_to_be_within! if config.convert_deprecated_method? end def process_raise_error(raise_error) return unless raise_error - if configuration.convert_deprecated_method? + if config.convert_deprecated_method? raise_error.remove_error_specification_with_negative_expectation! end end def process_its(its) - its.convert_to_describe_subject_it! if configuration.convert_its? + its.convert_to_describe_subject_it! if config.convert_its? end def process_example(example) - return if !rspec_version.rspec_2_99? || !configuration.convert_pending? + return if !rspec_version.rspec_2_99? || !config.convert_pending? example.convert_pending_to_skip! end def process_pending(pending) - return if !rspec_version.rspec_2_99? || !configuration.convert_pending? + return if !rspec_version.rspec_2_99? || !config.convert_pending? pending.convert_deprecated_syntax! end def process_current_example(current_example) return unless rspec_version.yielded_example_available? - current_example.convert! if configuration.convert_deprecated_method? + current_example.convert! if config.convert_deprecated_method? end def process_matcher_definition(matcher_definition) return unless rspec_version.non_should_matcher_protocol_available? - matcher_definition.convert_deprecated_method! if configuration.convert_deprecated_method? + matcher_definition.convert_deprecated_method! if config.convert_deprecated_method? end def process_example_group(example_group) return unless rspec_version.non_monkey_patch_example_group_available? - example_group.convert_to_non_monkey_patch! if configuration.convert_example_group? + example_group.convert_to_non_monkey_patch! if config.convert_example_group? end def process_rspec_configure(rspec_configure) return unless spec_suite.main_rspec_configure_node?(rspec_configure.node) if rspec_version.non_monkey_patch_example_group_available? && - configuration.convert_example_group? + config.convert_example_group? rspec_configure.expose_dsl_globally = false end if need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config? - should_yield = configuration.add_receiver_arg_to_any_instance_implementation_block? + should_yield = config.add_receiver_arg_to_any_instance_implementation_block? rspec_configure.mocks.yield_receiver_to_any_instance_implementation_blocks = should_yield end end def process_have(have) - return if !have || !configuration.convert_have_items? - have.convert_to_standard_expectation!(configuration.parenthesize_matcher_arg) + return if !have || !config.convert_have_items? + have.convert_to_standard_expectation!(config.parenthesize_matcher_arg) end def process_hook(hook) - return if !configuration.convert_hook_scope? || !rspec_version.hook_scope_alias_available? + return if !config.convert_hook_scope? || !rspec_version.hook_scope_alias_available? hook.convert_scope_name! end def process_useless_and_return(messaging_host) return unless messaging_host - return unless configuration.convert_deprecated_method? + return unless config.convert_deprecated_method? messaging_host.remove_useless_and_return! end def process_any_instance_block(messaging_host) return unless messaging_host return unless rspec_version.rspec_2_99? - return unless configuration.convert_deprecated_method? - return unless configuration.add_receiver_arg_to_any_instance_implementation_block? + return unless config.convert_deprecated_method? + return unless config.add_receiver_arg_to_any_instance_implementation_block? messaging_host.add_receiver_arg_to_any_instance_implementation_block! end def need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config? - rspec_version.rspec_2_99? && configuration.convert_deprecated_method? && + rspec_version.rspec_2_99? && config.convert_deprecated_method? && spec_suite.need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config? end end diff --git a/lib/transpec/option_parser.rb b/lib/transpec/option_parser.rb index 761ac81..9641f60 100644 --- a/lib/transpec/option_parser.rb +++ b/lib/transpec/option_parser.rb @@ -1,6 +1,6 @@ # coding: utf-8 -require 'transpec/configuration' +require 'transpec/config' require 'transpec/git' require 'transpec/version' require 'optparse' @@ -28,14 +28,14 @@ class OptionParser # rubocop:disable ClassLength VALID_BOOLEAN_MATCHER_TYPES = %w(truthy,falsey truthy,falsy true,false) - attr_reader :configuration + attr_reader :config def self.available_conversion_types CONFIG_ATTRS_FOR_KEEP_TYPES.keys end - def initialize(configuration = Configuration.new) - @configuration = configuration + def initialize(config = Config.new) + @config = config setup_parser end @@ -55,11 +55,11 @@ def setup_parser # rubocop:disable MethodLength @parser = create_parser define_option('-f', '--force') do - configuration.forced = true + config.forced = true end define_option('-c', '--rspec-command COMMAND') do |command| - configuration.rspec_command = command + config.rspec_command = command end define_option('-k', '--keep TYPE[,TYPE...]') do |types| @@ -71,11 +71,11 @@ def setup_parser # rubocop:disable MethodLength end define_option('-s', '--skip-dynamic-analysis') do - configuration.skip_dynamic_analysis = true + config.skip_dynamic_analysis = true end define_option('-n', '--negative-form FORM') do |form| - configuration.negative_form_of_to = form + config.negative_form_of_to = form end define_option('-b', '--boolean-matcher TYPE') do |type| @@ -83,16 +83,16 @@ def setup_parser # rubocop:disable MethodLength types = VALID_BOOLEAN_MATCHER_TYPES.map(&:inspect).join(', ') fail ArgumentError, "Boolean matcher type must be any of #{types}" end - configuration.boolean_matcher_type = type.include?('truthy') ? :conditional : :exact - configuration.form_of_be_falsey = type.include?('falsy') ? 'be_falsy' : 'be_falsey' + config.boolean_matcher_type = type.include?('truthy') ? :conditional : :exact + config.form_of_be_falsey = type.include?('falsy') ? 'be_falsy' : 'be_falsey' end define_option('-a', '--no-yield-any-instance') do - configuration.add_receiver_arg_to_any_instance_implementation_block = false + config.add_receiver_arg_to_any_instance_implementation_block = false end define_option('-p', '--no-parentheses-matcher-arg') do - configuration.parenthesize_matcher_arg = false + config.parenthesize_matcher_arg = false end define_option('--no-color') do @@ -222,7 +222,7 @@ def configure_conversion(type_to_attr_map, inputted_types, boolean) inputted_types.split(',').each do |type| config_attr = type_to_attr_map[type.to_sym] fail ArgumentError, "Unknown syntax type #{type.inspect}" unless config_attr - configuration.send(config_attr, boolean) + config.send(config_attr, boolean) end end end diff --git a/lib/transpec/syntax/rspec_configure.rb b/lib/transpec/syntax/rspec_configure.rb index 8692c99..ee737fc 100644 --- a/lib/transpec/syntax/rspec_configure.rb +++ b/lib/transpec/syntax/rspec_configure.rb @@ -8,11 +8,11 @@ module Transpec class Syntax class RSpecConfigure < Syntax - require 'transpec/syntax/rspec_configure/configuration_modification' + require 'transpec/syntax/rspec_configure/config_modification' require 'transpec/syntax/rspec_configure/expectations' require 'transpec/syntax/rspec_configure/mocks' - include Mixin::Send, Mixin::RSpecRails, ConfigurationModification + include Mixin::Send, Mixin::RSpecRails, ConfigModification define_dynamic_analysis do |rewriter| code = "TranspecAnalysis.global_data[:rspec_configure_run_order] ||= 0\n" \ @@ -26,17 +26,17 @@ def dynamic_analysis_target? end def expose_dsl_globally=(boolean) - set_configuration!(:expose_dsl_globally, boolean) + set_config!(:expose_dsl_globally, boolean) end def infer_spec_type_from_file_location! return if infer_spec_type_from_file_location? return unless rspec_rails? - add_configuration!(:infer_spec_type_from_file_location!) + add_config!(:infer_spec_type_from_file_location!) end def infer_spec_type_from_file_location? - !find_configuration_node(:infer_spec_type_from_file_location!).nil? + !find_config_node(:infer_spec_type_from_file_location!).nil? end def expectations diff --git a/lib/transpec/syntax/rspec_configure/configuration_modification.rb b/lib/transpec/syntax/rspec_configure/config_modification.rb similarity index 69% rename from lib/transpec/syntax/rspec_configure/configuration_modification.rb rename to lib/transpec/syntax/rspec_configure/config_modification.rb index 53c66ef..5203094 100644 --- a/lib/transpec/syntax/rspec_configure/configuration_modification.rb +++ b/lib/transpec/syntax/rspec_configure/config_modification.rb @@ -6,7 +6,7 @@ module Transpec class Syntax class RSpecConfigure - module ConfigurationModification + module ConfigModification include Util, ::AST::Sexp def block_node @@ -15,27 +15,27 @@ def block_node private - def set_configuration!(config_name, value) - setter_node = find_configuration_node("#{config_name}=") + def set_config!(config_name, value) + setter_node = find_config_node("#{config_name}=") if setter_node arg_node = setter_node.children[2] source_rewriter.replace(arg_node.loc.expression, value.to_s) else - add_configuration!(config_name, value) + add_config!(config_name, value) end end - def find_configuration_node(configuration_method_name) + def find_config_node(config_method_name) return nil unless block_node - configuration_method_name = configuration_method_name.to_sym + config_method_name = config_method_name.to_sym block_node.each_descendent_node.find do |node| next unless node.send_type? receiver_node, method_name, = *node next unless receiver_node == s(:lvar, block_arg_name) - method_name == configuration_method_name + method_name == config_method_name end end @@ -45,19 +45,19 @@ def block_arg_name end # TODO: Refactor this to remove messy overrides in Framework. - module ConfigurationAddition - def add_configuration!(config_name, value = nil) - lines = generate_configuration_lines(config_name, value) + module ConfigAddition + def add_config!(config_name, value = nil) + lines = generate_config_lines(config_name, value) lines.unshift('') unless empty_block_body? lines.map! { |line| line + "\n" } insertion_position = beginning_of_line_range(block_node_to_insert_code.loc.end) source_rewriter.insert_before(insertion_position, lines.join('')) - block_node_to_insert_code.metadata[:added_configuration] = true + block_node_to_insert_code.metadata[:added_config] = true end - def generate_configuration_lines(config_name, value = nil) + def generate_config_lines(config_name, value = nil) line = body_indentation + "#{config_variable_name}.#{config_name}" line << " = #{value}" unless value.nil? [line] @@ -78,11 +78,11 @@ def block_node_to_insert_code def empty_block_body? block_node = block_node_to_insert_code (block_node.loc.end.line - block_node.loc.begin.line <= 1) && - !block_node.metadata[:added_configuration] + !block_node.metadata[:added_config] end end - include ConfigurationAddition + include ConfigAddition end end end diff --git a/lib/transpec/syntax/rspec_configure/framework.rb b/lib/transpec/syntax/rspec_configure/framework.rb index 71f5594..0496570 100644 --- a/lib/transpec/syntax/rspec_configure/framework.rb +++ b/lib/transpec/syntax/rspec_configure/framework.rb @@ -1,12 +1,12 @@ # coding: utf-8 -require 'transpec/syntax/rspec_configure/configuration_modification' +require 'transpec/syntax/rspec_configure/config_modification' module Transpec class Syntax class RSpecConfigure class Framework - include ConfigurationModification + include ConfigModification attr_reader :rspec_configure, :source_rewriter @@ -34,7 +34,7 @@ def block_method_name fail NotImplementedError end - def generate_configuration_lines(config_name, value = nil) + def generate_config_lines(config_name, value = nil) lines = super unless block_node @@ -86,7 +86,7 @@ def rspec_configure_body_indentation indentation_of_line(rspec_configure.node) + (' ' * 2) end - module SyntaxConfiguration + module SyntaxConfig def syntaxes return [] unless syntaxes_node @@ -107,7 +107,7 @@ def syntaxes=(syntaxes) fail ArgumentError, 'Syntaxes must be either an array or a symbol.' end - set_configuration!(:syntax, syntaxes.inspect) + set_config!(:syntax, syntaxes.inspect) end private @@ -115,7 +115,7 @@ def syntaxes=(syntaxes) def syntaxes_node return @syntaxes_node if instance_variable_defined?(:@syntaxes_node) - syntax_setter_node = find_configuration_node(:syntax=) + syntax_setter_node = find_config_node(:syntax=) @syntaxes_node = if syntax_setter_node syntax_setter_node.children[2] @@ -127,7 +127,7 @@ def syntaxes_node class UnknownSyntaxError < StandardError; end end - include SyntaxConfiguration + include SyntaxConfig end end end diff --git a/lib/transpec/syntax/rspec_configure/mocks.rb b/lib/transpec/syntax/rspec_configure/mocks.rb index 75aa994..40c0833 100644 --- a/lib/transpec/syntax/rspec_configure/mocks.rb +++ b/lib/transpec/syntax/rspec_configure/mocks.rb @@ -11,7 +11,7 @@ def block_method_name end def yield_receiver_to_any_instance_implementation_blocks=(boolean) - set_configuration!(:yield_receiver_to_any_instance_implementation_blocks, boolean) + set_config!(:yield_receiver_to_any_instance_implementation_blocks, boolean) end end end diff --git a/spec/transpec/configuration_spec.rb b/spec/transpec/config_spec.rb similarity index 81% rename from spec/transpec/configuration_spec.rb rename to spec/transpec/config_spec.rb index d7053ca..170c64c 100644 --- a/spec/transpec/configuration_spec.rb +++ b/spec/transpec/config_spec.rb @@ -1,11 +1,11 @@ # coding: utf-8 require 'spec_helper' -require 'transpec/configuration' +require 'transpec/config' module Transpec - describe Configuration do - subject(:configuration) { Configuration.new } + describe Config do + subject(:config) { Config.new } context 'by default' do [ @@ -29,7 +29,7 @@ module Transpec [:parenthesize_matcher_arg?, true] ].each do |attribute, value| describe "##{attribute}" do - subject { configuration.send(attribute) } + subject { config.send(attribute) } it "is #{value.inspect}" do should == value @@ -42,8 +42,8 @@ module Transpec ['not_to', 'to_not'] .each do |form| context "when #{form.inspect} is passed" do it "sets #{form.inspect}" do - configuration.negative_form_of_to = form - configuration.negative_form_of_to.should == form + config.negative_form_of_to = form + config.negative_form_of_to.should == form end end end @@ -51,7 +51,7 @@ module Transpec context 'when a form other than "not_to" or "to_not" is passed' do it 'raises error' do lambda do - configuration.negative_form_of_to = 'foo' + config.negative_form_of_to = 'foo' end.should raise_error(ArgumentError) end end @@ -61,8 +61,8 @@ module Transpec [:conditional, :exact] .each do |type| context "when #{type.inspect} is passed" do it "sets #{type.inspect}" do - configuration.boolean_matcher_type = type - configuration.boolean_matcher_type.should == type + config.boolean_matcher_type = type + config.boolean_matcher_type.should == type end end end @@ -70,7 +70,7 @@ module Transpec context 'when a type other than :conditional or :exact is passed' do it 'raises error' do lambda do - configuration.boolean_matcher_type = :foo + config.boolean_matcher_type = :foo end.should raise_error(ArgumentError) end end @@ -80,8 +80,8 @@ module Transpec ['be_falsey', 'be_falsy'] .each do |form| context "when #{form.inspect} is passed" do it "sets #{form.inspect}" do - configuration.form_of_be_falsey = form - configuration.form_of_be_falsey.should == form + config.form_of_be_falsey = form + config.form_of_be_falsey.should == form end end end @@ -89,7 +89,7 @@ module Transpec context 'when a form other than "be_falsey" or "be_falsy" is passed' do it 'raises error' do lambda do - configuration.form_of_be_falsey = 'foo' + config.form_of_be_falsey = 'foo' end.should raise_error(ArgumentError) end end diff --git a/spec/transpec/converter_spec.rb b/spec/transpec/converter_spec.rb index acfd5a3..45d378e 100644 --- a/spec/transpec/converter_spec.rb +++ b/spec/transpec/converter_spec.rb @@ -5,9 +5,9 @@ module Transpec describe Converter do - subject(:converter) { Converter.new(spec_suite, configuration, rspec_version) } + subject(:converter) { Converter.new(spec_suite, config, rspec_version) } let(:spec_suite) { double('spec_suite', runtime_data: nil).as_null_object } - let(:configuration) { Configuration.new } + let(:config) { Config.new } let(:rspec_version) { Transpec.required_rspec_version } describe '#convert_file!' do @@ -107,7 +107,7 @@ module Transpec end before do - configuration.convert_stub_with_hash_to_allow_to_receive_and_return = true + config.convert_stub_with_hash_to_allow_to_receive_and_return = true end it 'converts all targets properly' do @@ -122,7 +122,7 @@ module Transpec context 'when the source has a monkey-patched expectation outside of example group context' do before do - configuration.convert_should = true + config.convert_should = true converter.stub(:warn) end @@ -157,11 +157,11 @@ def some_method let(:should_object) { double('should_object', raise_error_matcher: raise_error_object).as_null_object } let(:raise_error_object) { double('raise_error_object').as_null_object } - context 'when Configuration#convert_should? is true' do - before { configuration.convert_should = true } + context 'when Config#convert_should? is true' do + before { config.convert_should = true } - context 'and Configuration#negative_form_of_to is "not_to"' do - before { configuration.negative_form_of_to = 'not_to' } + context 'and Config#negative_form_of_to is "not_to"' do + before { config.negative_form_of_to = 'not_to' } it 'invokes Should#expectize! with "not_to"' do should_object.should_receive(:expectize!).with('not_to') @@ -169,8 +169,8 @@ def some_method end end - context 'and Configuration#negative_form_of_to is "to_not"' do - before { configuration.negative_form_of_to = 'to_not' } + context 'and Config#negative_form_of_to is "to_not"' do + before { config.negative_form_of_to = 'to_not' } it 'invokes Should#expectize! with "to_not"' do should_object.should_receive(:expectize!).with('to_not') @@ -179,8 +179,8 @@ def some_method end end - context 'when Configuration#convert_should? is false' do - before { configuration.convert_should = false } + context 'when Config#convert_should? is false' do + before { config.convert_should = false } it 'does not invoke Should#expectize!' do should_object.should_not_receive(:expectize!) @@ -227,8 +227,8 @@ def some_method end shared_examples 'converts to standard expecatations' do - context 'and Configuration#convert_should? is true' do - before { configuration.convert_should = true } + context 'and Config#convert_should? is true' do + before { config.convert_should = true } it 'invokes OnelinerShould#convert_have_items_to_standard_expect!' do should_object.should_receive(:convert_have_items_to_standard_expect!) @@ -236,8 +236,8 @@ def some_method end end - context 'and Configuration#convert_should? is false' do - before { configuration.convert_should = false } + context 'and Config#convert_should? is false' do + before { config.convert_should = false } it 'invokes OnelinerShould#convert_have_items_to_standard_should!' do should_object.should_receive(:convert_have_items_to_standard_should!) @@ -246,21 +246,21 @@ def some_method end end - context 'when Configuration#convert_oneliner? is true' do - before { configuration.convert_oneliner = true } + context 'when Config#convert_oneliner? is true' do + before { config.convert_oneliner = true } context 'and the #have matcher is conversion target' do before do have_object.stub(:conversion_target?).and_return(true) end - context 'and Configuration#convert_have_items? is true' do - before { configuration.convert_have_items = true } + context 'and Config#convert_have_items? is true' do + before { config.convert_have_items = true } include_examples 'converts to standard expecatations' end - context 'and Configuration#convert_have_items? is false' do - before { configuration.convert_have_items = false } + context 'and Config#convert_have_items? is false' do + before { config.convert_have_items = false } include_examples 'invokes OnelinerShould#expectize! if available' end end @@ -270,33 +270,33 @@ def some_method have_object.stub(:conversion_target?).and_return(false) end - context 'and Configuration#convert_have_items? is true' do - before { configuration.convert_have_items = true } + context 'and Config#convert_have_items? is true' do + before { config.convert_have_items = true } include_examples 'invokes OnelinerShould#expectize! if available' end - context 'and Configuration#convert_have_items? is false' do - before { configuration.convert_have_items = false } + context 'and Config#convert_have_items? is false' do + before { config.convert_have_items = false } include_examples 'invokes OnelinerShould#expectize! if available' end end end - context 'when Configuration#convert_oneliner? is false' do - before { configuration.convert_oneliner = false } + context 'when Config#convert_oneliner? is false' do + before { config.convert_oneliner = false } context 'and the #have matcher is conversion target' do before do have_object.stub(:conversion_target?).and_return(true) end - context 'and Configuration#convert_have_items? is true' do - before { configuration.convert_have_items = true } + context 'and Config#convert_have_items? is true' do + before { config.convert_have_items = true } include_examples 'converts to standard expecatations' end - context 'and Configuration#convert_have_items? is false' do - before { configuration.convert_have_items = false } + context 'and Config#convert_have_items? is false' do + before { config.convert_have_items = false } include_examples 'does nothing' end end @@ -306,13 +306,13 @@ def some_method have_object.stub(:conversion_target?).and_return(false) end - context 'and Configuration#convert_have_items? is true' do - before { configuration.convert_have_items = true } + context 'and Config#convert_have_items? is true' do + before { config.convert_have_items = true } include_examples 'does nothing' end - context 'and Configuration#convert_have_items? is false' do - before { configuration.convert_have_items = false } + context 'and Config#convert_have_items? is false' do + before { config.convert_have_items = false } include_examples 'does nothing' end end @@ -334,18 +334,18 @@ def some_method context 'when ShouldReceive#useless_expectation? returns true' do before { should_receive_object.stub(:useless_expectation?).and_return(true) } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } - context 'and Configuration#convert_stub? is true' do - before { configuration.convert_stub = true } + context 'and Config#convert_stub? is true' do + before { config.convert_stub = true } [true, false].each do |convert_should_receive| - context "and Configuration#convert_should_receive? is #{convert_should_receive}" do - before { configuration.convert_should_receive = convert_should_receive } + context "and Config#convert_should_receive? is #{convert_should_receive}" do + before { config.convert_should_receive = convert_should_receive } - context 'and Configuration#negative_form_of_to is "not_to"' do - before { configuration.negative_form_of_to = 'not_to' } + context 'and Config#negative_form_of_to is "not_to"' do + before { config.negative_form_of_to = 'not_to' } it 'invokes ShouldReceive#allowize_useless_expectation! with "not_to"' do should_receive_object.should_receive(:allowize_useless_expectation!).with('not_to') @@ -353,8 +353,8 @@ def some_method end end - context 'and Configuration#negative_form_of_to is "to_not"' do - before { configuration.negative_form_of_to = 'to_not' } + context 'and Config#negative_form_of_to is "to_not"' do + before { config.negative_form_of_to = 'to_not' } it 'invokes ShouldReceive#allowize_useless_expectation! with "to_not"' do should_receive_object.should_receive(:allowize_useless_expectation!).with('to_not') @@ -365,12 +365,12 @@ def some_method end end - context 'and Configuration#convert_stub? is false' do - before { configuration.convert_stub = false } + context 'and Config#convert_stub? is false' do + before { config.convert_stub = false } [true, false].each do |convert_should_receive| - context "and Configuration#convert_should_receive? is #{convert_should_receive}" do - before { configuration.convert_should_receive = convert_should_receive } + context "and Config#convert_should_receive? is #{convert_should_receive}" do + before { config.convert_should_receive = convert_should_receive } it 'invokes ShouldReceive#stubize_useless_expectation!' do should_receive_object.should_receive(:stubize_useless_expectation!) @@ -381,18 +381,18 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } [true, false].each do |convert_stub| - context "and Configuration#convert_stub? is #{convert_stub}" do - before { configuration.convert_stub = convert_stub } + context "and Config#convert_stub? is #{convert_stub}" do + before { config.convert_stub = convert_stub } - context 'and Configuration#convert_should_receive? is true' do - before { configuration.convert_should_receive = true } + context 'and Config#convert_should_receive? is true' do + before { config.convert_should_receive = true } - context 'and Configuration#negative_form_of_to is "not_to"' do - before { configuration.negative_form_of_to = 'not_to' } + context 'and Config#negative_form_of_to is "not_to"' do + before { config.negative_form_of_to = 'not_to' } it 'invokes ShouldReceive#expectize! with "not_to"' do should_receive_object.should_receive(:expectize!).with('not_to') @@ -400,8 +400,8 @@ def some_method end end - context 'and Configuration#negative_form_of_to is "to_not"' do - before { configuration.negative_form_of_to = 'to_not' } + context 'and Config#negative_form_of_to is "to_not"' do + before { config.negative_form_of_to = 'to_not' } it 'invokes ShouldReceive#expectize! with "to_not"' do should_receive_object.should_receive(:expectize!).with('to_not') @@ -410,8 +410,8 @@ def some_method end end - context 'and Configuration#convert_should_receive? is false' do - before { configuration.convert_should_receive = false } + context 'and Config#convert_should_receive? is false' do + before { config.convert_should_receive = false } include_examples 'does nothing' end @@ -423,19 +423,19 @@ def some_method context 'when ShouldReceive#useless_expectation? returns false' do before { should_receive_object.stub(:useless_expectation?).and_return(false) } - context 'and Configuration#convert_should_receive? is true' do - before { configuration.convert_should_receive = true } + context 'and Config#convert_should_receive? is true' do + before { config.convert_should_receive = true } [true, false].each do |convert_deprecated_method| - context "and Configuration#convert_deprecated_method? is #{convert_deprecated_method}" do - before { configuration.convert_deprecated_method = convert_deprecated_method } + context "and Config#convert_deprecated_method? is #{convert_deprecated_method}" do + before { config.convert_deprecated_method = convert_deprecated_method } [true, false].each do |convert_stub| - context "and Configuration#convert_stub? is #{convert_stub}" do - before { configuration.convert_stub = convert_stub } + context "and Config#convert_stub? is #{convert_stub}" do + before { config.convert_stub = convert_stub } - context 'and Configuration#negative_form_of_to is "not_to"' do - before { configuration.negative_form_of_to = 'not_to' } + context 'and Config#negative_form_of_to is "not_to"' do + before { config.negative_form_of_to = 'not_to' } it 'invokes ShouldReceive#expectize! with "not_to"' do should_receive_object.should_receive(:expectize!).with('not_to') @@ -443,8 +443,8 @@ def some_method end end - context 'and Configuration#negative_form_of_to is "to_not"' do - before { configuration.negative_form_of_to = 'to_not' } + context 'and Config#negative_form_of_to is "to_not"' do + before { config.negative_form_of_to = 'to_not' } it 'invokes ShouldReceive#expectize! with "to_not"' do should_receive_object.should_receive(:expectize!).with('to_not') @@ -457,16 +457,16 @@ def some_method end end - context 'and Configuration#convert_should_receive? is false' do - before { configuration.convert_should_receive = false } + context 'and Config#convert_should_receive? is false' do + before { config.convert_should_receive = false } [true, false].each do |convert_deprecated_method| - context "and Configuration#convert_deprecated_method? is #{convert_deprecated_method}" do - before { configuration.convert_deprecated_method = convert_deprecated_method } + context "and Config#convert_deprecated_method? is #{convert_deprecated_method}" do + before { config.convert_deprecated_method = convert_deprecated_method } [true, false].each do |convert_stub| - context "and Configuration#convert_stub? is #{convert_stub}" do - before { configuration.convert_stub = convert_stub } + context "and Config#convert_stub? is #{convert_stub}" do + before { config.convert_stub = convert_stub } include_examples 'does nothing' end @@ -522,11 +522,11 @@ def some_method end end - context 'when Configuration#convert_stub? is true' do - before { configuration.convert_stub = true } + context 'when Config#convert_stub? is true' do + before { config.convert_stub = true } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } context 'and MethodStub#hash_arg? is false' do before { method_stub_object.stub(:hash_arg?).and_return(false) } @@ -538,8 +538,8 @@ def some_method context 'and MethodStub#hash_arg? is true' do before { method_stub_object.stub(:hash_arg?).and_return(true) } - context 'and Configuration#convert_stub_with_hash_to_allow_to_receive_and_return? is true' do - before { configuration.convert_stub_with_hash_to_allow_to_receive_and_return = true } + context 'and Config#convert_stub_with_hash_to_allow_to_receive_and_return? is true' do + before { config.convert_stub_with_hash_to_allow_to_receive_and_return = true } context 'and RSpecVersion#receive_messages_available? is true' do before { rspec_version.stub(:receive_messages_available?).and_return(true) } @@ -556,8 +556,8 @@ def some_method end end - context 'and Configuration#convert_stub_with_hash_to_allow_to_receive_and_return? is false' do - before { configuration.convert_stub_with_hash_to_allow_to_receive_and_return = false } + context 'and Config#convert_stub_with_hash_to_allow_to_receive_and_return? is false' do + before { config.convert_stub_with_hash_to_allow_to_receive_and_return = false } context 'and RSpecVersion#receive_messages_available? is true' do before { rspec_version.stub(:receive_messages_available?).and_return(true) } @@ -576,9 +576,9 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? is false' do + context 'and Config#convert_deprecated_method? is false' do before do - configuration.convert_deprecated_method = false + config.convert_deprecated_method = false method_stub_object.stub(:hash_arg?).and_return(false) end @@ -588,19 +588,19 @@ def some_method end end - context 'when Configuration#convert_stub? is false' do - before { configuration.convert_stub = false } + context 'when Config#convert_stub? is false' do + before { config.convert_stub = false } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } include_examples 'does not invoke MethodStub#allowize!' include_examples 'invokes MethodStub#convert_deprecated_method!' include_examples 'invokes MethodStub#remove_no_message_allowance!' end - context 'and Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } include_examples 'does not invoke MethodStub#allowize!' include_examples 'does not invoke MethodStub#convert_deprecated_method!' @@ -612,8 +612,8 @@ def some_method describe '#process_double' do let(:double_object) { double('double_object').as_null_object } - context 'when Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'when Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'invokes Double#convert_to_double!' do double_object.should_receive(:convert_to_double!) @@ -621,8 +621,8 @@ def some_method end end - context 'when Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'when Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } it 'does nothing' do double_object.should_not_receive(:convert_to_double!) @@ -634,11 +634,11 @@ def some_method describe '#process_operator' do let(:operator_object) { double('operator_object').as_null_object } - context 'when Configuration#convert_should? is true' do - before { configuration.convert_should = true } + context 'when Config#convert_should? is true' do + before { config.convert_should = true } - context 'and Configuration#parenthesize_matcher_arg is true' do - before { configuration.parenthesize_matcher_arg = true } + context 'and Config#parenthesize_matcher_arg is true' do + before { config.parenthesize_matcher_arg = true } it 'invokes Operator#convert_operator! with true' do operator_object.should_receive(:convert_operator!).with(true) @@ -646,8 +646,8 @@ def some_method end end - context 'and Configuration#parenthesize_matcher_arg is false' do - before { configuration.parenthesize_matcher_arg = false } + context 'and Config#parenthesize_matcher_arg is false' do + before { config.parenthesize_matcher_arg = false } it 'invokes Should#expectize! with false as second argument' do operator_object.should_receive(:convert_operator!).with(false) @@ -680,8 +680,8 @@ def some_method end end - context 'when Configuration#convert_should? is false' do - before { configuration.convert_should = false } + context 'when Config#convert_should? is false' do + before { config.convert_should = false } it 'does not invoke Operator#convert_operator!' do operator_object.should_not_receive(:convert_operator!) @@ -696,14 +696,14 @@ def some_method context 'when RSpecVersion#be_truthy_available? returns true' do before { rspec_version.stub(:be_truthy_available?).and_return(true) } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } - context 'and Configuration#boolean_matcher_type is :conditional' do - before { configuration.boolean_matcher_type = :conditional } + context 'and Config#boolean_matcher_type is :conditional' do + before { config.boolean_matcher_type = :conditional } - context 'and Configuration#form_of_be_falsey is "be_falsey"' do - before { configuration.form_of_be_falsey = 'be_falsey' } + context 'and Config#form_of_be_falsey is "be_falsey"' do + before { config.form_of_be_falsey = 'be_falsey' } it 'invokes BeBoolean#convert_to_conditional_matcher! with "be_falsey"' do be_boolean_object.should_receive(:convert_to_conditional_matcher!).with('be_falsey') @@ -711,8 +711,8 @@ def some_method end end - context 'and Configuration#form_of_be_falsey is "be_falsy"' do - before { configuration.form_of_be_falsey = 'be_falsy' } + context 'and Config#form_of_be_falsey is "be_falsy"' do + before { config.form_of_be_falsey = 'be_falsy' } it 'invokes BeBoolean#convert_to_conditional_matcher! with "be_falsy"' do be_boolean_object.should_receive(:convert_to_conditional_matcher!).with('be_falsy') @@ -721,8 +721,8 @@ def some_method end end - context 'and Configuration#boolean_matcher_type is :exact' do - before { configuration.boolean_matcher_type = :exact } + context 'and Config#boolean_matcher_type is :exact' do + before { config.boolean_matcher_type = :exact } it 'invokes BeBoolean#convert_to_exact_matcher!' do be_boolean_object.should_receive(:convert_to_exact_matcher!) @@ -731,8 +731,8 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } it 'does nothing' do be_boolean_object.should_not_receive(:convert_to_conditional_matcher!) @@ -756,8 +756,8 @@ def some_method describe '#process_be_close' do let(:be_close_object) { double('be_close_object').as_null_object } - context 'when Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'when Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'invokes BeClose#convert_to_be_within!' do be_close_object.should_receive(:convert_to_be_within!) @@ -765,8 +765,8 @@ def some_method end end - context 'when Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'when Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } it 'does nothing' do be_close_object.should_not_receive(:convert_to_be_within!) @@ -778,11 +778,11 @@ def some_method describe '#process_have' do let(:have_object) { double('have_object').as_null_object } - context 'when Configuration#convert_have_items? is true' do - before { configuration.convert_have_items = true } + context 'when Config#convert_have_items? is true' do + before { config.convert_have_items = true } - context 'and Configuration#parenthesize_matcher_arg is true' do - before { configuration.parenthesize_matcher_arg = true } + context 'and Config#parenthesize_matcher_arg is true' do + before { config.parenthesize_matcher_arg = true } it 'invokes Have#convert_to_standard_expectation! with true' do have_object.should_receive(:convert_to_standard_expectation!).with(true) @@ -790,8 +790,8 @@ def some_method end end - context 'and Configuration#parenthesize_matcher_arg is false' do - before { configuration.parenthesize_matcher_arg = false } + context 'and Config#parenthesize_matcher_arg is false' do + before { config.parenthesize_matcher_arg = false } it 'invokes Have#convert_to_standard_expectation! with false' do have_object.should_receive(:convert_to_standard_expectation!).with(false) @@ -800,8 +800,8 @@ def some_method end end - context 'when Configuration#convert_have_items? is false' do - before { configuration.convert_have_items = false } + context 'when Config#convert_have_items? is false' do + before { config.convert_have_items = false } it 'does not invoke Have#convert_to_standard_expectation!' do have_object.should_not_receive(:convert_to_standard_expectation!) @@ -813,8 +813,8 @@ def some_method describe '#process_hook' do let(:hook_object) { double('hook_object').as_null_object } - context 'when Configuration#convert_hook_scope? is true' do - before { configuration.convert_hook_scope = true } + context 'when Config#convert_hook_scope? is true' do + before { config.convert_hook_scope = true } context 'when RSpecVersion#hook_scope_alias_available? returns true' do before { rspec_version.stub(:hook_scope_alias_available?).and_return(true) } @@ -835,8 +835,8 @@ def some_method end end - context 'when Configuration#convert_hook_scope? is false' do - before { configuration.convert_hook_scope = false } + context 'when Config#convert_hook_scope? is false' do + before { config.convert_hook_scope = false } context 'when RSpecVersion#hook_scope_alias_available? returns true' do before { rspec_version.stub(:hook_scope_alias_available?).and_return(true) } @@ -852,8 +852,8 @@ def some_method describe '#process_raise_error' do let(:raise_error_object) { double('raise_error_object').as_null_object } - context 'when Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'when Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'invokes RaiseError#remove_error_specification_with_negative_expectation!' do raise_error_object.should_receive(:remove_error_specification_with_negative_expectation!) @@ -861,8 +861,8 @@ def some_method end end - context 'when Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'when Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } it 'does nothing' do raise_error_object.should_not_receive(:remove_error_specification_with_negative_expectation!) @@ -874,8 +874,8 @@ def some_method describe '#process_its' do let(:its_object) { double('its_object').as_null_object } - context 'when Configuration#convert_its? is true' do - before { configuration.convert_its = true } + context 'when Config#convert_its? is true' do + before { config.convert_its = true } it 'invokes Its#convert_to_describe_subject_it!' do its_object.should_receive(:convert_to_describe_subject_it!) @@ -883,8 +883,8 @@ def some_method end end - context 'when Configuration#convert_its? is false' do - before { configuration.convert_its = false } + context 'when Config#convert_its? is false' do + before { config.convert_its = false } it 'does nothing' do its_object.should_not_receive(:convert_to_describe_subject_it!) @@ -906,8 +906,8 @@ def some_method context 'when RSpecVersion#rspec_2_99? returns true' do before { rspec_version.stub(:rspec_2_99?).and_return(true) } - context 'and Configuration#convert_pending? returns true' do - before { configuration.convert_pending = true } + context 'and Config#convert_pending? returns true' do + before { config.convert_pending = true } it 'invokes Example#convert_pending_to_skip!' do example_object.should_receive(:convert_pending_to_skip!) @@ -915,8 +915,8 @@ def some_method end end - context 'and Configuration#convert_pending? returns false' do - before { configuration.convert_pending = false } + context 'and Config#convert_pending? returns false' do + before { config.convert_pending = false } include_examples 'does nothing' end end @@ -924,13 +924,13 @@ def some_method context 'when RSpecVersion#rspec_2_99? returns false' do before { rspec_version.stub(:rspec_2_99?).and_return(false) } - context 'and Configuration#convert_pending? returns true' do - before { configuration.convert_pending = true } + context 'and Config#convert_pending? returns true' do + before { config.convert_pending = true } include_examples 'does nothing' end - context 'and Configuration#convert_pending? returns false' do - before { configuration.convert_pending = false } + context 'and Config#convert_pending? returns false' do + before { config.convert_pending = false } include_examples 'does nothing' end end @@ -949,8 +949,8 @@ def some_method context 'when RSpecVersion#rspec_2_99? returns true' do before { rspec_version.stub(:rspec_2_99?).and_return(true) } - context 'and Configuration#convert_pending? returns true' do - before { configuration.convert_pending = true } + context 'and Config#convert_pending? returns true' do + before { config.convert_pending = true } it 'invokes Example#convert_deprecated_syntax!' do pending_object.should_receive(:convert_deprecated_syntax!) @@ -958,8 +958,8 @@ def some_method end end - context 'and Configuration#convert_pending? returns false' do - before { configuration.convert_pending = false } + context 'and Config#convert_pending? returns false' do + before { config.convert_pending = false } include_examples 'does nothing' end end @@ -967,13 +967,13 @@ def some_method context 'when RSpecVersion#rspec_2_99? returns false' do before { rspec_version.stub(:rspec_2_99?).and_return(false) } - context 'and Configuration#convert_pending? returns true' do - before { configuration.convert_pending = true } + context 'and Config#convert_pending? returns true' do + before { config.convert_pending = true } include_examples 'does nothing' end - context 'and Configuration#convert_pending? returns false' do - before { configuration.convert_pending = false } + context 'and Config#convert_pending? returns false' do + before { config.convert_pending = false } include_examples 'does nothing' end end @@ -985,8 +985,8 @@ def some_method context 'when RSpecVersion#yielded_example_available? returns true' do before { rspec_version.stub(:yielded_example_available?).and_return(true) } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'invokes CurrentExample#convert!' do current_example_object.should_receive(:convert!) @@ -994,8 +994,8 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } it 'does nothing' do current_example_object.should_not_receive(:convert!) @@ -1007,8 +1007,8 @@ def some_method context 'when RSpecVersion#yielded_example_available? returns false' do before { rspec_version.stub(:yielded_example_available?).and_return(false) } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'does nothing' do current_example_object.should_not_receive(:convert!) @@ -1024,8 +1024,8 @@ def some_method context 'when RSpecVersion#non_should_matcher_protocol_available? returns true' do before { rspec_version.stub(:non_should_matcher_protocol_available?).and_return(true) } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'invokes MatcherDefinition#convert_deprecated_method!' do matcher_definition.should_receive(:convert_deprecated_method!) @@ -1033,8 +1033,8 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? is false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? is false' do + before { config.convert_deprecated_method = false } it 'does nothing' do matcher_definition.should_not_receive(:convert_deprecated_method!) @@ -1046,8 +1046,8 @@ def some_method context 'when RSpecVersion#non_should_matcher_protocol_available? returns false' do before { rspec_version.stub(:non_should_matcher_protocol_available?).and_return(false) } - context 'and Configuration#convert_deprecated_method? is true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? is true' do + before { config.convert_deprecated_method = true } it 'does nothing' do matcher_definition.should_not_receive(:convert_deprecated_method!) @@ -1063,8 +1063,8 @@ def some_method context 'when RSpecVersion#non_monkey_patch_example_group_available? returns true' do before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(true) } - context 'and Configuration#convert_example_group? is true' do - before { configuration.convert_example_group = true } + context 'and Config#convert_example_group? is true' do + before { config.convert_example_group = true } it 'invokes ExampleGroup#convert_to_non_monkey_patch!' do example_group.should_receive(:convert_to_non_monkey_patch!) @@ -1072,8 +1072,8 @@ def some_method end end - context 'and Configuration#convert_example_group? is false' do - before { configuration.convert_example_group = false } + context 'and Config#convert_example_group? is false' do + before { config.convert_example_group = false } it 'does nothing' do example_group.should_not_receive(:convert_to_non_monkey_patch!) @@ -1085,8 +1085,8 @@ def some_method context 'when RSpecVersion#non_monkey_patch_example_group_available? returns false' do before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(false) } - context 'and Configuration#convert_example_group? is true' do - before { configuration.convert_example_group = true } + context 'and Config#convert_example_group? is true' do + before { config.convert_example_group = true } it 'does nothing' do example_group.should_not_receive(:convert_to_non_monkey_patch!) @@ -1110,22 +1110,22 @@ def some_method rspec_version.stub(:rspec_2_99?).and_return(true) end - context 'and Configuration#convert_deprecated_method? returns true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? returns true' do + before { config.convert_deprecated_method = true } context 'and SpecSuite#main_rspec_configure_node? returns true' do before do spec_suite.stub(:main_rspec_configure_node?).and_return(true) end - context 'and SpecSuite#need_to_modify_yield_receiver_..._configuration? return true' do + context 'and SpecSuite#need_to_modify_yield_receiver_..._config? return true' do before do spec_suite.stub(:need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?) .and_return(true) end - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns true' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = true } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do + before { config.add_receiver_arg_to_any_instance_implementation_block = true } it 'invokes RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks= with true' do rspec_configure.mocks @@ -1134,8 +1134,8 @@ def some_method end end - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns false' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = false } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns false' do + before { config.add_receiver_arg_to_any_instance_implementation_block = false } it 'invokes RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks= with false' do rspec_configure.mocks @@ -1146,14 +1146,14 @@ def some_method end end - context 'and SpecSuite#need_to_modify_yield_receiver_..._configuration? return false' do + context 'and SpecSuite#need_to_modify_yield_receiver_..._config? return false' do before do spec_suite.stub(:need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?) .and_return(false) end - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns true' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = true } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do + before { config.add_receiver_arg_to_any_instance_implementation_block = true } it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=) @@ -1167,8 +1167,8 @@ def some_method spec_suite.stub(:main_rspec_configure_node?).and_return(false) end - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns true' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = true } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do + before { config.add_receiver_arg_to_any_instance_implementation_block = true } it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=) @@ -1178,8 +1178,8 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? returns false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? returns false' do + before { config.convert_deprecated_method = false } it 'does not invoke RSpecConfigure.mocks.yield_receiver_to_any_instance_implementation_blocks=' do rspec_configure.mocks.should_not_receive(:yield_receiver_to_any_instance_implementation_blocks=) @@ -1202,8 +1202,8 @@ def some_method context 'when RSpecVersion#non_monkey_patch_example_group_available? returns true' do before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(true) } - context 'and Configuration#convert_example_group? is true' do - before { configuration.convert_example_group = true } + context 'and Config#convert_example_group? is true' do + before { config.convert_example_group = true } it 'invokes RSpecConfigure#expose_dsl_globally= with false' do rspec_configure.should_receive(:expose_dsl_globally=).with(false) @@ -1211,8 +1211,8 @@ def some_method end end - context 'and Configuration#convert_example_group? is false' do - before { configuration.convert_example_group = false } + context 'and Config#convert_example_group? is false' do + before { config.convert_example_group = false } it 'does nothing' do rspec_configure.should_not_receive(:expose_dsl_globally=) @@ -1224,8 +1224,8 @@ def some_method context 'when RSpecVersion#non_monkey_patch_example_group_available? returns false' do before { rspec_version.stub(:non_monkey_patch_example_group_available?).and_return(false) } - context 'and Configuration#convert_example_group? is true' do - before { configuration.convert_example_group = true } + context 'and Config#convert_example_group? is true' do + before { config.convert_example_group = true } it 'does nothing' do rspec_configure.should_not_receive(:expose_dsl_globally=) @@ -1238,8 +1238,8 @@ def some_method describe '#process_useless_and_return' do let(:messaging_host) { double('messaging host').as_null_object } - context 'when Configuration#convert_deprecated_method? returns true' do - before { configuration.convert_deprecated_method = true } + context 'when Config#convert_deprecated_method? returns true' do + before { config.convert_deprecated_method = true } it 'invokes #remove_useless_and_return!' do messaging_host.should_receive(:remove_useless_and_return!) @@ -1247,8 +1247,8 @@ def some_method end end - context 'when Configuration#convert_deprecated_method? returns false' do - before { configuration.convert_deprecated_method = false } + context 'when Config#convert_deprecated_method? returns false' do + before { config.convert_deprecated_method = false } it 'does nothing' do messaging_host.should_not_receive(:remove_useless_and_return!) @@ -1265,11 +1265,11 @@ def some_method rspec_version.stub(:rspec_2_99?).and_return(true) end - context 'and Configuration#convert_deprecated_method? returns true' do - before { configuration.convert_deprecated_method = true } + context 'and Config#convert_deprecated_method? returns true' do + before { config.convert_deprecated_method = true } - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns true' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = true } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do + before { config.add_receiver_arg_to_any_instance_implementation_block = true } it 'invokes #add_receiver_arg_to_any_instance_implementation_block!' do messaging_host.should_receive(:add_receiver_arg_to_any_instance_implementation_block!) @@ -1277,8 +1277,8 @@ def some_method end end - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns false' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = false } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns false' do + before { config.add_receiver_arg_to_any_instance_implementation_block = false } it 'does nothing' do messaging_host.should_not_receive(:add_instance_arg_to_any_instance_implementation_block!) @@ -1287,11 +1287,11 @@ def some_method end end - context 'and Configuration#convert_deprecated_method? returns false' do - before { configuration.convert_deprecated_method = false } + context 'and Config#convert_deprecated_method? returns false' do + before { config.convert_deprecated_method = false } - context 'and Configuration#add_receiver_arg_to_any_instance_implementation_block? returns true' do - before { configuration.add_receiver_arg_to_any_instance_implementation_block = true } + context 'and Config#add_receiver_arg_to_any_instance_implementation_block? returns true' do + before { config.add_receiver_arg_to_any_instance_implementation_block = true } it 'does nothing' do messaging_host.should_not_receive(:add_instance_arg_to_any_instance_implementation_block!) diff --git a/spec/transpec/option_parser_spec.rb b/spec/transpec/option_parser_spec.rb index cf53aa7..98043d3 100644 --- a/spec/transpec/option_parser_spec.rb +++ b/spec/transpec/option_parser_spec.rb @@ -5,8 +5,8 @@ module Transpec describe OptionParser do - subject(:parser) { OptionParser.new(configuration) } - let(:configuration) { Configuration.new } + subject(:parser) { OptionParser.new(config) } + let(:config) { Config.new } describe '#parse' do subject { parser.parse(args) } @@ -24,18 +24,18 @@ module Transpec describe '-f/--force option' do let(:args) { ['--force'] } - it 'sets Configuration#forced? true' do + it 'sets Config#forced? true' do parser.parse(args) - configuration.forced?.should be_true + config.forced?.should be_true end end describe '-s/--skip-dynamic-analysis option' do let(:args) { ['--skip-dynamic-analysis'] } - it 'sets Configuration#skip_dynamic_analysis? true' do + it 'sets Config#skip_dynamic_analysis? true' do parser.parse(args) - configuration.skip_dynamic_analysis?.should be_true + config.skip_dynamic_analysis?.should be_true end end @@ -73,9 +73,9 @@ module Transpec context "when #{cli_type.inspect} is specified" do let(:args) { ['--keep', cli_type] } - it "sets Configuration##{config_attr} false" do + it "sets Config##{config_attr} false" do parser.parse(args) - configuration.send(config_attr).should be_false + config.send(config_attr).should be_false end end end @@ -85,8 +85,8 @@ module Transpec it 'handles all of them' do parser.parse(args) - configuration.convert_should_receive?.should be_false - configuration.convert_deprecated_method?.should be_false + config.convert_should_receive?.should be_false + config.convert_deprecated_method?.should be_false end end @@ -110,9 +110,9 @@ module Transpec context "when #{cli_type.inspect} is specified" do let(:args) { ['--convert', cli_type] } - it "sets Configuration##{config_attr} true" do + it "sets Config##{config_attr} true" do parser.parse(args) - configuration.send(config_attr).should be_true + config.send(config_attr).should be_true end end end @@ -133,9 +133,9 @@ module Transpec context "when #{form.inspect} is specified" do let(:args) { ['--negative-form', form] } - it "sets Configuration#negative_form_of_to #{form.inspect}" do + it "sets Config#negative_form_of_to #{form.inspect}" do parser.parse(args) - configuration.negative_form_of_to.should == form + config.negative_form_of_to.should == form end end end @@ -146,18 +146,18 @@ module Transpec ['truthy,falsey', :conditional, 'be_falsey'], ['truthy,falsy', :conditional, 'be_falsy'], ['true,false', :exact, 'be_falsey'] - ].each do |cli_type, configuration_type, form_of_be_falsey| + ].each do |cli_type, config_type, form_of_be_falsey| context "when #{cli_type.inspect} is specified" do let(:args) { ['--boolean-matcher', cli_type] } - it "sets Configuration#boolean_matcher_type #{configuration_type.inspect}" do + it "sets Config#boolean_matcher_type #{config_type.inspect}" do parser.parse(args) - configuration.boolean_matcher_type.should == configuration_type + config.boolean_matcher_type.should == config_type end - it "sets Configuration#form_of_be_falsey #{form_of_be_falsey.inspect}" do + it "sets Config#form_of_be_falsey #{form_of_be_falsey.inspect}" do parser.parse(args) - configuration.form_of_be_falsey.should == form_of_be_falsey + config.form_of_be_falsey.should == form_of_be_falsey end end end @@ -176,9 +176,9 @@ module Transpec describe '-a/--no-yield-any-instance option' do let(:args) { ['--no-yield-any-instance'] } - it 'sets Configuration#add_receiver_arg_to_any_instance_implementation_block? false' do + it 'sets Config#add_receiver_arg_to_any_instance_implementation_block? false' do parser.parse(args) - configuration.add_receiver_arg_to_any_instance_implementation_block? + config.add_receiver_arg_to_any_instance_implementation_block? .should be_false end end @@ -190,9 +190,9 @@ module Transpec parser.stub(:warn) end - it 'sets Configuration#convert_stub_with_hash_to_allow_to_receive_and_return? true' do + it 'sets Config#convert_stub_with_hash_to_allow_to_receive_and_return? true' do parser.parse(args) - configuration.convert_stub_with_hash_to_allow_to_receive_and_return?.should be_true + config.convert_stub_with_hash_to_allow_to_receive_and_return?.should be_true end it 'is deprecated' do @@ -207,9 +207,9 @@ module Transpec describe '-p/--no-parentheses-matcher-arg option' do let(:args) { ['--no-parentheses-matcher-arg'] } - it 'sets Configuration#parenthesize_matcher_arg? false' do + it 'sets Config#parenthesize_matcher_arg? false' do parser.parse(args) - configuration.parenthesize_matcher_arg.should be_false + config.parenthesize_matcher_arg.should be_false end end