rails_twirp 0.2.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +21 -0
  3. data/.gitignore +1 -0
  4. data/.standard.yml +4 -0
  5. data/Gemfile +3 -3
  6. data/lib/rails_twirp.rb +2 -0
  7. data/lib/rails_twirp/base.rb +36 -11
  8. data/lib/rails_twirp/engine.rb +29 -9
  9. data/lib/rails_twirp/errors.rb +11 -0
  10. data/lib/rails_twirp/implicit_render.rb +11 -0
  11. data/lib/rails_twirp/instrumentation.rb +32 -0
  12. data/lib/rails_twirp/log_subscriber.rb +64 -0
  13. data/lib/rails_twirp/mapper.rb +83 -0
  14. data/lib/rails_twirp/render_pb.rb +18 -0
  15. data/lib/rails_twirp/rescue.rb +14 -0
  16. data/lib/rails_twirp/route_set.rb +7 -48
  17. data/lib/rails_twirp/testing/integration_test.rb +73 -10
  18. data/lib/rails_twirp/url_for.rb +17 -0
  19. data/lib/rails_twirp/version.rb +1 -1
  20. data/test/dummy/Rakefile +6 -0
  21. data/test/dummy/app/assets/config/manifest.js +2 -0
  22. data/test/dummy/app/assets/images/.keep +0 -0
  23. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  24. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  25. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  26. data/test/dummy/app/controllers/application_controller.rb +2 -0
  27. data/test/dummy/app/controllers/application_twirp_controller.rb +7 -0
  28. data/test/dummy/app/controllers/concerns/.keep +0 -0
  29. data/test/dummy/app/controllers/pings_controller.rb +40 -0
  30. data/test/dummy/app/controllers/testmod/nested/other_controller.rb +10 -0
  31. data/test/dummy/app/helpers/application_helper.rb +2 -0
  32. data/test/dummy/app/helpers/random_helper.rb +5 -0
  33. data/test/dummy/app/javascript/packs/application.js +15 -0
  34. data/test/dummy/app/jobs/application_job.rb +7 -0
  35. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  36. data/test/dummy/app/models/application_record.rb +3 -0
  37. data/test/dummy/app/models/concerns/.keep +0 -0
  38. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  39. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  40. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  41. data/test/dummy/app/views/pings/ping_template.pb.pbbuilder +1 -0
  42. data/test/dummy/bin/generate +3 -0
  43. data/test/dummy/bin/rails +4 -0
  44. data/test/dummy/bin/rake +4 -0
  45. data/test/dummy/bin/setup +33 -0
  46. data/test/dummy/config.ru +6 -0
  47. data/test/dummy/config/application.rb +23 -0
  48. data/test/dummy/config/boot.rb +5 -0
  49. data/test/dummy/config/cable.yml +10 -0
  50. data/test/dummy/config/database.yml +25 -0
  51. data/test/dummy/config/environment.rb +5 -0
  52. data/test/dummy/config/environments/development.rb +76 -0
  53. data/test/dummy/config/environments/production.rb +120 -0
  54. data/test/dummy/config/environments/test.rb +59 -0
  55. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  56. data/test/dummy/config/initializers/assets.rb +12 -0
  57. data/test/dummy/config/initializers/backtrace_silencers.rb +8 -0
  58. data/test/dummy/config/initializers/content_security_policy.rb +28 -0
  59. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  60. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  61. data/test/dummy/config/initializers/inflections.rb +16 -0
  62. data/test/dummy/config/initializers/mime_types.rb +4 -0
  63. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  64. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/test/dummy/config/locales/en.yml +33 -0
  66. data/test/dummy/config/puma.rb +43 -0
  67. data/test/dummy/config/routes.rb +3 -0
  68. data/test/dummy/config/storage.yml +34 -0
  69. data/test/dummy/config/twirp/routes.rb +21 -0
  70. data/test/dummy/lib/assets/.keep +0 -0
  71. data/test/dummy/log/.keep +0 -0
  72. data/test/dummy/proto/api.proto +24 -0
  73. data/test/dummy/proto/api_pb.rb +22 -0
  74. data/test/dummy/proto/api_twirp.rb +24 -0
  75. data/test/dummy/public/404.html +67 -0
  76. data/test/dummy/public/422.html +67 -0
  77. data/test/dummy/public/500.html +66 -0
  78. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  79. data/test/dummy/public/apple-touch-icon.png +0 -0
  80. data/test/dummy/public/favicon.ico +0 -0
  81. data/test/other_controller_test.rb +9 -0
  82. data/test/ping_controller_test.rb +64 -0
  83. data/test/test_helper.rb +10 -1
  84. metadata +138 -2
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ class OtherControllerTest < RailsTwirp::IntegrationTest
4
+ test "modules work" do
5
+ req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
6
+ rpc RPC::DummyAPI::DummyService, "Nested", req
7
+ assert_equal "BoukeBouke", response.double_name
8
+ end
9
+ end
@@ -0,0 +1,64 @@
1
+ require "test_helper"
2
+
3
+ class PingControllerTest < RailsTwirp::IntegrationTest
4
+ test "you can ping it" do
5
+ req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
6
+ rpc RPC::DummyAPI::DummyService, "Ping", req
7
+ assert_equal "BoukeBouke", response.double_name
8
+ end
9
+
10
+ test "you can ping render" do
11
+ req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
12
+ rpc RPC::DummyAPI::DummyService, "PingRender", req
13
+ refute_instance_of Twirp::Error, response
14
+ assert_equal "http://www.example.com/twirp BoukeBouke", response.double_name
15
+ end
16
+
17
+ test "you can ping render with host and https" do
18
+ host! "localhost"
19
+ https!
20
+ req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
21
+ rpc RPC::DummyAPI::DummyService, "PingRender", req
22
+ refute_instance_of Twirp::Error, response
23
+ assert_equal "https://localhost/twirp BoukeBouke", response.double_name
24
+ end
25
+
26
+ test "you can ping template" do
27
+ req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
28
+ rpc RPC::DummyAPI::DummyService, "PingTemplate", req
29
+ refute_instance_of Twirp::Error, response
30
+ assert_equal "BoukeBouke", response.double_name
31
+ end
32
+
33
+ test "error response" do
34
+ req = RPC::DummyAPI::PingRequest.new
35
+ rpc RPC::DummyAPI::DummyService, "ErrorResponse", req
36
+ assert_instance_of Twirp::Error, response
37
+ assert_equal "You are not authenticated!!", response.msg
38
+ assert_equal :unauthenticated, response.code
39
+ end
40
+
41
+ test "raise error" do
42
+ req = RPC::DummyAPI::PingRequest.new
43
+ rpc RPC::DummyAPI::DummyService, "RaiseError", req
44
+ assert_instance_of Twirp::Error, response
45
+ assert_equal "Not found", response.msg
46
+ assert_equal :not_found, response.code
47
+ end
48
+
49
+ test "uncaught error" do
50
+ req = RPC::DummyAPI::PingRequest.new
51
+ rpc RPC::DummyAPI::DummyService, "UncaughtError", req
52
+ assert_instance_of Twirp::Error, response
53
+ assert_equal "Uncaught", response.msg
54
+ assert_equal :internal, response.code
55
+ end
56
+
57
+ test "before error" do
58
+ req = RPC::DummyAPI::PingRequest.new
59
+ rpc RPC::DummyAPI::DummyService, "BeforeError", req
60
+ assert_instance_of Twirp::Error, response
61
+ assert_equal "yOuR ReQuEsT Is mAlFoRmEd", response.msg
62
+ assert_equal :malformed, response.code
63
+ end
64
+ end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,16 @@
1
1
  # Configure Rails Environment
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
- require "rails"
4
+ require_relative "../test/dummy/config/environment"
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
5
6
  require "rails/test_help"
