Class: Object

Inherits:
BasicObject
Includes:
Spec::Expectations::ObjectExpectations, Spec::Mocks::Methods
Defined in:
lib/spec/runner/extensions/object.rb,
lib/spec.rb,
lib/spec/extensions/object.rb,
lib/spec/mocks/extensions/object.rb,
lib/spec/expectations/extensions/object.rb

Overview

The following copyright applies to Object#copy_instance_variables_from, which we borrowed from active_support.

Copyright © 2004 David Heinemeier Hansson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Instance Method Summary collapse

Methods included from Spec::Expectations::ObjectExpectations

#should, #should_not

Methods included from Spec::Mocks::Methods

#received_message?, #rspec_reset, #rspec_verify, #should_not_receive, #should_receive, #stub!

Instance Method Details

#args_and_options(*args) ⇒ Object



2
3
4
5
# File 'lib/spec/extensions/object.rb', line 2

def args_and_options(*args)
  options = Hash === args.last ? args.pop : {}
  return args, options
end

#copy_instance_variables_from(object, exclude = []) ⇒ Object

From active_support



26
27
28
29
30
31
# File 'lib/spec/runner/extensions/object.rb', line 26

def copy_instance_variables_from(object, exclude = []) # :nodoc:
  exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables
  
  instance_variables = object.instance_variables - exclude.map { |name| name.to_s }
  instance_variables.each { |name| instance_variable_set(name, object.instance_variable_get(name)) }
end

#metaclassObject



10
11
12
# File 'lib/spec.rb', line 10

def metaclass
  class << self; self; end
end