sorbet-rails 0.6.5.1 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +1 -2
- data/.gitignore +2 -1
- data/.travis.yml +1 -1
- data/README.md +66 -13
- data/Rakefile +3 -3
- data/lib/bundled_rbi/customizabel_rbi_formatter.rbi +29 -0
- data/lib/bundled_rbi/pluck_to_tstruct.rbi +2 -1
- data/lib/bundled_rbi/typed_enum.rbi +7 -0
- data/lib/sorbet-rails.rb +1 -3
- data/lib/sorbet-rails/active_record_rbi_formatter.rb +6 -6
- data/lib/sorbet-rails/config.rb +12 -0
- data/lib/sorbet-rails/dependent_gem_rbis/activerecord.rbi +3 -0
- data/lib/sorbet-rails/dependent_gem_rbis/parlour.rbi +1896 -0
- data/lib/sorbet-rails/deprecation.rb +1 -0
- data/lib/sorbet-rails/gem_plugins/attr_json_plugin.rb +137 -0
- data/lib/sorbet-rails/gem_plugins/flag_shih_tzu_plugin.rb +201 -0
- data/lib/sorbet-rails/gem_plugins/kaminari_plugin.rb +28 -0
- data/lib/sorbet-rails/gem_plugins/shrine_plugin.rb +1 -1
- data/lib/sorbet-rails/helper_rbi_formatter.rb +1 -1
- data/lib/sorbet-rails/job_rbi_formatter.rb +75 -62
- data/lib/sorbet-rails/mailer_rbi_formatter.rb +40 -27
- data/lib/sorbet-rails/model_column_utils.rb +129 -0
- data/lib/sorbet-rails/model_plugins/active_record_assoc.rb +40 -1
- data/lib/sorbet-rails/model_plugins/active_record_attribute.rb +12 -112
- data/lib/sorbet-rails/model_plugins/active_record_serialized_attribute.rb +68 -0
- data/lib/sorbet-rails/model_plugins/base.rb +6 -8
- data/lib/sorbet-rails/model_plugins/plugins.rb +9 -0
- data/lib/sorbet-rails/model_rbi_formatter.rb +3 -3
- data/lib/sorbet-rails/model_utils.rb +5 -2
- data/lib/sorbet-rails/rails_mixins/generated_url_helpers.rb +2 -3
- data/lib/sorbet-rails/rails_mixins/pluck_to_tstruct.rb +54 -7
- data/lib/sorbet-rails/railtie.rb +0 -2
- data/lib/sorbet-rails/routes_rbi_formatter.rb +6 -2
- data/lib/sorbet-rails/sorbet_utils.rb +152 -150
- data/lib/sorbet-rails/tasks/rails_rbi.rake +9 -8
- data/sorbet-rails.gemspec +2 -2
- data/spec/bin/run_spec.sh +1 -1
- data/spec/generators/rails-template.rb +16 -0
- data/spec/generators/sorbet_test_cases.rb +28 -56
- data/spec/job_rbi_formatter_spec.rb +1 -1
- data/spec/pluck_to_tstruct_spec.rb +115 -16
- data/spec/rails_helper.rb +3 -7
- data/spec/rake_rails_rbi_jobs_spec.rb +20 -0
- data/spec/rake_rails_rbi_mailers_spec.rb +21 -0
- data/spec/sorbet_spec.rb +5 -5
- data/spec/support/v5.0/Gemfile +1 -1
- data/spec/support/v5.0/Gemfile.lock +23 -19
- data/spec/support/v5.0/app/controllers/application_controller.rb +1 -1
- data/spec/support/v5.0/app/models/headmaster.rb +1 -1
- data/spec/support/v5.0/app/models/potion.rb +1 -1
- data/spec/support/v5.0/app/models/robe.rb +1 -1
- data/spec/support/v5.0/app/models/school.rb +1 -1
- data/spec/support/v5.0/app/models/spell.rb +1 -1
- data/spec/support/v5.0/app/models/subject.rb +1 -1
- data/spec/support/v5.0/app/models/wizard.rb +5 -0
- data/spec/support/v5.0/config/environments/development.rb +1 -1
- data/spec/support/v5.0/config/environments/production.rb +1 -1
- data/spec/support/v5.0/config/environments/test.rb +1 -1
- data/spec/support/v5.0/config/routes.rb +1 -1
- data/spec/support/v5.0/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
- data/spec/support/v5.0/db/schema.rb +8 -4
- data/spec/support/v5.0/sorbet_test_cases.rb +28 -56
- data/spec/support/v5.1/Gemfile.lock +21 -17
- data/spec/support/v5.1/app/controllers/application_controller.rb +1 -1
- data/spec/support/v5.1/app/models/headmaster.rb +1 -1
- data/spec/support/v5.1/app/models/school.rb +1 -1
- data/spec/support/v5.1/app/models/wizard.rb +5 -0
- data/spec/support/v5.1/config/environments/production.rb +1 -1
- data/spec/support/v5.1/config/routes.rb +1 -1
- data/spec/support/v5.1/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
- data/spec/support/v5.1/db/schema.rb +5 -1
- data/spec/support/v5.1/sorbet_test_cases.rb +28 -56
- data/spec/support/v5.2/Gemfile +1 -1
- data/spec/support/v5.2/Gemfile.lock +23 -19
- data/spec/support/v5.2/app/models/headmaster.rb +1 -1
- data/spec/support/v5.2/app/models/school.rb +1 -1
- data/spec/support/v5.2/app/models/wizard.rb +5 -0
- data/spec/support/v5.2/config/environments/development.rb +1 -1
- data/spec/support/v5.2/config/environments/production.rb +1 -1
- data/spec/support/v5.2/config/environments/test.rb +1 -1
- data/spec/support/v5.2/config/routes.rb +1 -1
- data/spec/support/v5.2/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
- data/spec/support/v5.2/db/schema.rb +5 -1
- data/spec/support/v5.2/sorbet_test_cases.rb +28 -56
- data/spec/support/v6.0/.gitignore +6 -0
- data/spec/support/v6.0/Gemfile +3 -3
- data/spec/support/v6.0/Gemfile.lock +89 -84
- data/spec/support/v6.0/app/models/wizard.rb +5 -0
- data/spec/support/v6.0/bin/bundle +22 -13
- data/spec/support/v6.0/config/environments/development.rb +1 -1
- data/spec/support/v6.0/config/environments/production.rb +1 -1
- data/spec/support/v6.0/config/environments/test.rb +2 -2
- data/spec/support/v6.0/config/routes.rb +1 -1
- data/spec/support/v6.0/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
- data/spec/support/v6.0/db/schema.rb +5 -1
- data/spec/support/v6.0/sorbet_test_cases.rb +28 -56
- data/spec/support/v6.0/tmp/pids/.keep +0 -0
- data/spec/test_data/v5.0/expected_active_record_relation.rbi +0 -1
- data/spec/test_data/v5.0/expected_application_job.rbi +2 -2
- data/spec/test_data/v5.0/expected_award_house_point_hourglasses.rbi +2 -2
- data/spec/test_data/v5.0/expected_custom_application_job.rbi +21 -0
- data/spec/test_data/v5.0/expected_custom_application_mailer.rbi +6 -0
- data/spec/test_data/v5.0/expected_custom_award_house_point_hourglasses.rbi +21 -0
- data/spec/test_data/v5.0/expected_custom_daily_prophet_mailer.rbi +8 -0
- data/spec/test_data/v5.0/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
- data/spec/test_data/v5.0/expected_headmaster.rbi +24 -0
- data/spec/test_data/v5.0/expected_potion.rbi +12 -0
- data/spec/test_data/v5.0/expected_robe.rbi +12 -0
- data/spec/test_data/v5.0/expected_routes.rbi +4 -0
- data/spec/test_data/v5.0/expected_school.rbi +12 -0
- data/spec/test_data/v5.0/expected_spell/habtm_spell_books.rbi +24 -0
- data/spec/test_data/v5.0/expected_spell_book.rbi +21 -9
- data/spec/test_data/v5.0/expected_spell_book/habtm_spells.rbi +24 -0
- data/spec/test_data/v5.0/expected_squib.rbi +63 -0
- data/spec/test_data/v5.0/expected_subject/habtm_wizards.rbi +24 -0
- data/spec/test_data/v5.0/expected_wand.rbi +22 -10
- data/spec/test_data/v5.0/expected_wizard.rbi +121 -58
- data/spec/test_data/v5.0/expected_wizard/habtm_subjects.rbi +24 -0
- data/spec/test_data/v5.0/expected_wizard_wo_spellbook.rbi +121 -58
- data/spec/test_data/v5.1/expected_active_record_relation.rbi +0 -1
- data/spec/test_data/v5.1/expected_application_job.rbi +2 -2
- data/spec/test_data/v5.1/expected_award_house_point_hourglasses.rbi +2 -2
- data/spec/test_data/v5.1/expected_custom_application_job.rbi +21 -0
- data/spec/test_data/v5.1/expected_custom_application_mailer.rbi +6 -0
- data/spec/test_data/v5.1/expected_custom_award_house_point_hourglasses.rbi +21 -0
- data/spec/test_data/v5.1/expected_custom_daily_prophet_mailer.rbi +8 -0
- data/spec/test_data/v5.1/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
- data/spec/test_data/v5.1/expected_headmaster.rbi +24 -0
- data/spec/test_data/v5.1/expected_potion.rbi +12 -0
- data/spec/test_data/v5.1/expected_robe.rbi +12 -0
- data/spec/test_data/v5.1/expected_routes.rbi +4 -0
- data/spec/test_data/v5.1/expected_school.rbi +12 -0
- data/spec/test_data/v5.1/expected_spell/habtm_spell_books.rbi +24 -0
- data/spec/test_data/v5.1/expected_spell_book.rbi +21 -9
- data/spec/test_data/v5.1/expected_spell_book/habtm_spells.rbi +24 -0
- data/spec/test_data/v5.1/expected_squib.rbi +63 -0
- data/spec/test_data/v5.1/expected_subject/habtm_wizards.rbi +24 -0
- data/spec/test_data/v5.1/expected_wand.rbi +22 -10
- data/spec/test_data/v5.1/expected_wizard.rbi +121 -58
- data/spec/test_data/v5.1/expected_wizard/habtm_subjects.rbi +24 -0
- data/spec/test_data/v5.1/expected_wizard_wo_spellbook.rbi +121 -58
- data/spec/test_data/v5.2/expected_active_record_relation.rbi +0 -1
- data/spec/test_data/v5.2/expected_application_job.rbi +2 -2
- data/spec/test_data/v5.2/expected_attachment.rbi +24 -0
- data/spec/test_data/v5.2/expected_award_house_point_hourglasses.rbi +2 -2
- data/spec/test_data/v5.2/expected_blob.rbi +25 -1
- data/spec/test_data/v5.2/expected_custom_application_job.rbi +21 -0
- data/spec/test_data/v5.2/expected_custom_application_mailer.rbi +6 -0
- data/spec/test_data/v5.2/expected_custom_award_house_point_hourglasses.rbi +21 -0
- data/spec/test_data/v5.2/expected_custom_daily_prophet_mailer.rbi +8 -0
- data/spec/test_data/v5.2/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
- data/spec/test_data/v5.2/expected_headmaster.rbi +24 -0
- data/spec/test_data/v5.2/expected_potion.rbi +12 -0
- data/spec/test_data/v5.2/expected_robe.rbi +12 -0
- data/spec/test_data/v5.2/expected_routes.rbi +4 -0
- data/spec/test_data/v5.2/expected_school.rbi +12 -0
- data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +24 -0
- data/spec/test_data/v5.2/expected_spell_book.rbi +21 -9
- data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +24 -0
- data/spec/test_data/v5.2/expected_squib.rbi +89 -2
- data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +24 -0
- data/spec/test_data/v5.2/expected_wand.rbi +22 -10
- data/spec/test_data/v5.2/expected_wizard.rbi +147 -60
- data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +24 -0
- data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +147 -60
- data/spec/test_data/v6.0/expected_active_record_relation.rbi +0 -1
- data/spec/test_data/v6.0/expected_application_job.rbi +2 -2
- data/spec/test_data/v6.0/expected_attachment.rbi +24 -0
- data/spec/test_data/v6.0/expected_award_house_point_hourglasses.rbi +2 -2
- data/spec/test_data/v6.0/expected_blob.rbi +25 -1
- data/spec/test_data/v6.0/expected_custom_application_job.rbi +21 -0
- data/spec/test_data/v6.0/expected_custom_application_mailer.rbi +6 -0
- data/spec/test_data/v6.0/expected_custom_award_house_point_hourglasses.rbi +21 -0
- data/spec/test_data/v6.0/expected_custom_daily_prophet_mailer.rbi +8 -0
- data/spec/test_data/v6.0/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
- data/spec/test_data/v6.0/expected_headmaster.rbi +24 -0
- data/spec/test_data/v6.0/expected_potion.rbi +12 -0
- data/spec/test_data/v6.0/expected_robe.rbi +12 -0
- data/spec/test_data/v6.0/expected_routes.rbi +4 -0
- data/spec/test_data/v6.0/expected_school.rbi +12 -0
- data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +24 -0
- data/spec/test_data/v6.0/expected_spell_book.rbi +21 -9
- data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +24 -0
- data/spec/test_data/v6.0/expected_squib.rbi +89 -2
- data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +24 -0
- data/spec/test_data/v6.0/expected_wand.rbi +22 -10
- data/spec/test_data/v6.0/expected_wizard.rbi +147 -60
- data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +24 -0
- data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +147 -60
- data/spec/tstruct_comparable.rb +13 -0
- metadata +64 -15
- data/lib/bundled_rbi/parameters.rbi +0 -28
- data/lib/sorbet-rails/custom_types/boolean_string.rb +0 -42
- data/lib/sorbet-rails/custom_types/integer_string.rb +0 -45
- data/lib/sorbet-rails/rails_mixins/custom_params_methods.rb +0 -57
- data/spec/boolean_string_spec.rb +0 -59
- data/spec/custom_params_methods_spec.rb +0 -138
- data/spec/integer_string_spec.rb +0 -46
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.
|
4
|
+
sorbet-rails (0.7.4)
|
5
5
|
method_source (>= 0.9.2)
|
6
|
-
parlour (
|
6
|
+
parlour (>= 4.0.1)
|
7
7
|
parser (>= 2.7)
|
8
8
|
sorbet-coerce (>= 0.2.6)
|
9
9
|
sorbet-runtime (>= 0.5)
|
@@ -49,11 +49,11 @@ GEM
|
|
49
49
|
minitest (~> 5.1)
|
50
50
|
tzinfo (~> 1.1)
|
51
51
|
arel (8.0.0)
|
52
|
-
ast (2.4.
|
52
|
+
ast (2.4.2)
|
53
53
|
bindex (0.8.1)
|
54
54
|
builder (3.2.4)
|
55
55
|
byebug (11.1.1)
|
56
|
-
commander (4.
|
56
|
+
commander (4.6.0)
|
57
57
|
highline (~> 2.0.0)
|
58
58
|
concurrent-ruby (1.1.6)
|
59
59
|
crass (1.0.6)
|
@@ -72,21 +72,25 @@ GEM
|
|
72
72
|
mini_mime (>= 0.1.1)
|
73
73
|
method_source (1.0.0)
|
74
74
|
mini_mime (1.0.2)
|
75
|
-
mini_portile2 (2.
|
75
|
+
mini_portile2 (2.5.0)
|
76
76
|
minitest (5.14.0)
|
77
77
|
nio4r (2.5.2)
|
78
|
-
nokogiri (1.
|
79
|
-
mini_portile2 (~> 2.
|
80
|
-
|
78
|
+
nokogiri (1.11.1)
|
79
|
+
mini_portile2 (~> 2.5.0)
|
80
|
+
racc (~> 1.4)
|
81
|
+
nokogiri (1.11.1-x86_64-darwin)
|
82
|
+
racc (~> 1.4)
|
83
|
+
parlour (6.0.0)
|
81
84
|
commander (~> 4.5)
|
82
85
|
parser
|
83
86
|
rainbow (~> 3.0)
|
84
87
|
sorbet-runtime (>= 0.5)
|
85
|
-
parser (
|
86
|
-
ast (~> 2.4.
|
87
|
-
polyfill (1.
|
88
|
+
parser (3.0.1.1)
|
89
|
+
ast (~> 2.4.1)
|
90
|
+
polyfill (1.9.0)
|
88
91
|
puma (3.12.4)
|
89
|
-
|
92
|
+
racc (1.5.2)
|
93
|
+
rack (2.2.3)
|
90
94
|
rack-test (1.1.0)
|
91
95
|
rack (>= 1.0, < 3)
|
92
96
|
rails (5.1.7)
|
@@ -117,13 +121,12 @@ GEM
|
|
117
121
|
safe_type (1.1.1)
|
118
122
|
sorbet (0.5.5480)
|
119
123
|
sorbet-static (= 0.5.5480)
|
120
|
-
sorbet-coerce (0.
|
124
|
+
sorbet-coerce (0.4.0)
|
121
125
|
polyfill (~> 1.8)
|
122
126
|
safe_type (~> 1.1, >= 1.1.1)
|
123
|
-
sorbet (>= 0.4.4704)
|
124
127
|
sorbet-runtime (>= 0.4.4704)
|
125
128
|
sorbet-runtime (0.5.5480)
|
126
|
-
sorbet-static (0.5.5480-universal-darwin-
|
129
|
+
sorbet-static (0.5.5480-universal-darwin-19)
|
127
130
|
sprockets (4.0.0)
|
128
131
|
concurrent-ruby (~> 1.0)
|
129
132
|
rack (> 1, < 3)
|
@@ -143,10 +146,11 @@ GEM
|
|
143
146
|
railties (>= 5.0)
|
144
147
|
websocket-driver (0.6.5)
|
145
148
|
websocket-extensions (>= 0.1.0)
|
146
|
-
websocket-extensions (0.1.
|
149
|
+
websocket-extensions (0.1.5)
|
147
150
|
|
148
151
|
PLATFORMS
|
149
152
|
ruby
|
153
|
+
x86_64-darwin-19
|
150
154
|
|
151
155
|
DEPENDENCIES
|
152
156
|
byebug
|
@@ -161,4 +165,4 @@ DEPENDENCIES
|
|
161
165
|
web-console (>= 3.3.0)
|
162
166
|
|
163
167
|
BUNDLED WITH
|
164
|
-
2.0
|
168
|
+
2.2.0
|
@@ -47,6 +47,11 @@ class Wizard < ApplicationRecord
|
|
47
47
|
blue: 2,
|
48
48
|
}, _prefix: :color, _suffix: :eyes
|
49
49
|
|
50
|
+
serialize :owl_results, Hash
|
51
|
+
serialize :newt_subjects # no specific data type, uses the default YAML Object coder
|
52
|
+
serialize :pets, Array
|
53
|
+
serialize :patronus_characteristics, JSON
|
54
|
+
|
50
55
|
has_one :wand
|
51
56
|
has_many :spell_books
|
52
57
|
# habtm which is optional at the db level
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# typed: false
|
2
|
+
class AddSerializedToWizards < ActiveRecord::Migration[5.1]
|
3
|
+
def change
|
4
|
+
add_column :wizards, :owl_results, :text # Hash
|
5
|
+
add_column :wizards, :newt_subjects, :text # generic
|
6
|
+
add_column :wizards, :pets, :text # Array
|
7
|
+
add_column :wizards, :patronus_characteristics, :text # serialized as JSON, but not a JSON column type
|
8
|
+
end
|
9
|
+
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20190620000015) do
|
15
15
|
|
16
16
|
create_table "headmasters", force: :cascade do |t|
|
17
17
|
t.integer "school_id"
|
@@ -87,6 +87,10 @@ ActiveRecord::Schema.define(version: 20190620000014) do
|
|
87
87
|
t.integer "hair_length"
|
88
88
|
t.string "type", default: "Wizard", null: false
|
89
89
|
t.integer "school_id"
|
90
|
+
t.text "owl_results"
|
91
|
+
t.text "newt_subjects"
|
92
|
+
t.text "pets"
|
93
|
+
t.text "patronus_characteristics"
|
90
94
|
end
|
91
95
|
|
92
96
|
end
|
@@ -305,6 +305,21 @@ T.assert_type!(Wizard::House::Hufflepuff, Wizard::House)
|
|
305
305
|
T.assert_type!(Wizard::House::Ravenclaw, Wizard::House)
|
306
306
|
T.assert_type!(Wizard::House::Slytherin, Wizard::House)
|
307
307
|
|
308
|
+
# Serialization
|
309
|
+
T.assert_type!(
|
310
|
+
wizard.owl_results,
|
311
|
+
T.nilable(T::Hash[T.untyped, T.untyped])
|
312
|
+
)
|
313
|
+
T.assert_type!(
|
314
|
+
wizard.newt_subjects,
|
315
|
+
T.nilable(T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[T.untyped, T.untyped], Integer, String))
|
316
|
+
)
|
317
|
+
T.assert_type!(
|
318
|
+
wizard.patronus_characteristics,
|
319
|
+
T.nilable(T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[String, T.untyped], Integer, String))
|
320
|
+
)
|
321
|
+
T.assert_type!(wizard.pets, T.nilable(T::Array[T.untyped]))
|
322
|
+
|
308
323
|
# Mythical plugin
|
309
324
|
T.assert_type!(Wand.mythicals, T::Array[Wand])
|
310
325
|
|
@@ -312,7 +327,10 @@ T.assert_type!(Wand.mythicals, T::Array[Wand])
|
|
312
327
|
T.assert_type!(HogwartsAcceptanceMailer.notify(wizard), ActionMailer::MessageDelivery)
|
313
328
|
|
314
329
|
# Jobs
|
315
|
-
|
330
|
+
T.assert_type!(
|
331
|
+
AwardHousePointHourglasses.perform_later(student: wizard, point: 10),
|
332
|
+
AwardHousePointHourglasses
|
333
|
+
)
|
316
334
|
AwardHousePointHourglasses.perform_now(student: wizard, point: 10)
|
317
335
|
AwardHousePointHourglasses.
|
318
336
|
set(queue: :daily, wait: 5.minutes).
|
@@ -321,7 +339,6 @@ AwardHousePointHourglasses.
|
|
321
339
|
set(priority: 10, wait_until: Time.now.tomorrow).
|
322
340
|
perform_later(student: wizard, point: 10)
|
323
341
|
|
324
|
-
|
325
342
|
T.assert_type!(wizard.broom_nimbus?, T::Boolean)
|
326
343
|
T.assert_type!(wizard.color_brown_eyes?, T::Boolean)
|
327
344
|
T.assert_type!(wizard.quidditch_keeper?, T::Boolean)
|
@@ -361,44 +378,6 @@ params = ActionController::Parameters.new({
|
|
361
378
|
typed_params = TypedParams[MyActionParams].new.extract!(params)
|
362
379
|
T.assert_type!(typed_params, MyActionParams)
|
363
380
|
|
364
|
-
# -- require_typed
|
365
|
-
T.assert_type!(
|
366
|
-
params.require_typed(:age, TA[Integer].new),
|
367
|
-
Integer,
|
368
|
-
)
|
369
|
-
T.assert_type!(
|
370
|
-
params.require_typed(:name, TA[String].new),
|
371
|
-
String,
|
372
|
-
)
|
373
|
-
info = params.require_typed(:info, TA[ActionController::Parameters].new)
|
374
|
-
T.assert_type!(info, ActionController::Parameters)
|
375
|
-
T.assert_type!(
|
376
|
-
info.require_typed(:friends, TA[T::Array[String]].new),
|
377
|
-
T::Array[String],
|
378
|
-
)
|
379
|
-
# -- fetch_typed
|
380
|
-
T.assert_type!(
|
381
|
-
params.fetch_typed(:age, TA[Integer].new),
|
382
|
-
Integer,
|
383
|
-
)
|
384
|
-
T.assert_type!(
|
385
|
-
params.fetch_typed(:name, TA[String].new),
|
386
|
-
String,
|
387
|
-
)
|
388
|
-
T.assert_type!(
|
389
|
-
params.fetch_typed(:nonexistence, TA[String].new, ''),
|
390
|
-
String,
|
391
|
-
)
|
392
|
-
T.assert_type!(
|
393
|
-
params.fetch_typed(:nonexistence, TA[T.nilable(String)].new, nil),
|
394
|
-
T.nilable(String),
|
395
|
-
)
|
396
|
-
T.assert_type!(
|
397
|
-
params.fetch_typed(:nonexistence, TA[T::Array[Integer]].new, []),
|
398
|
-
T::Array[Integer],
|
399
|
-
)
|
400
|
-
|
401
|
-
|
402
381
|
# -- pluck to tstruct
|
403
382
|
class WizardStruct < T::Struct
|
404
383
|
const :name, String
|
@@ -415,23 +394,16 @@ Wizard.all.pluck_to_tstruct(TA[WizardStruct].new).each do |row|
|
|
415
394
|
T.assert_type!(row, WizardStruct)
|
416
395
|
end
|
417
396
|
|
418
|
-
|
419
397
|
# -- GeneratedUrlHelpers
|
420
398
|
class TestHelper
|
421
399
|
include GeneratedUrlHelpers
|
422
|
-
|
423
|
-
# need to implement this for the url
|
424
|
-
def default_url_options
|
425
|
-
{
|
426
|
-
protocol: 'http',
|
427
|
-
host: 'localhost',
|
428
|
-
port: 3000,
|
429
|
-
}
|
430
|
-
end
|
431
|
-
|
432
|
-
def test_url_helper
|
433
|
-
T.assert_type!(test_index_path, String)
|
434
|
-
T.assert_type!(test_index_url, String)
|
435
|
-
end
|
436
400
|
end
|
437
|
-
|
401
|
+
|
402
|
+
T.assert_type!(TestHelper.new.test_index_path, String)
|
403
|
+
# need to set this config for _url methods
|
404
|
+
Rails.application.routes.default_url_options = {
|
405
|
+
protocol: 'http',
|
406
|
+
host: 'localhost',
|
407
|
+
port: 3000,
|
408
|
+
}
|
409
|
+
T.assert_type!(TestHelper.new.test_index_url, String)
|
data/spec/support/v5.2/Gemfile
CHANGED
@@ -8,7 +8,7 @@ gem 'rails', '~> 5.2.4', '>= 5.2.4.2'
|
|
8
8
|
# Use sqlite3 as the database for Active Record
|
9
9
|
gem 'sqlite3'
|
10
10
|
# Use Puma as the app server
|
11
|
-
gem 'puma', '~> 3.
|
11
|
+
gem 'puma', '~> 3.12'
|
12
12
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
13
13
|
gem 'jbuilder', '~> 2.5'
|
14
14
|
# Use ActiveModel has_secure_password
|
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.
|
4
|
+
sorbet-rails (0.7.4)
|
5
5
|
method_source (>= 0.9.2)
|
6
|
-
parlour (
|
6
|
+
parlour (>= 4.0.1)
|
7
7
|
parser (>= 2.7)
|
8
8
|
sorbet-coerce (>= 0.2.6)
|
9
9
|
sorbet-runtime (>= 0.5)
|
@@ -53,11 +53,11 @@ GEM
|
|
53
53
|
minitest (~> 5.1)
|
54
54
|
tzinfo (~> 1.1)
|
55
55
|
arel (9.0.0)
|
56
|
-
ast (2.4.
|
56
|
+
ast (2.4.2)
|
57
57
|
bindex (0.8.1)
|
58
58
|
builder (3.2.4)
|
59
59
|
byebug (11.1.1)
|
60
|
-
commander (4.
|
60
|
+
commander (4.6.0)
|
61
61
|
highline (~> 2.0.0)
|
62
62
|
concurrent-ruby (1.1.6)
|
63
63
|
crass (1.0.6)
|
@@ -79,21 +79,25 @@ GEM
|
|
79
79
|
method_source (1.0.0)
|
80
80
|
mimemagic (0.3.4)
|
81
81
|
mini_mime (1.0.2)
|
82
|
-
mini_portile2 (2.
|
82
|
+
mini_portile2 (2.5.0)
|
83
83
|
minitest (5.14.0)
|
84
84
|
nio4r (2.5.2)
|
85
|
-
nokogiri (1.
|
86
|
-
mini_portile2 (~> 2.
|
87
|
-
|
85
|
+
nokogiri (1.11.1)
|
86
|
+
mini_portile2 (~> 2.5.0)
|
87
|
+
racc (~> 1.4)
|
88
|
+
nokogiri (1.11.1-x86_64-darwin)
|
89
|
+
racc (~> 1.4)
|
90
|
+
parlour (6.0.0)
|
88
91
|
commander (~> 4.5)
|
89
92
|
parser
|
90
93
|
rainbow (~> 3.0)
|
91
94
|
sorbet-runtime (>= 0.5)
|
92
|
-
parser (
|
93
|
-
ast (~> 2.4.
|
94
|
-
polyfill (1.
|
95
|
-
puma (3.12.
|
96
|
-
|
95
|
+
parser (3.0.1.1)
|
96
|
+
ast (~> 2.4.1)
|
97
|
+
polyfill (1.9.0)
|
98
|
+
puma (3.12.6)
|
99
|
+
racc (1.5.2)
|
100
|
+
rack (2.2.3)
|
97
101
|
rack-test (1.1.0)
|
98
102
|
rack (>= 1.0, < 3)
|
99
103
|
rails (5.2.4.2)
|
@@ -125,13 +129,12 @@ GEM
|
|
125
129
|
safe_type (1.1.1)
|
126
130
|
sorbet (0.5.5480)
|
127
131
|
sorbet-static (= 0.5.5480)
|
128
|
-
sorbet-coerce (0.
|
132
|
+
sorbet-coerce (0.4.0)
|
129
133
|
polyfill (~> 1.8)
|
130
134
|
safe_type (~> 1.1, >= 1.1.1)
|
131
|
-
sorbet (>= 0.4.4704)
|
132
135
|
sorbet-runtime (>= 0.4.4704)
|
133
136
|
sorbet-runtime (0.5.5480)
|
134
|
-
sorbet-static (0.5.5480-universal-darwin-
|
137
|
+
sorbet-static (0.5.5480-universal-darwin-19)
|
135
138
|
sprockets (4.0.0)
|
136
139
|
concurrent-ruby (~> 1.0)
|
137
140
|
rack (> 1, < 3)
|
@@ -151,15 +154,16 @@ GEM
|
|
151
154
|
railties (>= 5.0)
|
152
155
|
websocket-driver (0.7.1)
|
153
156
|
websocket-extensions (>= 0.1.0)
|
154
|
-
websocket-extensions (0.1.
|
157
|
+
websocket-extensions (0.1.5)
|
155
158
|
|
156
159
|
PLATFORMS
|
157
160
|
ruby
|
161
|
+
x86_64-darwin-19
|
158
162
|
|
159
163
|
DEPENDENCIES
|
160
164
|
byebug
|
161
165
|
jbuilder (~> 2.5)
|
162
|
-
puma (~> 3.
|
166
|
+
puma (~> 3.12)
|
163
167
|
rails (~> 5.2.4, >= 5.2.4.2)
|
164
168
|
sorbet
|
165
169
|
sorbet-rails!
|
@@ -172,4 +176,4 @@ RUBY VERSION
|
|
172
176
|
ruby 2.5.5p157
|
173
177
|
|
174
178
|
BUNDLED WITH
|
175
|
-
2.0
|
179
|
+
2.2.0
|
@@ -47,6 +47,11 @@ class Wizard < ApplicationRecord
|
|
47
47
|
blue: 2,
|
48
48
|
}, _prefix: :color, _suffix: :eyes
|
49
49
|
|
50
|
+
serialize :owl_results, Hash
|
51
|
+
serialize :newt_subjects # no specific data type, uses the default YAML Object coder
|
52
|
+
serialize :pets, Array
|
53
|
+
serialize :patronus_characteristics, JSON
|
54
|
+
|
50
55
|
has_one :wand
|
51
56
|
has_many :spell_books
|
52
57
|
# habtm which is optional at the db level
|