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.150 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.149 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.148 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.147 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.146 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.145 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.144 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.143 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.142 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.141 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.140 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.139 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.138 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.137 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.136 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.135 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.134 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.133 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.132 spec/markdown/codes_spec.rb
tbpgr_utils-0.0.131 spec/markdown/codes_spec.rb