Sha256: 63c2a7200c2fc8a4fea6d2ede60e445a65c9e45b3f46934be8042c0d84e351ea

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Locomotive::Liquid::Tags::Consume do
  
  context '#validating syntax' do
    
    it 'validates a basic syntax' do
      markup = 'blog from "http://blog.locomotiveapp.org"'
      lambda do
        Locomotive::Liquid::Tags::Consume.new('consume', markup, ["{% endconsume %}"])
      end.should_not raise_error
    end
    
    it 'validates more complex syntax with attributes' do
      markup = 'blog from "http://www.locomotiveapp.org" username: "john", password: "easyone"'
      lambda do
        Locomotive::Liquid::Tags::Consume.new('consume', markup, ["{% endconsume %}"])
      end.should_not raise_error
    end

    it 'raises an error if the syntax is incorrect' do
      markup = 'blog from http://www.locomotiveapp.org'
      lambda do
        Locomotive::Liquid::Tags::Consume.new('consume', markup, ["{% endconsume %}"])
      end.should raise_error
    end
    
  end
    
  context '#rendering' do
    
    it 'puts the response into the liquid variable' do
      Locomotive::Httparty::Webservice.stubs(:get).returns({ 'title' => 'Locomotive rocks !' })
      template = "{% consume blog from \"http://blog.locomotiveapp.org/api/read\" %}{{ blog.title }}{% endconsume %}"
      Liquid::Template.parse(template).render.should == 'Locomotive rocks !'
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 spec/lib/locomotive/liquid/tags/consume_spec.rb
locomotive_cms-0.0.3.1 spec/lib/locomotive/liquid/tags/consume_spec.rb
locomotive_cms-0.0.2.9 spec/lib/locomotive/liquid/tags/consume_spec.rb
locomotive_cms-0.0.2.8 spec/lib/locomotive/liquid/tags/consume_spec.rb