Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressable::Template: Substitution with something that is not a Hash #133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/addressable/template.rb
Expand Up @@ -829,6 +829,7 @@ def normalize_value(value)
# @return [Hash]
# A hash with stringified keys
def normalize_keys(mapping)
return mapping unless mapping.respond_to?(:inject)
return mapping.inject({}) do |accu, pair|
name, value = pair
if Symbol === name
Expand Down
6 changes: 6 additions & 0 deletions spec/addressable/template_spec.rb
Expand Up @@ -44,6 +44,12 @@
}
end

describe "Substituting from an optional block" do
sub = lambda { |x| "foo-#{x}" }

Addressable::Template.new("{bar}/{baz}").expand(sub).to_str.should == "foo-bar/foo-baz"
end

describe "Level 1:" do
subject{
{:var => "value", :hello => "Hello World!"}
Expand Down