Sha256: 2b4a9145f5bb64d0470142107c666e8ce1f1d89a55b72f1805ba9be62194e33e

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe ActiveCleaner::StringCleaner do

  let(:cleaner) { ActiveCleaner::StringCleaner.new(:title) }

  describe "#clean_value" do

    it "doesn't touch legit value" do
      expect(cleaner.clean_value("A good title!")).to eq("A good title!")
    end

    it "empties string full of spaces" do
      [
        "",
        " ",
        "\t",
        "\n",
        " \t\n \t\n \t\n \t\n",
      ].each do |title|
        expect(cleaner.clean_value(title)).to eq("")
      end
    end

    it "cleans leading and trailing spaces" do
      expect(cleaner.clean_value("  A good title!  ")).to eq("A good title!")
    end
    it "cleans leading and trailing tabs" do
      expect(cleaner.clean_value("\tA good title!\t")).to eq("A good title!")
    end
    it "cleans leading and trailing lines" do
      expect(cleaner.clean_value("\nA good title!\n")).to eq("A good title!")
    end

    it "cleans repeted spaces" do
      expect(cleaner.clean_value("A    good    title!")).to eq("A good title!")
      expect(cleaner.clean_value("A  \n good  \t title!")).to eq("A good title!")
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activecleaner-0.3.0 spec/lib/active_cleaner/string_cleaner_spec.rb
activecleaner-0.2.0 spec/lib/active_cleaner/string_cleaner_spec.rb