Class: HttpDecoy::Definition
- Inherits:
-
Object
- Object
- HttpDecoy::Definition
- Defined in:
- lib/http_decoy/rspec.rb
Overview
Wraps a named RouteMap and generates an anonymous RSpec helper module.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#route_map ⇒ Object
readonly
Returns the value of attribute route_map.
Instance Method Summary collapse
-
#initialize(name, route_map) ⇒ Definition
constructor
A new instance of Definition.
-
#rspec_helpers ⇒ Object
Returns an anonymous module.
Constructor Details
#initialize(name, route_map) ⇒ Definition
Returns a new instance of Definition.
179 180 181 182 |
# File 'lib/http_decoy/rspec.rb', line 179 def initialize(name, route_map) @name = name @route_map = route_map end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
177 178 179 |
# File 'lib/http_decoy/rspec.rb', line 177 def name @name end |
#route_map ⇒ Object (readonly)
Returns the value of attribute route_map.
177 178 179 |
# File 'lib/http_decoy/rspec.rb', line 177 def route_map @route_map end |
Instance Method Details
#rspec_helpers ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/http_decoy/rspec.rb', line 189 def rspec_helpers definition = self Module.new do include HttpDecoy::RSpec # define_singleton_method closes over `definition` from the outer scope. # `def self.included` would NOT — def never captures outer locals. define_singleton_method(:included) do |base| super(base) base._http_decoy_register(definition.name, definition.route_map) end define_method(:_http_decoy_definition) { definition } end end |