Sha256: 3217d09e0abb043dc3e55a5b9008e593899a308d395180a8d82c69ffc29b3177

Contents?: true

Size: 1.96 KB

Versions: 65

Compression:

Stored size: 1.96 KB

Contents

require File.expand_path('../helper', __FILE__)

begin
require 'markaby'

class MarkabyTest < Minitest::Test
  def markaby_app(&block)
    mock_app do
      set :views, File.dirname(__FILE__) + '/views'
      get('/', &block)
    end
    get '/'
  end

  it 'renders inline markaby strings' do
    markaby_app { markaby 'h1 "Hiya"' }
    assert ok?
    assert_equal "<h1>Hiya</h1>", body
  end

  it 'renders .markaby files in views path' do
    markaby_app { markaby :hello }
    assert ok?
    assert_equal "<h1>Hello From Markaby</h1>", body
  end

  it "renders with inline layouts" do
    mock_app do
      layout { 'h1 { text "THIS. IS. "; yield }' }
      get('/') { markaby 'em "SPARTA"' }
    end
    get '/'
    assert ok?
    assert_equal "<h1>THIS. IS. <em>SPARTA</em></h1>", body
  end

  it "renders with file layouts" do
    markaby_app { markaby 'text "Hello World"', :layout => :layout2 }
    assert ok?
    assert_equal "<h1>Markaby Layout!</h1><p>Hello World</p>", body
  end

  it 'renders inline markaby blocks' do
    markaby_app { markaby { h1 'Hiya' } }
    assert ok?
    assert_equal "<h1>Hiya</h1>", body
  end

  it 'renders inline markaby blocks with inline layouts' do
    markaby_app do
      settings.layout { 'h1 { text "THIS. IS. "; yield }' }
      markaby { em 'SPARTA' }
    end
    assert ok?
    assert_equal "<h1>THIS. IS. <em>SPARTA</em></h1>", body
  end

  it 'renders inline markaby blocks with file layouts' do
    markaby_app { markaby(:layout => :layout2) { text "Hello World" } }
    assert ok?
    assert_equal "<h1>Markaby Layout!</h1><p>Hello World</p>", body
  end

  it "raises error if template not found" do
    mock_app { get('/') { markaby :no_such_template } }
    assert_raises(Errno::ENOENT) { get('/') }
  end

  it "allows passing locals" do
    markaby_app {
      markaby 'text value', :locals => { :value => 'foo' }
    }
    assert ok?
    assert_equal 'foo', body
  end
end

rescue LoadError
  warn "#{$!.to_s}: skipping markaby tests"
end

Version data entries

65 entries across 62 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.1.9 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.8 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.7 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.6 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.4 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.3 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-scalyr-0.1.2 vendor/bundle/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/markaby_test.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/markaby_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/sinatra-1.4.8/test/markaby_test.rb