Class: RailsEdgeTest::Dsl::Edge
- Inherits:
-
Struct
- Object
- Struct
- RailsEdgeTest::Dsl::Edge
- Defined in:
- lib/rails_edge_test/dsl/edge.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#controller_class ⇒ Object
Returns the value of attribute controller_class.
-
#description ⇒ Object
Returns the value of attribute description.
Instance Method Summary collapse
- #controller ⇒ Object
-
#initialize(*args) ⇒ Edge
constructor
A new instance of Edge.
- #perform_get(parameters = {}) ⇒ Object
- #produce_elm_file(module_name, ivar: nil) ⇒ Object
- #request ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(*args) ⇒ Edge
Returns a new instance of Edge.
8 9 10 11 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 8 def initialize(*args) super @let_cache = {} end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
6 7 8 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 6 def action @action end |
#controller_class ⇒ Object
Returns the value of attribute controller_class
6 7 8 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 6 def controller_class @controller_class end |
#description ⇒ Object
Returns the value of attribute description
6 7 8 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 6 def description @description end |
Instance Method Details
#controller ⇒ Object
19 20 21 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 19 def controller @controller ||= controller_class.new end |
#perform_get(parameters = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 27 def perform_get(parameters = {}) request.assign_parameters( ::Rails.application.routes, controller_class.controller_path, action.to_s, parameters ) @response = controller.dispatch(action, request) end |
#produce_elm_file(module_name, ivar: nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 38 def produce_elm_file(module_name, ivar: nil) json = produce_json(ivar: ivar) json = json.gsub("\\", "\\\\\\\\") # unbelievably, this replaces \ with \\ filepath = File.join( RailsEdgeTest.configuration.elm_path, 'Edge', controller_class.name.gsub('::','/') ) full_module_name = "#{controller_class.name.gsub('::','.')}.#{module_name}" data = " module Edge.\#{full_module_name} exposing (json)\n\n\n json : String\n json =\n \"\"\"\n \#{json}\n \"\"\"\n ELM\n\n write_file(filepath, module_name+'.elm', data)\nend\n" |
#request ⇒ Object
15 16 17 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 15 def request @request ||= ActionController::TestRequest.new end |
#response ⇒ Object
23 24 25 |
# File 'lib/rails_edge_test/dsl/edge.rb', line 23 def response @response end |