Sha256: 4c15f80aeaaf21d4215c42af9f3e310b95d815768449b9fa23867b128ad52732

Contents?: true

Size: 1.7 KB

Versions: 36

Compression:

Stored size: 1.7 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'markdown/codes'

describe MarkdownString do
  context :codes do
    cases = [
      {
        case_no: 1,
        case_title: 'string case',
        input: "class Hoge\n  def hoge\n    'hoge'\n  end\nend",
        lang: 'ruby',
        expected: <<-EOS
~~~ruby
class Hoge
  def hoge
    'hoge'
  end
end
~~~
        EOS
      },
      {
        case_no: 2,
        case_title: 'string no lang case',
        input: "class Hoge\n  def hoge\n    'hoge'\n  end\nend",
        lang: nil,
        expected: <<-EOS
~~~
class Hoge
  def hoge
    'hoge'
  end
end
~~~
        EOS
      },
      {
        case_no: 3,
        case_title: 'not string case',
        input: 1,
        lang: 'ruby',
        expected: 1,
      },
      {
        case_no: 4,
        case_title: 'empty case',
        input: '',
        lang: 'ruby',
        expected: <<-EOS
~~~ruby

~~~
        EOS
      },
      {
        case_no: 5,
        case_title: 'nil case',
        input: nil,
        lang: 'ruby',
        expected: <<-EOS
~~~ruby

~~~
        EOS
      },
    ]

    cases.each do |c|
      it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
        begin
          case_before c

          # -- given --
          # nothing

          # -- when --
          actual = MarkdownString.codes c[:input], c[:lang]

          # -- then --
          expect(actual).to eq(c[:expected])
        ensure
          case_after c
        end
      end

      def case_before(c)
        # implement each case before
      end

      def case_after(c)
        # implement each case after
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.130 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.129 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.128 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.127 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.126 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.125 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.124 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.123 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.122 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.121 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.120 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.119 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.118 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.117 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.116 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.115 spec/markdown/codes_spec.rb