Skip to content

Commit

Permalink
Fix ruby warnings.
Browse files Browse the repository at this point in the history
- lib/rspec/mocks/error_generator.rb:32: warning: assigned but unused variable - expected_args
- lib/rspec/mocks/error_generator.rb:33: warning: assigned but unused variable - actual_args
- lib/rspec/mocks/stub_const.rb:8: warning: shadowing outer local variable - name
- lib/rspec/mocks/stub_const.rb:12: warning: shadowing outer local variable - name
- spec/rspec/mocks/stub_const_spec.rb:60: warning: assigned but unused variable - orig_value
- lib/rspec/mocks/stub_const.rb:233: warning: instance variable @registered_with_mocks_space not initialized


Closes #162.
  • Loading branch information
myronmarston committed Jul 11, 2012
1 parent d9169ca commit f36ad4d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/rspec/mocks/error_generator.rb
Expand Up @@ -31,7 +31,7 @@ def raise_unexpected_message_args_error(expectation, *args)
def raise_missing_default_stub_error(expectation,*args)
expected_args = format_args(*expectation.expected_args)
actual_args = args.collect {|a| format_args(*a)}.join(", ")
__raise "#{intro} received #{expectation.message.inspect} with unexpected arguments\n Please stub a default value first if message might be received with other args as well. \n"
__raise "#{intro} received #{expectation.message.inspect} with unexpected arguments\n expected: #{expected_args}\n got: #{actual_args}\n Please stub a default value first if message might be received with other args as well. \n"
end

# @private
Expand Down
10 changes: 5 additions & 5 deletions lib/rspec/mocks/stub_const.rb
Expand Up @@ -4,12 +4,12 @@ module Mocks
# constant stubbing.
# @api private
module RecursiveConstMethods
def recursive_const_get(name)
name.split('::').inject(Object) { |mod, name| mod.const_get name }
def recursive_const_get(const_name)
const_name.split('::').inject(Object) { |mod, name| mod.const_get name }
end

def recursive_const_defined?(name)
name.split('::').inject([Object, '']) do |(mod, full_name), name|
def recursive_const_defined?(const_name)
const_name.split('::').inject([Object, '']) do |(mod, full_name), name|
yield(full_name, name) if block_given? && !mod.is_a?(Module)
return false unless mod.const_defined?(name)
[mod.const_get(name), [mod, name].join('::')]
Expand Down Expand Up @@ -230,7 +230,7 @@ def rspec_reset
#
# @api private
def self.ensure_registered_with_mocks_space
return if @registered_with_mocks_space
return if defined?(@registered_with_mocks_space) && @registered_with_mocks_space
::RSpec::Mocks.space.add(self)
@registered_with_mocks_space = true
end
Expand Down
1 change: 0 additions & 1 deletion spec/rspec/mocks/stub_const_spec.rb
Expand Up @@ -57,7 +57,6 @@ def change_const_value_to(value)
end

it 'returns the stubbed value' do
orig_value = const
stub_const(const_name, 7).should eq(7)
end
end
Expand Down

0 comments on commit f36ad4d

Please sign in to comment.