6
7
  require "rails/test_unit/reporter"
7
8
  Rails::TestUnitReporter.executable = "bin/test"
9
+
10
+ # Load fixtures from the engine
11
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
12
+ ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
13
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
14
+ ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
15
+ ActiveSupport::TestCase.fixtures :all
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_twirp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -45,7 +45,9 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/test.yml"
48
49
  - ".gitignore"
50
+ - ".standard.yml"
49
51
  - Gemfile
50
52
  - MIT-LICENSE
51
53
  - README.md
@@ -56,10 +58,81 @@ files:
56
58
  - lib/rails_twirp/application.rb
57
59
  - lib/rails_twirp/base.rb
58
60
  - lib/rails_twirp/engine.rb
61
+ - lib/rails_twirp/errors.rb
62
+ - lib/rails_twirp/implicit_render.rb
63
+ - lib/rails_twirp/instrumentation.rb
64
+ - lib/rails_twirp/log_subscriber.rb
65
+ - lib/rails_twirp/mapper.rb
66
+ - lib/rails_twirp/render_pb.rb
67
+ - lib/rails_twirp/rescue.rb
59
68
  - lib/rails_twirp/route_set.rb
60
69
  - lib/rails_twirp/testing/integration_test.rb
70
+ - lib/rails_twirp/url_for.rb
61
71
  - lib/rails_twirp/version.rb
