Sha256: 14c0a746af38ac2aa453e93744d3407975fb2937a7ae732ea174ab5559a0a9ab

Contents?: true

Size: 1.68 KB

Versions: 7

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

module ShortcodeSpecViewHelper
  def wrap_in_p(content)
    content_tag :p, content
  end
end

describe "rails helpers" do

  let(:template)    { load_fixture :rails_helper }

  let(:erb_output)  { load_fixture :rails_helper_output_erb,  :html }
  let(:haml_output) { load_fixture :rails_helper_output_haml, :html }
  let(:slim_output) { load_fixture :rails_helper_output_slim, :html }

  describe "erb" do

    it "are accessible within erb templates" do
      expect(Shortcode.process(template).gsub("\n",'')).to eq(erb_output)
    end

  end

  describe "haml" do

    before(:each) do
      Shortcode.setup do |config|
        config.template_parser = :haml
        config.template_path = File.join File.dirname(__FILE__), "support/templates/haml"
      end
    end

    it "are accessible within haml templates" do
      expect(Shortcode.process(template).gsub("\n",'')).to eq(haml_output)
    end

  end

  describe "slim" do

    before(:each) do
      Shortcode.setup do |config|
        config.template_parser = :slim
        config.template_path = File.join File.dirname(__FILE__), "support/templates/slim"
      end
    end

    it "are accessible within slim templates" do
      expect(Shortcode.process(template).gsub("\n",'')).to eq(slim_output)
    end

  end

  describe "using a custom helper module" do

    let(:template) { load_fixture :custom_helper }
    let(:output)   { load_fixture :custom_helper_output,  :html }

    before(:each) do
      Shortcode.setup do |config|
        config.helpers = [ShortcodeSpecViewHelper]
      end
    end

    it "is accessible within templates" do
      expect(Shortcode.process(template).gsub("\n",'')).to eq(output)
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shortcode-1.2.1 spec/rails_helpers_spec.rb
shortcode-1.2.0 spec/rails_helpers_spec.rb
shortcode-1.1.1 spec/rails_helpers_spec.rb
shortcode-1.1.0 spec/rails_helpers_spec.rb
shortcode-1.0.2 spec/rails_helpers_spec.rb
shortcode-1.0.0 spec/rails_helpers_spec.rb
shortcode-0.4.3 spec/rails_helpers_spec.rb