File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 {
1616 "caption" : " RSpec: Create new module" ,
1717 "command" : " rspec_create_module"
18+ },
19+ {
20+ "caption" : " RSpec: Generate specification" ,
21+ "command" : " rspec_generate_specification" ,
1822 }
1923]
Original file line number Diff line number Diff line change @@ -29,3 +29,4 @@ RSpec does not define default key bindings to avoid conflicts with other package
2929* Command to go to the corresponding spec / source file (available in the Command Palette, can be configured to a keyboard shortcut)
3030* Large amount of * RSpec* snippets
3131* Symbol support: use Goto Symbol... inside an RSpec file and you will get a menu with the specification as you've defined it
32+ * You can also generate a structured document of a spec file with the "RSpec: Generate specification" command
Original file line number Diff line number Diff line change 1+ import sublime
2+ import sublime_plugin
3+
4+
5+ class RspecGenerateSpecificationCommand (sublime_plugin .WindowCommand ):
6+ def run (self ):
7+ view = self .window .active_view ()
8+ if view is None :
9+ return
10+
11+ symbols = view .symbol_regions ()
12+ result = []
13+ for symbol in symbols :
14+ # Sublime automatically assigns NAMESPACE for "RSpec.describe" format
15+ # https://github.com/sublimehq/sublime_text/issues/3315
16+ if symbol .kind [0 ] in (sublime .KindId .KEYWORD , sublime .KindId .NAMESPACE ):
17+ result .append (symbol .name )
18+
19+ doc_file = self .window .new_file ()
20+ doc_file .set_name ("RSpec specification" )
21+ doc_file .set_scratch (True )
22+ doc_file .run_command ("rspec_insert_content" , {"text" : "\n " .join (result )})
23+
24+ def is_enabled (self ):
25+ view = self .window .active_view ()
26+ if view is None :
27+ return False
28+
29+ syntax = view .syntax ()
30+ return syntax and syntax .scope == "source.ruby.rspec"
Original file line number Diff line number Diff line change @@ -19,8 +19,10 @@ Report bugs or request features in the Github repo: https://github.com/SublimeTe
1919
2020
2121
22- # Other improvements
22+ # Other improvements and new features
2323
2424- Added improved syntax, courtesy of @themilkman
25+ - Extended to include all RSpec matchers available in the latest version (3.13)
2526- Scope commands so they don't appear when they are not relevant.
2627- Fixed support for symbol lists. Now doing "Goto Symbol" inside an RSpec file will basically show the specification.
28+ - Added a command, "RSpec: Generate specification" that generates the specification in a new tab.
Original file line number Diff line number Diff line change 1+ import sublime
2+ import sublime_plugin
3+
4+
15def other_group_in_pair (window ):
26 """Returns the neighbour focus group for the current window."""
37 if window .active_group () % 2 == 0 :
48 target_group = window .active_group () + 1
59 else :
610 target_group = window .active_group () - 1
711 return min (target_group , window .num_groups () - 1 )
12+
13+
14+ # TODO: Call from RspecNewModuleCommand and RspecNewSpecCommand
15+ class RspecInsertContentCommand (sublime_plugin .TextCommand ):
16+ def run (self , edit : sublime .Edit , text : str = "" ):
17+ self .view .insert (edit , 0 , text )
You can’t perform that action at this time.
0 commit comments