62
72
  - rails_twirp.gemspec
73
+ - test/dummy/Rakefile
74
+ - test/dummy/app/assets/config/manifest.js
75
+ - test/dummy/app/assets/images/.keep
76
+ - test/dummy/app/assets/stylesheets/application.css
77
+ - test/dummy/app/channels/application_cable/channel.rb
78
+ - test/dummy/app/channels/application_cable/connection.rb
79
+ - test/dummy/app/controllers/application_controller.rb
80
+ - test/dummy/app/controllers/application_twirp_controller.rb
81
+ - test/dummy/app/controllers/concerns/.keep
82
+ - test/dummy/app/controllers/pings_controller.rb
83
+ - test/dummy/app/controllers/testmod/nested/other_controller.rb
84
+ - test/dummy/app/helpers/application_helper.rb
85
+ - test/dummy/app/helpers/random_helper.rb
86
+ - test/dummy/app/javascript/packs/application.js
87
+ - test/dummy/app/jobs/application_job.rb
88
+ - test/dummy/app/mailers/application_mailer.rb
89
+ - test/dummy/app/models/application_record.rb
90
+ - test/dummy/app/models/concerns/.keep
91
+ - test/dummy/app/views/layouts/application.html.erb
92
+ - test/dummy/app/views/layouts/mailer.html.erb
93
+ - test/dummy/app/views/layouts/mailer.text.erb
94
+ - test/dummy/app/views/pings/ping_template.pb.pbbuilder
95
+ - test/dummy/bin/generate
96
+ - test/dummy/bin/rails
97
+ - test/dummy/bin/rake
98
+ - test/dummy/bin/setup
99
+ - test/dummy/config.ru
100
+ - test/dummy/config/application.rb
101
+ - test/dummy/config/boot.rb
102
+ - test/dummy/config/cable.yml
103
+ - test/dummy/config/database.yml
104
+ - test/dummy/config/environment.rb
105
+ - test/dummy/config/environments/development.rb
106
+ - test/dummy/config/environments/production.rb
107
+ - test/dummy/config/environments/test.rb
108
+ - test/dummy/config/initializers/application_controller_renderer.rb
109
+ - test/dummy/config/initializers/assets.rb
110
+ - test/dummy/config/initializers/backtrace_silencers.rb
111
+ - test/dummy/config/initializers/content_security_policy.rb
112
+ - test/dummy/config/initializers/cookies_serializer.rb
113
+ - test/dummy/config/initializers/filter_parameter_logging.rb
114
+ - test/dummy/config/initializers/inflections.rb
115
+ - test/dummy/config/initializers/mime_types.rb
116
+ - test/dummy/config/initializers/permissions_policy.rb
117
+ - test/dummy/config/initializers/wrap_parameters.rb
118
+ - test/dummy/config/locales/en.yml
119
+ - test/dummy/config/puma.rb
120
+ - test/dummy/config/routes.rb
121
+ - test/dummy/config/storage.yml
122
+ - test/dummy/config/twirp/routes.rb
123
+ - test/dummy/lib/assets/.keep
124
+ - test/dummy/log/.keep
125
+ - test/dummy/proto/api.proto
126
+ - test/dummy/proto/api_pb.rb
127
+ - test/dummy/proto/api_twirp.rb
128
+ - test/dummy/public/404.html
129
+ - test/dummy/public/422.html
130
+ - test/dummy/public/500.html
131
+ - test/dummy/public/apple-touch-icon-precomposed.png
132
+ - test/dummy/public/apple-touch-icon.png
133
+ - test/dummy/public/favicon.ico
134
+ - test/other_controller_test.rb
135
+ - test/ping_controller_test.rb
63
136
  - test/rails_twirp_test.rb
