File: strip_margin_spec.rb

package info (click to toggle)
ruby-powerpack 0.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 492 kB
  • sloc: ruby: 819; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 639 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'spec_helper'

unless String.method_defined? :strip_margin
  describe 'String#strip_margin' do
    it 'strips margin on every line of string' do
      code = <<-END
        |def test
        |  some_method
        |  other_method
        |end
      END

      expect(code.strip_margin('|'))
        .to eq("def test\n  some_method\n  other_method\nend\n")
    end

    it 'strips special characters margin from every line' do
      code = <<-END
        {{1}}def test
        {{1}}  some_method
        {{1}}end
      END

      expect(code.strip_margin('{{1}}'))
        .to eq("def test\n  some_method\nend\n")
    end
  end
end