Sha256: 3b946ec07da8f00fd063b6a21943d58d98d4ee7cca28387fd58c5263eccc5c1d

Contents?: true

Size: 1.79 KB

Versions: 11

Compression:

Stored size: 1.79 KB

Contents

require 'helper'
require 'tempfile'
require 'turnip_formatter/renderer/html'

module TurnipFormatter::Renderer
  class TestHtml < Test::Unit::TestCase
    def setup
      Html.reset!

      Html.add_javascript(@script_path)
      Html.add_stylesheet(@style_path)
    end

    def teardown
      Html.reset!
    end

    sub_test_case 'with local file' do
      def setup
        @script_path = Tempfile.open(['local', 'js']) do |f|
          f.write('var s = 1 + 1')
          f.path
        end

        @style_path = Tempfile.open(['local', 'css']) do |f|
          f.write('body { }')
          f.path
        end

        super
      end

      def test_render_javascript_codes
        assert_match(/#{Regexp.escape('var s = 1 + 1')}/, Html.render_javascript_codes)
      end

      def test_render_javascript_links
        assert Html.render_javascript_links.empty?
      end

      def test_render_stylesheet_codes
        assert_match(/#{Regexp.escape('body { }')}/, Html.render_stylesheet_codes)
      end

      def test_render_stylesheet_links
        assert Html.render_stylesheet_links.empty?
      end
    end

    sub_test_case 'with remote file' do
      def setup
        @script_path = 'http://example.com/foo.js'
        @style_path = 'http://example.com/foo.css'

        super
      end

      def test_render_javascript_codes
        assert Html.render_javascript_codes.empty?
      end

      def test_render_javascript_links
        assert_match(/#{Regexp.escape('http://example.com/foo.js')}/, Html.render_javascript_links)
      end

      def test_render_stylesheet_codes
        assert Html.render_stylesheet_codes.empty?
      end

      def test_render_stylesheet_links
        assert_match(/#{Regexp.escape('http://example.com/foo.css')}/, Html.render_stylesheet_links)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
turnip_formatter-0.8.0 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.7.2 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.7.1 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.7.0 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.1 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.0 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.0.pre.beta.7 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.0.pre.beta.6 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.0.pre.beta.5 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.0.pre.beta.4 test/turnip_formatter/renderer/test_html.rb
turnip_formatter-0.6.0.pre.beta.3 test/turnip_formatter/renderer/test_html.rb