Sha256: 97357c65bf26f48e1aa64d3f2d9a2a681625b2ac8bd942c7b86010ac7b3c73d9
Contents?: true
Size: 1.61 KB
Versions: 4
Compression:
Stored size: 1.61 KB
Contents
require 'spec_helper' describe Shortcode::Tag do context "when the template file is missing" do let(:tag) { Shortcode::Tag.new('doesnt_exist') } it "raises a TemplateNotFound error when the file doesn't exists" do expect { tag.render }.to raise_error(Shortcode::TemplateNotFound) end end context "when an unsupported template parser is specified" do let(:tag) { Shortcode::Tag.new('quote') } before(:each) do Shortcode.setup do |config| config.template_parser = :something_crazy end end it "raises a TemplateNotFound error when the file doesn't exists" do expect { tag.render }.to raise_error(Shortcode::TemplateParserNotSupported) end end context "templates from strings" do let(:tag) { Shortcode::Tag.new('from_string', [{ key: 'string', value: 'batman' }]) } before(:each) do Shortcode.setup do |config| config.template_parser = :erb config.templates = { from_string: '<p><%= @attributes[:string] %></p>' } end end it "renders a template from a string" do tag.render.should == '<p>batman</p>' end end context "when the template is missing from the config" do let(:tag) { Shortcode::Tag.new('missing', [{ key: 'string', value: 'batman' }]) } before(:each) do Shortcode.setup do |config| config.template_parser = :erb config.templates = { from_string: '<p><%= @attributes[:string] %></p>' } end end it "raises an error" do expect { tag.render }.to raise_error(Shortcode::TemplateNotFound) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
shortcode-0.3.3 | spec/tag_spec.rb |
shortcode-0.3.2 | spec/tag_spec.rb |
shortcode-0.3.1 | spec/tag_spec.rb |
shortcode-0.3.0 | spec/tag_spec.rb |