Skip to content

Commit

Permalink
Fixed a bug where nil fields would raise an exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
johncarney committed Mar 6, 2015
1 parent 0d5c8b7 commit 524f48d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/pikelet/field_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def initialize(index, parse: nil, type: :alpha, format: nil, pad: nil, align: ni

def parse(record)
# TODO: Test that fields are always stripped.
if value = record[index].strip
if value = record[index]
value.strip!
if parser
parser.to_proc.call(value)
else
Expand Down
2 changes: 1 addition & 1 deletion spec/pikelet/field_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

subject { definition }

its(:parser) { is_expected.to eq :strip }
its(:parser) { is_expected.to be_nil }
its(:formatter) { is_expected.to eq :to_s }
its(:padding) { is_expected.to eq " " }
its(:alignment) { is_expected.to eq :left }
Expand Down

0 comments on commit 524f48d

Please sign in to comment.