Class: RailsTwirp::IntegrationTest
- Inherits:
-
ActiveSupport::TestCase
- Object
- ActiveSupport::TestCase
- RailsTwirp::IntegrationTest
- Defined in:
- lib/rails_twirp/testing/integration_test.rb
Defined Under Namespace
Classes: Response
Constant Summary collapse
- DEFAULT_HOST =
"www.example.com"
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
- #host ⇒ Object
-
#mount_path ⇒ Object
(also: #mount_path!)
writeonly
Sets the attribute mount_path.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #app ⇒ Object
- #before_rpc(&block) ⇒ Object
- #https!(value = true) ⇒ Object
- #https? ⇒ Boolean
-
#initialize(name) ⇒ IntegrationTest
constructor
A new instance of IntegrationTest.
- #reset! ⇒ Object
- #rpc(service, rpc, request, headers: nil) ⇒ Object
Constructor Details
#initialize(name) ⇒ IntegrationTest
Returns a new instance of IntegrationTest.
12 13 14 15 16 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 12 def initialize(name) super reset! @before_rpc = [] end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
8 9 10 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 8 def controller @controller end |
#host ⇒ Object
18 19 20 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 18 def host @host || DEFAULT_HOST end |
#mount_path=(value) ⇒ Object (writeonly) Also known as: mount_path!
Sets the attribute mount_path
9 10 11 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 9 def mount_path=(value) @mount_path = value end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 8 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 8 def response @response end |
Instance Method Details
#app ⇒ Object
60 61 62 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 60 def app RailsTwirp.test_app end |
#before_rpc(&block) ⇒ Object
41 42 43 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 41 def before_rpc(&block) @before_rpc << block end |
#https!(value = true) ⇒ Object
28 29 30 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 28 def https!(value = true) @https = value end |
#https? ⇒ Boolean
24 25 26 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 24 def https? @https end |
#reset! ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 32 def reset! @request = nil @response = nil @host = nil @host = nil @https = false @mount_path = "/twirp" end |
#rpc(service, rpc, request, headers: nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 45 def rpc(service, rpc, request, headers: nil) @request = request env = build_rack_env(service, rpc, request, headers) @before_rpc.each do |hook| hook.call(env) end status, headers, body = app.call(env) @response = decode_rack_response(service, rpc, status, headers, body) set_controller_from_rack_env(env) @response end |