rails_twirp 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +1 -0
- data/.standard.yml +4 -0
- data/Gemfile +3 -3
- data/lib/rails_twirp.rb +1 -0
- data/lib/rails_twirp/base.rb +29 -10
- data/lib/rails_twirp/engine.rb +11 -6
- data/lib/rails_twirp/errors.rb +11 -0
- data/lib/rails_twirp/render_pb.rb +18 -0
- data/lib/rails_twirp/rescue.rb +14 -0
- data/lib/rails_twirp/route_set.rb +3 -0
- data/lib/rails_twirp/testing/integration_test.rb +6 -1
- data/lib/rails_twirp/version.rb +1 -1
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +2 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/application_twirp_controller.rb +7 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/pings_controller.rb +39 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/javascript/packs/application.js +15 -0
- data/test/dummy/app/jobs/application_job.rb +7 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/twirp/views/pings/ping_template.pb.pbbuilder +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +15 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/generate +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +33 -0
- data/test/dummy/config.ru +6 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +76 -0
- data/test/dummy/config/environments/production.rb +120 -0
- data/test/dummy/config/environments/test.rb +59 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +12 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/test/dummy/config/initializers/content_security_policy.rb +28 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/permissions_policy.rb +11 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +43 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/storage.yml +34 -0
- data/test/dummy/config/twirp/routes.rb +13 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/proto/api.proto +23 -0
- data/test/dummy/proto/api_pb.rb +22 -0
- data/test/dummy/proto/api_twirp.rb +23 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/ping_controller_test.rb +55 -0
- data/test/test_helper.rb +10 -1
- metadata +127 -2
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
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 "BoukeBouke", response.double_name
|
15
|
+
end
|
16
|
+
|
17
|
+
test "you can ping template" do
|
18
|
+
req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
|
19
|
+
rpc RPC::DummyAPI::DummyService, "PingTemplate", req
|
20
|
+
refute_instance_of Twirp::Error, response
|
21
|
+
assert_equal "BoukeBouke", response.double_name
|
22
|
+
end
|
23
|
+
|
24
|
+
test "error response" do
|
25
|
+
req = RPC::DummyAPI::PingRequest.new
|
26
|
+
rpc RPC::DummyAPI::DummyService, "ErrorResponse", req
|
27
|
+
assert_instance_of Twirp::Error, response
|
28
|
+
assert_equal "You are not authenticated!!", response.msg
|
29
|
+
assert_equal :unauthenticated, response.code
|
30
|
+
end
|
31
|
+
|
32
|
+
test "raise error" do
|
33
|
+
req = RPC::DummyAPI::PingRequest.new
|
34
|
+
rpc RPC::DummyAPI::DummyService, "RaiseError", req
|
35
|
+
assert_instance_of Twirp::Error, response
|
36
|
+
assert_equal "Not found", response.msg
|
37
|
+
assert_equal :not_found, response.code
|
38
|
+
end
|
39
|
+
|
40
|
+
test "uncaught error" do
|
41
|
+
req = RPC::DummyAPI::PingRequest.new
|
42
|
+
rpc RPC::DummyAPI::DummyService, "UncaughtError", req
|
43
|
+
assert_instance_of Twirp::Error, response
|
44
|
+
assert_equal "Uncaught", response.msg
|
45
|
+
assert_equal :internal, response.code
|
46
|
+
end
|
47
|
+
|
48
|
+
test "before error" do
|
49
|
+
req = RPC::DummyAPI::PingRequest.new
|
50
|
+
rpc RPC::DummyAPI::DummyService, "BeforeError", req
|
51
|
+
assert_instance_of Twirp::Error, response
|
52
|
+
assert_equal "yOuR ReQuEsT Is mAlFoRmEd", response.msg
|
53
|
+
assert_equal :malformed, response.code
|
54
|
+
end
|
55
|
+
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
|
-
|
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2021-04-06 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,73 @@ 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/render_pb.rb
|
63
|
+
- lib/rails_twirp/rescue.rb
|
59
64
|
- lib/rails_twirp/route_set.rb
|
60
65
|
- lib/rails_twirp/testing/integration_test.rb
|
61
66
|
- lib/rails_twirp/version.rb
|
62
67
|
- rails_twirp.gemspec
|
68
|
+
- test/dummy/Rakefile
|
69
|
+
- test/dummy/app/assets/config/manifest.js
|
70
|
+
- test/dummy/app/assets/images/.keep
|
71
|
+
- test/dummy/app/assets/stylesheets/application.css
|
72
|
+
- test/dummy/app/channels/application_cable/channel.rb
|
73
|
+
- test/dummy/app/channels/application_cable/connection.rb
|
74
|
+
- test/dummy/app/controllers/application_controller.rb
|
75
|
+
- test/dummy/app/controllers/application_twirp_controller.rb
|
76
|
+
- test/dummy/app/controllers/concerns/.keep
|
77
|
+
- test/dummy/app/controllers/pings_controller.rb
|
78
|
+
- test/dummy/app/helpers/application_helper.rb
|
79
|
+
- test/dummy/app/javascript/packs/application.js
|
80
|
+
- test/dummy/app/jobs/application_job.rb
|
81
|
+
- test/dummy/app/mailers/application_mailer.rb
|
82
|
+
- test/dummy/app/models/application_record.rb
|
83
|
+
- test/dummy/app/models/concerns/.keep
|
84
|
+
- test/dummy/app/twirp/views/pings/ping_template.pb.pbbuilder
|
85
|
+
- test/dummy/app/views/layouts/application.html.erb
|
86
|
+
- test/dummy/app/views/layouts/mailer.html.erb
|
87
|
+
- test/dummy/app/views/layouts/mailer.text.erb
|
88
|
+
- test/dummy/bin/generate
|
89
|
+
- test/dummy/bin/rails
|
90
|
+
- test/dummy/bin/rake
|
91
|
+
- test/dummy/bin/setup
|
92
|
+
- test/dummy/config.ru
|
93
|
+
- test/dummy/config/application.rb
|
94
|
+
- test/dummy/config/boot.rb
|
95
|
+
- test/dummy/config/cable.yml
|
96
|
+
- test/dummy/config/database.yml
|
97
|
+
- test/dummy/config/environment.rb
|
98
|
+
- test/dummy/config/environments/development.rb
|
99
|
+
- test/dummy/config/environments/production.rb
|
100
|
+
- test/dummy/config/environments/test.rb
|
101
|
+
- test/dummy/config/initializers/application_controller_renderer.rb
|
102
|
+
- test/dummy/config/initializers/assets.rb
|
103
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
104
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
105
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
106
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
107
|
+
- test/dummy/config/initializers/inflections.rb
|
108
|
+
- test/dummy/config/initializers/mime_types.rb
|
109
|
+
- test/dummy/config/initializers/permissions_policy.rb
|
110
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
111
|
+
- test/dummy/config/locales/en.yml
|
112
|
+
- test/dummy/config/puma.rb
|
113
|
+
- test/dummy/config/routes.rb
|
114
|
+
- test/dummy/config/storage.yml
|
115
|
+
- test/dummy/config/twirp/routes.rb
|
116
|
+
- test/dummy/lib/assets/.keep
|
117
|
+
- test/dummy/log/.keep
|
118
|
+
- test/dummy/proto/api.proto
|
119
|
+
- test/dummy/proto/api_pb.rb
|
120
|
+
- test/dummy/proto/api_twirp.rb
|
121
|
+
- test/dummy/public/404.html
|
122
|
+
- test/dummy/public/422.html
|
123
|
+
- test/dummy/public/500.html
|
124
|
+
- test/dummy/public/apple-touch-icon-precomposed.png
|
125
|
+
- test/dummy/public/apple-touch-icon.png
|
126
|
+
- test/dummy/public/favicon.ico
|
127
|
+
- test/ping_controller_test.rb
|
63
128
|
- test/rails_twirp_test.rb
|
64
129
|
- test/test_helper.rb
|
65
130
|
homepage: https://github.com/cheddar-me/rails-twirp
|
@@ -86,5 +151,65 @@ signing_key:
|
|
86
151
|
specification_version: 4
|
87
152
|
summary: Integrate Twirp into Rails
|
88
153
|
test_files:
|
154
|
+
- test/dummy/Rakefile
|
155
|
+
- test/dummy/app/assets/config/manifest.js
|
156
|
+
- test/dummy/app/assets/images/.keep
|
157
|
+
- test/dummy/app/assets/stylesheets/application.css
|
158
|
+
- test/dummy/app/channels/application_cable/channel.rb
|
159
|
+
- test/dummy/app/channels/application_cable/connection.rb
|
160
|
+
- test/dummy/app/controllers/application_controller.rb
|
161
|
+
- test/dummy/app/controllers/application_twirp_controller.rb
|
162
|
+
- test/dummy/app/controllers/concerns/.keep
|
163
|
+
- test/dummy/app/controllers/pings_controller.rb
|
164
|
+
- test/dummy/app/helpers/application_helper.rb
|
165
|
+
- test/dummy/app/javascript/packs/application.js
|
166
|
+
- test/dummy/app/jobs/application_job.rb
|
167
|
+
- test/dummy/app/mailers/application_mailer.rb
|
168
|
+
- test/dummy/app/models/application_record.rb
|
169
|
+
- test/dummy/app/models/concerns/.keep
|
170
|
+
- test/dummy/app/twirp/views/pings/ping_template.pb.pbbuilder
|
171
|
+
- test/dummy/app/views/layouts/application.html.erb
|
172
|
+
- test/dummy/app/views/layouts/mailer.html.erb
|
173
|
+
- test/dummy/app/views/layouts/mailer.text.erb
|
174
|
+
- test/dummy/bin/generate
|
175
|
+
- test/dummy/bin/rails
|
176
|
+
- test/dummy/bin/rake
|
177
|
+
- test/dummy/bin/setup
|
178
|
+
- test/dummy/config.ru
|
179
|
+
- test/dummy/config/application.rb
|
180
|
+
- test/dummy/config/boot.rb
|
181
|
+
- test/dummy/config/cable.yml
|
182
|
+
- test/dummy/config/database.yml
|
183
|
+
- test/dummy/config/environment.rb
|
184
|
+
- test/dummy/config/environments/development.rb
|
185
|
+
- test/dummy/config/environments/production.rb
|
186
|
+
- test/dummy/config/environments/test.rb
|
187
|
+
- test/dummy/config/initializers/application_controller_renderer.rb
|
188
|
+
- test/dummy/config/initializers/assets.rb
|
189
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
190
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
191
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
192
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
193
|
+
- test/dummy/config/initializers/inflections.rb
|
194
|
+
- test/dummy/config/initializers/mime_types.rb
|
195
|
+
- test/dummy/config/initializers/permissions_policy.rb
|
196
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
197
|
+
- test/dummy/config/locales/en.yml
|
198
|
+
- test/dummy/config/puma.rb
|
199
|
+
- test/dummy/config/routes.rb
|
200
|
+
- test/dummy/config/storage.yml
|
201
|
+
- test/dummy/config/twirp/routes.rb
|
202
|
+
- test/dummy/lib/assets/.keep
|
203
|
+
- test/dummy/log/.keep
|
204
|
+
- test/dummy/proto/api.proto
|
205
|
+
- test/dummy/proto/api_pb.rb
|
206
|
+
- test/dummy/proto/api_twirp.rb
|
207
|
+
- test/dummy/public/404.html
|
208
|
+
- test/dummy/public/422.html
|
209
|
+
- test/dummy/public/500.html
|
210
|
+
- test/dummy/public/apple-touch-icon-precomposed.png
|
211
|
+
- test/dummy/public/apple-touch-icon.png
|
212
|
+
- test/dummy/public/favicon.ico
|
213
|
+
- test/ping_controller_test.rb
|
89
214
|
- test/rails_twirp_test.rb
|
90
215
|
- test/test_helper.rb
|