64
137
  - test/test_helper.rb
65
138
  homepage: https://github.com/cheddar-me/rails-twirp
@@ -86,5 +159,68 @@ signing_key:
86
159
  specification_version: 4
87
160
  summary: Integrate Twirp into Rails
88
161
  test_files:
162
+ - test/dummy/Rakefile
163
+ - test/dummy/app/assets/config/manifest.js
164
+ - test/dummy/app/assets/images/.keep
165
+ - test/dummy/app/assets/stylesheets/application.css
166
+ - test/dummy/app/channels/application_cable/channel.rb
167
+ - test/dummy/app/channels/application_cable/connection.rb
168
+ - test/dummy/app/controllers/application_controller.rb
169
+ - test/dummy/app/controllers/application_twirp_controller.rb
170
+ - test/dummy/app/controllers/concerns/.keep
171
+ - test/dummy/app/controllers/pings_controller.rb
172
+ - test/dummy/app/controllers/testmod/nested/other_controller.rb
173
+ - test/dummy/app/helpers/application_helper.rb
174
+ - test/dummy/app/helpers/random_helper.rb
175
+ - test/dummy/app/javascript/packs/application.js
176
+ - test/dummy/app/jobs/application_job.rb
177
+ - test/dummy/app/mailers/application_mailer.rb
178
+ - test/dummy/app/models/application_record.rb
179
+ - test/dummy/app/models/concerns/.keep
180
+ - test/dummy/app/views/layouts/application.html.erb
181
+ - test/dummy/app/views/layouts/mailer.html.erb
182
+ - test/dummy/app/views/layouts/mailer.text.erb
183
+ - test/dummy/app/views/pings/ping_template.pb.pbbuilder
184
+ - test/dummy/bin/generate
185
+ - test/dummy/bin/rails
186
+ - test/dummy/bin/rake
187
+ - test/dummy/bin/setup
188
+ - test/dummy/config.ru
189
+ - test/dummy/config/application.rb
190
+ - test/dummy/config/boot.rb
191
+ - test/dummy/config/cable.yml
192
+ - test/dummy/config/database.yml
193
+ - test/dummy/config/environment.rb
194
+ - test/dummy/config/environments/development.rb
195
+ - test/dummy/config/environments/production.rb
196
+ - test/dummy/config/environments/test.rb
197
+ - test/dummy/config/initializers/application_controller_renderer.rb
198
+ - test/dummy/config/initializers/assets.rb
199
+ - test/dummy/config/initializers/backtrace_silencers.rb
200
+ - test/dummy/config/initializers/content_security_policy.rb
201
+ - test/dummy/config/initializers/cookies_serializer.rb
202
+ - test/dummy/config/initializers/filter_parameter_logging.rb
203
+ - test/dummy/config/initializers/inflections.rb
204
+ - test/dummy/config/initializers/mime_types.rb
205
+ - test/dummy/config/initializers/permissions_policy.rb
206
+ - test/dummy/config/initializers/wrap_parameters.rb
207
+ - test/dummy/config/locales/en.yml
208
+ - test/dummy/config/puma.rb
209
+ - test/dummy/config/routes.rb
210
+ - test/dummy/config/storage.yml
211
+ - test/dummy/config/twirp/routes.rb
212
+ - test/dummy/lib/assets/.keep
213
+ - test/dummy/log/.keep
214
+ - test/dummy/proto/api.proto
215
+ - test/dummy/proto/api_pb.rb
216
+ - test/dummy/proto/api_twirp.rb
217
+ - test/dummy/public/404.html
218
+ - test/dummy/public/422.html
219
+ - test/dummy/public/500.html
220
+ - test/dummy/public/apple-touch-icon-precomposed.png
221
+ - test/dummy/public/apple-touch-icon.png
222
+ - test/dummy/public/favicon.ico
223
+ - test/other_controller_test.rb
224
+ - test/ping_controller_test.rb
89
225
  - test/rails_twirp_test.rb
90
226
  - test/test_helper.rb