Class: RSpec::Mocks::Constant
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Inherits: | Object |
Defined in: | rspec-mocks/lib/rspec/mocks/mutate_const.rb |
Overview
Provides information about constants that may (or may not) have been mutated by rspec-mocks.
Class Method Summary
- .new(name) {|_self| ... } ⇒ Constant constructor Internal use only Internal use only
-
.original(name) ⇒ Constant
Queries rspec-mocks to find out information about the named constant.
- .unmutated(name) Internal use only Internal use only
::RSpec::Support::RecursiveConstMethods
- Extended
const_defined_on? | See additional method definition at line 31. |
constants_defined_on | See additional method definition at line 41. |
get_const_defined_on | See additional method definition at line 35. |
normalize_const_name, recursive_const_defined?, recursive_const_get |
Instance Attribute Summary
- #hidden=(value) rw Internal use only Internal use only
- #hidden? ⇒ Boolean rw
- #mutated? ⇒ Boolean readonly
- #name ⇒ String readonly
- #original_value ⇒ Object? rw
- #previously_defined=(value) rw Internal use only Internal use only
- #previously_defined? ⇒ Boolean rw
- #stubbed=(value) rw Internal use only Internal use only
- #stubbed? ⇒ Boolean rw
- #valid_name=(value) rw Internal use only Internal use only
- #valid_name? ⇒ Boolean rw
Instance Method Summary
Class Method Details
.original(name) ⇒ Constant
Queries rspec-mocks to find out information about the named constant.
.unmutated(name)
This method is for internal use only.
[ GitHub ]
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 68
def self.unmutated(name) previously_defined = !!recursive_const_defined?(name) rescue NameError new(name) do |c| c.valid_name = false end else new(name) do |const| const.previously_defined = previously_defined const.original_value = recursive_const_get(name) if previously_defined end end
Instance Attribute Details
#mutated? ⇒ Boolean
(readonly)
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 39
def mutated? @stubbed || @hidden end
#name ⇒ String
(readonly)
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 21
attr_reader :name
#original_value ⇒ Object
? (rw)
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 26
attr_accessor :original_value
#previously_defined=(value) (rw)
This method is for internal use only.
[ GitHub ]
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 29
attr_writer :previously_defined, :stubbed, :hidden, :valid_name
#previously_defined? ⇒ Boolean
(rw)
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 33
def previously_defined? @previously_defined end
#stubbed=(value) (rw)
This method is for internal use only.
[ GitHub ]
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 29
attr_writer :previously_defined, :stubbed, :hidden, :valid_name
#stubbed? ⇒ Boolean
(rw)
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 45
def stubbed? @stubbed end
#valid_name=(value) (rw)
This method is for internal use only.
[ GitHub ]
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 29
attr_writer :previously_defined, :stubbed, :hidden, :valid_name
#valid_name? ⇒ Boolean
(rw)
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 57
def valid_name? @valid_name end
Instance Method Details
#inspect
Alias for #to_s.
# File 'rspec-mocks/lib/rspec/mocks/mutate_const.rb', line 65
alias inspect to_s
#to_s Also known as: #inspect
The default to_s
isn’t very useful, so a custom version is provided.