File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def initialize(code)
2121 def run
2222 unless @output
2323 ast = ::Parser ::CurrentRuby . parse ( input )
24- @output = parse ( ast . loc . node )
24+ @output = ast . nil? ? [ ] : parse ( ast . loc . node )
2525 end
2626
2727 @output
Original file line number Diff line number Diff line change 11module CodeBreaker
2- VERSION = "0.1.1 "
2+ VERSION = "0.1.2 "
33end
Original file line number Diff line number Diff line change 1010 it { is_expected . to respond_to :input }
1111 it { is_expected . to respond_to :output }
1212
13+ context 'for an empty string as input' do
14+ it 'returns an empty array' do
15+ expect ( '' ) . to be_parsed_as [ ]
16+ end
17+ end
18+
19+ context 'for a comment as input' do
20+ it 'returns an empty array' do
21+ expect ( '# a comment' ) . to be_parsed_as [ ]
22+ end
23+ end
24+
1325 describe 'input' do
1426 it 'returns the code snippet the parser was instanciated with' do
1527 expect ( subject . input ) . to eq code_snippet
You can’t perform that action at this time.
0 commit comments