Skip to content

Commit

Permalink
Merge pull request #72 from khataev/frozen-string-literal-fix
Browse files Browse the repository at this point in the history
Fix issue with 'from' clause and frozen_string_literal magic comment
  • Loading branch information
Empact authored Jul 6, 2020
2 parents e0f1a5e + 920494f commit d6675eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/roxml/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def initialize(sym, opts = {}, &block)
@sought_type = :namespace
elsif opts[:from].to_s.starts_with?('@')
@sought_type = :attr
opts[:from].sub!('@', '')
opts[:from] = opts[:from].sub('@', '')
end

@name = @attr_name = accessor.to_s.chomp('?')
Expand Down
7 changes: 6 additions & 1 deletion spec/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ def self.from_xml(val)
end

describe "options" do

shared_examples_for "boolean option" do
it "should be recognized" do
ROXML::Definition.new(:author, :from => :content, @option => true).respond_to?(:"#{@option}?")
Expand Down Expand Up @@ -468,4 +467,10 @@ def self.from_xml(val)
it_should_behave_like "boolean option"
end
end

describe 'frozen_string_literal behavior' do
it 'should not raise error' do
expect { ROXML::Definition.new(:element, :from => '@somewhere'.freeze) }.not_to raise_error(FrozenError)
end
end
end

0 comments on commit d6675eb

Please sign in to comment.