templater 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/templater.rb +1 -1
- data/lib/templater/description.rb +1 -1
- data/spec/generator/arguments_spec.rb +8 -0
- metadata +1 -1
    
        data/lib/templater.rb
    CHANGED
    
    
| @@ -49,7 +49,7 @@ module Templater | |
| 49 49 | 
             
                  when :hash
         | 
| 50 50 | 
             
                    if argument.is_a?(String)
         | 
| 51 51 | 
             
                      return argument.split(',').inject({}) do |h, pair|
         | 
| 52 | 
            -
                        key, value = pair.split(':')
         | 
| 52 | 
            +
                        key, value = pair.strip.split(':')
         | 
| 53 53 | 
             
                        raise Templater::MalformattedArgumentError, "Expected '#{argument.inspect}' to be a key/value pair" unless key and value
         | 
| 54 54 | 
             
                        h[key] = value
         | 
| 55 55 | 
             
                        h
         | 
| @@ -204,6 +204,14 @@ describe Templater::Generator, '.argument as hash' do | |
| 204 204 | 
             
                instance.llama['river'].should == 'road'
         | 
| 205 205 | 
             
              end
         | 
| 206 206 |  | 
| 207 | 
            +
              it "should strip key/value pairs" do
         | 
| 208 | 
            +
                instance = @generator_class.new('/tmp', {}, 'a monkey', 'test:unit, john:silver, river:road,   silver:bullet')
         | 
| 209 | 
            +
                instance.llama['test'].should == 'unit'
         | 
| 210 | 
            +
                instance.llama['john'].should == 'silver'
         | 
| 211 | 
            +
                instance.llama['river'].should == 'road'
         | 
| 212 | 
            +
                instance.llama['silver'].should == 'bullet'
         | 
| 213 | 
            +
              end
         | 
| 214 | 
            +
             | 
| 207 215 | 
             
              it "should raise an error if one of the remaining arguments is not a key/value pair" do
         | 
| 208 216 | 
             
                lambda { @generator_class.new('/tmp', {}, 'a monkey', 'a:llama,duck:llama,not_a_pair,pair:blah') }.should raise_error(Templater::MalformattedArgumentError)
         | 
| 209 217 | 
             
              end
         |