File: strip_margin_spec.rb

package info (click to toggle)
ruby-powerpack 0.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 53
  • sloc: ruby: 727; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (3)
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
require 'spec_helper'

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