Sha256: 0942c8fabb7a5e0c082a6894ffa6443472ba11691d705caef04df639f2fcbec6

Contents?: true

Size: 1.84 KB

Versions: 6

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'
require 'volt/page/path_string_renderer'

unless RUBY_PLATFORM == 'opal'
  describe Volt::PathStringRenderer do
    before do
      kitchen_sink_path = File.expand_path(File.join(File.dirname(__FILE__), '../apps/kitchen_sink'))
      @volt_app = Volt::App.new(kitchen_sink_path)
    end

    it 'should render a section' do
      html = Volt::PathStringRenderer.new(@volt_app, 'main/mailers/welcome/subject', nil).html
      expect(html).to eq("\n  Welcome to the site!\n\n")
    end

    it 'should render a section with a variable' do
      html = Volt::PathStringRenderer.new(@volt_app, 'main/mailers/welcome/html', { name: 'Jimmy' }).html
      expect(html).to eq("\n  <h1>Welcome Jimmy</h1>\n\n  <p>Glad you signed up!</p>\n\n")
    end

    it 'should render with an attribute binding' do
      html = Volt::PathStringRenderer.new(@volt_app, 'main/mailers/reset_password/html', { reset_url: 'http://resetthepassword.com/' }).html
      expect(html).to eq("\n  Reset your password <a target=\"_new\" id=\"id0\" href=\"http://resetthepassword.com/\">here</a>.\n\n  <a id=\"id1\" href=\"http://resetthepassword.com/\">Reset Password</a>\n\n")
    end

    it 'Raises raises ViewLookupException if full_path is nil' do
      expect do
        Volt::PathStringRenderer.new(@volt_app, '', { name: 'Jimmy' }).html
      end.to raise_error(Volt::ViewLookupException)
    end

    it 'Raises raises ViewLookupException if full_path is wrong' do
      expect do
        Volt::PathStringRenderer.new(@volt_app, 'some/missing/path/thing', { name: 'Jimmy' }).html
      end.to raise_error(Volt::ViewLookupException)
    end

    it 'Raises raises ViewLookupException if full_path is wrong' do
      expect do
        Volt::PathStringRenderer.new(@volt_app, 'wrong/main', { name: 'Jimmy' }).html
      end.to raise_error(Volt::ViewLookupException)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 spec/page/path_string_renderer_spec.rb
volt-0.9.7.pre7 spec/page/path_string_renderer_spec.rb
volt-0.9.7.pre6 spec/page/path_string_renderer_spec.rb
volt-0.9.7.pre5 spec/page/path_string_renderer_spec.rb
volt-0.9.7.pre3 spec/page/path_string_renderer_spec.rb
volt-0.9.7.pre2 spec/page/path_string_renderer_spec.rb