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.
14 15 16 17 18 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 14 def initialize(name) super reset! @before_rpc = [] end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
10 11 12 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 10 def controller @controller end |
#host ⇒ Object
20 21 22 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 20 def host @host || DEFAULT_HOST end |
#mount_path=(value) ⇒ Object (writeonly) Also known as: mount_path!
Sets the attribute mount_path
11 12 13 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 11 def mount_path=(value) @mount_path = value end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
10 11 12 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 10 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 10 def response @response end |
Instance Method Details
#app ⇒ Object
62 63 64 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 62 def app RailsTwirp.test_app end |
#before_rpc(&block) ⇒ Object
43 44 45 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 43 def before_rpc(&block) @before_rpc << block end |
#https!(value = true) ⇒ Object
30 31 32 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 30 def https!(value = true) @https = value end |
#https? ⇒ Boolean
26 27 28 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 26 def https? @https end |
#reset! ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 34 def reset! @request = nil @response = nil @host = nil @host = nil @https = false @mount_path = "/twirp" end |
#rpc(service, rpc, request, headers: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rails_twirp/testing/integration_test.rb', line 47 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 |