Skip to content

Commit 2f84f0c

Browse files
committed
Merge branch 'hotfix-0.1.2'
2 parents 0ffd091 + 0a28a07 commit 2f84f0c

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

lib/code_breaker/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

lib/code_breaker/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CodeBreaker
2-
VERSION = "0.1.1"
2+
VERSION = "0.1.2"
33
end

spec/code_breaker/parser_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
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

0 commit comments

Comments
 (0)