Sha256: fc1b4835cacde1462a722f11bea89f534fb933d9a2f5c2332bfd4cf7853dfb4a

Contents?: true

Size: 1.14 KB

Versions: 25

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'chef/sugar/core_extensions'

describe String do
  describe '#satisfies?' do
    it 'includes the method' do
      expect(described_class).to be_method_defined(:satisfies?)
    end
  end

  describe '#satisfied_by?' do
    it 'includes the method' do
      expect(described_class).to be_method_defined(:satisfied_by?)
    end
  end

  describe '#flush' do
    context 'when given a single-line string' do
      it 'strips trailing whitespace' do
        string = <<-EOH
          This is a string
        EOH
        expect(string.flush).to eq('This is a string')
      end
    end

    context 'when given a multi-line string' do
      it 'removes the leading number of whitespaces' do
        string = <<-EOH
          def method
            "This is a string!"
          end
        EOH
        expect(string.flush).to eq(%Q(def method\n  "This is a string!"\nend))
      end

      it 'leaves a newline when given' do
        string = <<-EOH
          def method
            "This is a string!"
          end

        EOH
        expect(string.flush).to eq(%Q(def method\n  "This is a string!"\nend\n))
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
chef-sugar-ng-4.2.2 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-4.2.1 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-4.2.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-4.1.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-4.0.1 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-4.0.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.6.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.5.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.4.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.3.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.2.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.1.1 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.1.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.0.1 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-3.0.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-2.5.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-2.4.1 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-2.4.0 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-2.3.2 spec/unit/chef/sugar/core_extensions/string_spec.rb
chef-sugar-2.3.1 spec/unit/chef/sugar/core_extensions/string_spec.rb