Usually I use incremental searching to find what I'm looking for. Also, in general I write very small methods that easily fit in one screen. So before now I have had little use for any sort of code-folding mechanism, which is good because of the general communal distaste for such things.
But one exception to this is with tests. Right now I use rspec
and I'm finding it frustrating to navigate the tests. A test file I'm working on has about 500 lines so far and is structured like this:
Rspec.describe SomeClass do
let(:some_common_variable) { create :the_thing }
context 'with foos' do
it 'does a thing' do
# ... ~10 lines of arrange -> act -> assert stuff
end
end
context 'with bars' do
it 'does a thing differently' do
# ... ~10 lines of arrange -> act -> assert stuff
end
end
end
So as you can see this makes some common-sense coding styles (like short methods) impossible. At the end of these tests I also have:
end
end
end
end
end
which makes it pretty tricky to figure out which "end" I want to insert a new test after -- especially because the matching do
is not on the screen.
My question is: When I'm in the middle of some test, is there some way I can generate a breadcrumb that looks like this:
Someclass / with foos / it does a thing
Right now I'm using M-x occur
with a regex I wrote that includes things like it
, context
, Rspec.describe
, etc. to get an outline. Also, is there some code folding mode that makes it easy to quickly fold everything in an "it" block without folding everything else, but also have the ability to fold everything else with a different command.