Sha256: 63c89e73a987ca9efe4f26f74ca5f7b2236b9fe3c860fb7f39a21699d3f59301

Contents?: true

Size: 1.69 KB

Versions: 38

Compression:

Stored size: 1.69 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_paths = [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_paths = [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

38 entries across 38 versions & 1 rubygems

Version Path
virgo-0.3.17 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.16 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.15 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.14 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.13 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.12 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.11 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.10 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.9 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.8 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.7 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.6 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.4 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.3 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.2 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3.1 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.3 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.2.9 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.2.8 vendor/gems/shortcode/spec/rails_helpers_spec.rb
virgo-0.2.7 vendor/gems/shortcode/spec/rails_helpers_spec.rb