diff --git a/lib/locomotive/liquid/tags/with_scope.rb b/lib/locomotive/liquid/tags/with_scope.rb index ea23b339..7f79675d 100644 --- a/lib/locomotive/liquid/tags/with_scope.rb +++ b/lib/locomotive/liquid/tags/with_scope.rb @@ -23,9 +23,9 @@ module Locomotive def decode(attributes, context) attributes.each_pair do |key, value| attributes[key] = (case value - when /true|false/ then value == 'true' - when /[0-9]+/ then value.to_i - when /'(\S+)'/ then $1 + when /^true|false$/i then value == 'true' + when /^[0-9]+$/ then value.to_i + when /^["|'](.+)["|']$/ then $1.gsub(/^["|']/, '').gsub(/["|']$/, '') else context[value] end) diff --git a/spec/models/content_instance_spec.rb b/spec/models/content_instance_spec.rb index ef49fcd5..9669ab61 100644 --- a/spec/models/content_instance_spec.rb +++ b/spec/models/content_instance_spec.rb @@ -41,7 +41,7 @@ describe ContentInstance do end end - + describe "#navigation" do before(:each) do %w(first second third).each_with_index do |item,index| @@ -50,22 +50,21 @@ describe ContentInstance do instance_variable_set "@#{item}", content end end - + it 'should find previous item when available' do - puts @second.previous @second.previous.custom_field_1.should == "first" @second.previous._position_in_list.should == 0 end - + it 'should find next item when available' do @second.next.custom_field_1.should == "third" @second.next._position_in_list.should == 2 end - + it 'should return nil when fetching previous item on first in list' do @first.previous.should == nil end - + it 'should return nil when fetching next item on last in list' do @third.next.should == nil end