Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental: Publish RBI signatures to enable type-checked TDD #22

Merged
merged 205 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
205 commits
Select commit Hold shift + click to select a range
8cb4238
install deps
searls May 21, 2023
8bed1cd
be tapioca init
searls May 21, 2023
f218c56
don't extend struct new
searls May 21, 2023
fb20bb6
add # typed: true everywhere
searls May 24, 2023
93f8153
fix tests that depended on line numbers (which were all just bumped +2
searls May 24, 2023
793f56c
Make the tests pass
searls Jun 1, 2023
9cf1ebf
Try writing an example project that will consume mocktail and use it …
searls Jun 1, 2023
2011ee5
continue iterating on sorbet support
searls Jun 2, 2023
d906906
This return proc should never be used in practice, so just return nil…
searls Jun 2, 2023
78f3b3f
make this more accurate
searls Jun 2, 2023
f9fc568
Amazingly, type-checked stubbing works!
searls Jun 2, 2023
e61042d
run sorbet in actions
searls Jun 2, 2023
cc3a36b
fix actions
searls Jun 2, 2023
4af4d30
upgrade to strict type-checking
searls Jun 2, 2023
6f4920b
clear deprecations
searls Jun 2, 2023
28c7dd0
update test -- realize need for testing typechecking fails
searls Jun 2, 2023
20ed13d
continue iterating, this time building a harness allowing me to ensur…
searls Jun 2, 2023
47da91d
make this test fail
searls Jun 2, 2023
80f630e
Fix test
searls Jun 2, 2023
5de691f
iterate
searls Jun 2, 2023
5f45d95
add another test
searls Jun 5, 2023
6ebb8d8
tweak to clarify next commit
searls Jun 5, 2023
27dd42e
Why does Tapioca only seem to successfully merge my custom `sig` call…
searls Jun 5, 2023
60c3b7c
Start figuring out how to type matchers
searls Jun 5, 2023
f2e9525
write a type sig for m.is_a?
searls Jun 5, 2023
dc91c46
fix matcher name
searls Jun 6, 2023
6524c33
get test to a point where it's screwed up
searls Jun 6, 2023
bd8aad6
WIP
searls Jun 6, 2023
2c72835
Revert "WIP"
searls Jun 6, 2023
77b581f
try @paracycle's refinement approach -- not working yet
searls Jun 6, 2023
040f864
try just rewriting the methods instead of refining
searls Jun 6, 2023
0650a65
unwind this since it won't work with unbound methods
searls Jun 6, 2023
4b6fe5c
Revert "Revert "WIP""
searls Jun 6, 2023
3e34479
fixes the issue! All praise to @paracycle
searls Jun 6, 2023
752ecda
revert this change from 2011ee5
searls Jun 6, 2023
2d14bc2
don't type the main files, only tests
searls Jun 6, 2023
cdb7479
don't typecheck the child project with the parent (duplicate warnings)
searls Jun 6, 2023
6246663
wrap illegal calls
searls Jun 6, 2023
b285f07
fix test
searls Jun 6, 2023
03a7422
these changes seem to work and the RBI is unaffected
searls Jun 7, 2023
93fad57
Extracting this sig from the RBI file to the source results in tapioc…
searls Jun 7, 2023
6b5559a
Revert "Extracting this sig from the RBI file to the source results i…
searls Jun 7, 2023
754c08b
Revert "these changes seem to work and the RBI is unaffected"
searls Jun 7, 2023
0b35b5e
remove sorbet-runtime dep from mocktail - don't plan to saddle users …
searls Jun 7, 2023
5c190ad
bundle update
searls Jun 7, 2023
bf52090
start a sig for m.includes()
searls Jun 7, 2023
2381bab
make this a bit more greppable
searls Jun 7, 2023
28095f2
allow Numeric to match Numerics, lol
searls Jun 7, 2023
d588cf6
Continue iterating
searls Jun 7, 2023
efd6cc7
fix tests for < 3.2
searls Jun 7, 2023
52be005
Add Captor and Replace typing, as well as starting Explain stuff
searls Jun 8, 2023
a1167a5
Finally get the test suite type-checking, cover Explain more meaningf…
searls Jun 9, 2023
50d2728
formatting
searls Jun 9, 2023
b1c9a50
Thanks @jez for pointing me to https://github.com/sorbet/sorbet/blob/…
searls Jun 10, 2023
4bb8037
Give up on custom matcher typing for now, add explain_nils, add stuff
searls Jun 10, 2023
ca86e96
failing test -- this parameterized type has gotta be wrong
searls Jun 10, 2023
2f8f1ce
Get rid of unused parameterized type member and instead override refe…
searls Jun 10, 2023
efbfd14
take another stab at runtime dep
searls Jun 10, 2023
136f767
hack a fix
searls Jun 10, 2023
c580637
one more thing
searls Jun 10, 2023
47b0559
Move ExplanationData interface out of RBI and into source
searls Jun 10, 2023
8923de2
the hotfixes will continue until morale improve
searls Jun 10, 2023
c802dcb
Bump some values to strict, break unsatisfying explanation off since …
searls Jun 10, 2023
8c05f49
sorbet found two bugs zomg!!!!
searls Jun 10, 2023
294b2d1
iterating
searls Jun 10, 2023
76a69b0
iterating
searls Jun 10, 2023
e4ac847
baby steps
searls Jun 10, 2023
0062f42
convert Call to be typed as a T::Struct. Was kind of a pain
searls Jun 11, 2023
523444d
Don't add `include Kernel` to a module, use `require_ancestor` instead
searls Jun 12, 2023
f621e93
Revert "Don't add `include Kernel` to a module, use `require_ancestor…
searls Jun 12, 2023
67a5389
upgrade things
searls Jun 12, 2023
99a8966
upgrayyed
searls Jun 17, 2023
c8746e1
baby steps
searls Jun 17, 2023
4285581
Run tests without typechecks. Introduces this flake:
searls Jun 17, 2023
63f0a2e
fix flake
searls Jun 17, 2023
e4e9d11
warn folks about runtime check issues in the readme (make this more g…
searls Jun 17, 2023
63aa7e2
prove custom matchers can work with types
searls Jun 17, 2023
9178985
replace hack with static rbi
searls Jun 21, 2023
5d093b9
disable ruby-head b/c sorbet failing
searls Jun 21, 2023
24b1c92
update deps
searls Jun 21, 2023
480f386
enable typing for lib/mocktail/handles_dry_call
searls Jun 21, 2023
97f4c09
Enable typing on lib/mocktail/imitates_type
searls Jun 21, 2023
4b1edef
Enable typing on lib/mocktail/matchers
searls Jun 21, 2023
f72b67c
Enable typing on lib/mocktail/replaces_type
searls Jun 21, 2023
305ec0b
Enable typing on lib/mocktail/share/
searls Jun 21, 2023
6891312
Enable typing on lib/mocktail/simulates_argument_error
searls Jun 21, 2023
4de157f
Enable typing on lib/mocktail/value
searls Jun 21, 2023
f5a1e40
Enable typing on lib/mocktail/verifies_call
searls Jun 21, 2023
6b0fef4
Enable typing on lib/mocktail/
searls Jun 21, 2023
30e9528
get to 100% type sigils
searls Jun 21, 2023
814e515
add sigs
searls Jun 21, 2023
5db3b43
iterating
searls Jun 21, 2023
9795a7f
iterate
searls Jun 21, 2023
194c7c2
update to fix https://github.com/Shopify/spoom/issues/400#event-95951…
searls Jun 21, 2023
2129b3d
Really tightened up the values here.
searls Jun 21, 2023
167434b
iterate
searls Jun 21, 2023
dbb595a
strict
searls Jun 21, 2023
526e7db
cool
searls Jun 21, 2023
79054db
type the matchers
searls Jun 21, 2023
95242fe
more sigs
searls Jun 21, 2023
f6d6431
get a little stricter on booleans
searls Jun 21, 2023
2c46aee
progress
searls Jun 21, 2023
a13d150
make stricter
searls Jun 21, 2023
e8fab92
more work
searls Jun 21, 2023
05f0c49
iterating
searls Jun 22, 2023
6b83d12
that was a pain
searls Jun 22, 2023
b705a9d
more
searls Jun 22, 2023
8bd4b6e
more
searls Jun 22, 2023
f166c87
oof
searls Jun 22, 2023
5fe2a65
write some new code actually
searls Jun 22, 2023
4638cd5
baby steps
searls Jun 22, 2023
7644ff4
Caught an honest-to-god bug. Mocks of modules didn't include the full…
searls Jun 22, 2023
ba19195
eliminate some T.untypeds
searls Jun 22, 2023
a17f215
whackamole on T.untyped
searls Jun 22, 2023
1657012
Made an executive decision to not override the sorbet signature hooks…
searls Jun 23, 2023
47c7dad
work
searls Jun 23, 2023
1ffa724
doops
searls Jun 23, 2023
ba9368c
progress
searls Jun 23, 2023
ce72efd
this sucked.
searls Jun 23, 2023
b1bbc5d
turns out none of that module stuff worked :(
searls Jun 23, 2023
3f77c47
progress
searls Jun 23, 2023
f57992d
progress
searls Jun 24, 2023
88c3b60
matchers are incredibly typed
searls Jun 24, 2023
d9736df
finish up
searls Jun 24, 2023
56a3a09
add sorbet-eraser
searls Jun 25, 2023
c456675
bundle update
searls Jun 25, 2023
44c494d
preemptive sorbet-eraser prep
searls Jun 25, 2023
6076eda
Move the code from lib/ to src/ in order to facilitate a build step t…
searls Jun 25, 2023
3161aaf
doesn't work for rake anyway
searls Jun 25, 2023
c196727
didn't end up needing this
searls Jun 25, 2023
4cac514
get tests passing
searls Jun 25, 2023
2847d72
do a build -- almost everything passing but tapioca type info generat…
searls Jun 25, 2023
0da5e66
This build script is getting away from me.
searls Jun 26, 2023
d1885d2
tweaks
searls Jun 27, 2023
d66af79
Get ./script/test passing!
searls Jun 27, 2023
018488c
start stripping sigil comments
searls Jun 27, 2023
3df266b
typecheck the sorbet distribution even tho lib/ is ignored
searls Jun 27, 2023
80d01e5
add warnings to handle people requiring both mocktail AND mocktail/so…
searls Jun 27, 2023
bef51ca
fix script for ruby 3
searls Jun 28, 2023
2f33bbf
update scripts to print the output
searls Jun 28, 2023
90e6eda
improve the message a bit
searls Jun 28, 2023
f8d49e3
wups
searls Jun 28, 2023
1a7e778
🤦‍♂️
searls Jun 28, 2023
5df3d88
move sub-project directories
searls Jun 28, 2023
9876d62
annoyingly, sorbet-eraser doesn't seem to do anything when required i…
searls Jun 28, 2023
2fd7bd8
$ bundle exec ruby foo.rb #=> T::Generic
searls Jun 28, 2023
4a39966
$ bundle exec ruby foo.rb
searls Jun 28, 2023
248affd
clear out
searls Jun 28, 2023
29e0c06
ways to run a railroad include
searls Jun 28, 2023
e2a13b1
some tests
searls Jun 28, 2023
31de1d7
bring in setup
searls Jun 29, 2023
360e71a
add a more rigorous sorbet test
searls Jun 30, 2023
6b8d887
Fix this unnecessary addition
searls Jun 30, 2023
d5f4821
Remove hack preventing triggering of tapioca generic issue
searls Jun 30, 2023
ec053ac
try updating to latest rbi to see if that fixes it
searls Jul 12, 2023
7296b1f
make sure we're clearing this generated rbi each time
searls Jul 12, 2023
4b18e01
update deps
searls Jul 12, 2023
c106faf
Revert "update deps"
searls Jul 12, 2023
7f04084
get the build passing again
searls Jul 12, 2023
4d706e5
sorbet-eraser 0.4.0 regressions
searls Jul 12, 2023
8ac9c40
Revert "sorbet-eraser 0.4.0 regressions"
searls Jul 12, 2023
9600657
start rewriting all the docs
searls Aug 10, 2023
2d4d56b
update deps
searls Aug 10, 2023
f7ae8f3
doc futzing
searls Aug 11, 2023
4e37f1d
docs
searls Aug 11, 2023
25e6a59
docs
searls Aug 11, 2023
959cbf9
get more reserved in throwing the word singleton around
searls Aug 11, 2023
ed072db
flatten sorbet/untyped trees as it's looking more likely sorbet will …
searls Aug 11, 2023
f5fa8b8
docs
searls Aug 11, 2023
5b4cfec
words
searls Aug 14, 2023
5e37f59
may not exist
searls Aug 14, 2023
875711b
mocking http
searls Aug 14, 2023
e1ccc86
words
searls Aug 14, 2023
e29fb4a
partial mocks and proxies
searls Aug 14, 2023
efb5c9a
tweaks
searls Aug 14, 2023
d2b18c2
docs
searls Aug 17, 2023
75d0969
words
searls Aug 17, 2023
818642d
words
searls Aug 17, 2023
f245d7c
words
searls Aug 17, 2023
11092b8
fix
searls Aug 17, 2023
ca9d296
add a hr
searls Aug 17, 2023
010ffa9
fix
searls Aug 17, 2023
e04f997
doc
searls Aug 18, 2023
05583cd
words
searls Aug 18, 2023
b8b4a18
add demonstration
searls Aug 18, 2023
210d3e8
WIP
searls Aug 18, 2023
f33d8ba
sorta got stuck
searls Aug 19, 2023
07a088f
Cut this stuff -- it's just too obscure for beginners.
searls Aug 19, 2023
626a3ac
add docs
searls Aug 20, 2023
ce55fd0
docs
searls Aug 21, 2023
05a35ef
center?
searls Aug 21, 2023
81b70bb
words
searls Aug 21, 2023
b9faa69
first example checkpoint
searls Aug 21, 2023
92af64e
docs
searls Aug 23, 2023
51767e1
work
searls Aug 23, 2023
2f78f51
doc
searls Aug 23, 2023
7a4a5ce
words
searls Aug 23, 2023
d589ee8
words
searls Aug 23, 2023
33bbbce
docs
searls Aug 23, 2023
2caf74e
update deps
searls Aug 23, 2023
e5282df
clear out cruft from pregenerated rbi, remove it before generating to…
searls Aug 23, 2023
2fd867d
Fix everything after upgrades, add standard-sorbet, fix T.untyped in …
searls Aug 23, 2023
dea038e
Add images for the readme
searls Aug 23, 2023
3f84c43
readme
searls Aug 24, 2023
2a48c90
copy
searls Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
ruby-version: ['3.0', '3.1']
ruby-version: ['3.0', '3.1', '3.2']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run the default task
- name: Install gem dependencies
run: |
gem install bundler
bundle install
bundle exec rake
./script/setup
- name: Run the test script
run: ./script/test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Generated RBI that will be moved into rbi/
/sub_projects/rbi_generator/sorbet/rbi/gems/*.rbi

/.bundle/
/.yardoc
/_yardoc/
Expand Down
8 changes: 8 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
ruby_version: 3.0

plugins:
- standard-sorbet

ignore:
- "{docs,lib,sub_projects/untyped_user}/**/*.rb":
- Sorbet/FalseSigil

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Unreleased

* **Breaking change (you probably won't care about)** - When an unknown object
is passed to `Mocktail.explain`, the returned object's `reference` will now be
set to a `NoExplanationData` instead of the thing that was passed. To access
that unknown thing, you can call `NoExplanationData#thing`, (i.e.
`Mocktail.explain(lol_not_a_mock).reference.thing` and get a reference back to
`lol_not_a_mock`.)
* **Breaking change (you probably won't care about)** - If you fake a class with
module that overloads `nil?` or `is_a?` you _may_ get an infinite recursion if you
override it. See
[this skipped test](/test/safe/mocking_methodful_classes_test.rb)

# 1.2.2

* As promised in 1.2.1, there were bugs. [#19](https://github.com/testdouble/mocktail/pull/19)
Expand Down
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ gemspec
gem "rake"
gem "minitest"
gem "standard"
gem "pry"
gem "standard-sorbet"
gem "simplecov"
gem "m"

gem "sorbet-static"
gem "tapioca"
gem "spoom"
gem "rubocop-sorbet"
121 changes: 97 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,124 @@ PATH
remote: .
specs:
mocktail (1.2.2)
sorbet-eraser (~> 0.3.1)
sorbet-runtime (~> 0.5.9204)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
coderay (1.1.3)
base64 (0.1.1)
diff-lcs (1.5.0)
docile (1.4.0)
json (2.6.2)
erubi (1.12.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
m (1.6.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
method_source (1.0.0)
minitest (5.16.3)
parallel (1.22.1)
parser (3.1.2.1)
minitest (5.19.0)
netrc (0.11.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
racc
prettier_print (1.2.1)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.6.0)
rexml (3.2.5)
rubocop (1.39.0)
rbi (0.0.17)
ast
parser (>= 3.0.0)
sorbet-runtime (>= 0.5.9204)
unparser (>= 0.5.6)
regexp_parser (2.8.1)
rexml (3.2.6)
rubocop (1.56.1)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
parser (>= 3.1.1.0)
rubocop-performance (1.15.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
simplecov (0.21.2)
rubocop-sorbet (0.7.3)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
standard (1.18.0)
rubocop (= 1.39.0)
rubocop-performance (= 1.15.0)
unicode-display_width (2.3.0)
sorbet (0.5.10983)
sorbet-static (= 0.5.10983)
sorbet-eraser (0.3.1)
sorbet-runtime (0.5.10983)
sorbet-static (0.5.10983-universal-darwin-14)
sorbet-static (0.5.10983-universal-darwin-15)
sorbet-static (0.5.10983-universal-darwin-16)
sorbet-static (0.5.10983-universal-darwin-17)
sorbet-static (0.5.10983-universal-darwin-18)
sorbet-static (0.5.10983-universal-darwin-19)
sorbet-static (0.5.10983-universal-darwin-20)
sorbet-static (0.5.10983-universal-darwin-21)
sorbet-static (0.5.10983-universal-darwin-22)
sorbet-static (0.5.10983-x86_64-linux)
sorbet-static-and-runtime (0.5.10983)
sorbet (= 0.5.10983)
sorbet-runtime (= 0.5.10983)
spoom (1.2.3)
erubi (>= 1.10.0)
sorbet-static-and-runtime (>= 0.5.10187)
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
standard (1.31.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.0)
standard-sorbet (0.0.2)
lint_roller (~> 1.1)
rubocop-sorbet (~> 0.7.0)
syntax_tree (6.1.1)
prettier_print (>= 1.2.0)
tapioca (0.11.8)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.0.0, >= 0.0.16)
sorbet-static-and-runtime (>= 0.5.10187)
spoom (~> 1.2.0, >= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.2.2)
unicode-display_width (2.4.2)
unparser (0.6.8)
diff-lcs (~> 1.3)
parser (>= 3.2.0)
yard (0.9.34)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)

PLATFORMS
arm64-darwin-20
Expand All @@ -60,10 +129,14 @@ DEPENDENCIES
m
minitest
mocktail!
pry
rake
rubocop-sorbet
simplecov
sorbet-static
spoom
standard
standard-sorbet
tapioca

BUNDLED WITH
2.3.6
Loading