normatron 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/README.textile +35 -48
  2. data/Rakefile +6 -7
  3. data/lib/generators/normatron/install_generator.rb +23 -0
  4. data/lib/generators/normatron/templates/normatron.rb +4 -0
  5. data/lib/normatron.rb +22 -8
  6. data/lib/normatron/configuration.rb +26 -22
  7. data/lib/normatron/extensions.rb +8 -0
  8. data/lib/normatron/extensions/active_record.rb +20 -15
  9. data/lib/normatron/filters.rb +26 -379
  10. data/lib/normatron/filters/blank_filter.rb +29 -0
  11. data/lib/normatron/filters/camelize_filter.rb +50 -0
  12. data/lib/normatron/filters/capitalize_filter.rb +29 -0
  13. data/lib/normatron/filters/chomp_filter.rb +34 -0
  14. data/lib/normatron/filters/dasherize_filter.rb +25 -0
  15. data/lib/normatron/filters/downcase_filter.rb +29 -0
  16. data/lib/normatron/filters/dump_filter.rb +27 -0
  17. data/lib/normatron/filters/helpers.rb +44 -0
  18. data/lib/normatron/filters/keep_filter.rb +100 -0
  19. data/lib/normatron/filters/remove_filter.rb +37 -0
  20. data/lib/normatron/filters/squeeze_filter.rb +30 -0
  21. data/lib/normatron/filters/squish_filter.rb +28 -0
  22. data/lib/normatron/filters/strip_filter.rb +33 -0
  23. data/lib/normatron/filters/swapcase_filter.rb +30 -0
  24. data/lib/normatron/filters/titleize_filter.rb +29 -0
  25. data/lib/normatron/filters/underscore_filter.rb +45 -0
  26. data/lib/normatron/filters/upcase_filter.rb +29 -0
  27. data/lib/normatron/version.rb +3 -0
  28. data/spec/normatron/configuration_spec.rb +60 -0
  29. data/spec/normatron/extensions/active_record_spec.rb +96 -0
  30. data/spec/normatron/filters/blank_filter_spec.rb +15 -0
  31. data/spec/normatron/filters/camelize_filter_spec.rb +42 -0
  32. data/spec/normatron/filters/capitalize_filter_spec.rb +14 -0
  33. data/spec/normatron/filters/chomp_filter_spec.rb +15 -0
  34. data/spec/normatron/filters/dasherize_filter_spec.rb +9 -0
  35. data/spec/normatron/filters/downcase_filter_spec.rb +10 -0
  36. data/spec/normatron/filters/dump_filter_spec.rb +10 -0
  37. data/spec/normatron/filters/keep_filter_spec.rb +86 -0
  38. data/spec/normatron/filters/remove_filter_spec.rb +86 -0
  39. data/spec/normatron/filters/squeeze_filter_spec.rb +10 -0
  40. data/spec/normatron/filters/squish_filter_spec.rb +12 -0
  41. data/spec/normatron/filters/strip_filter_spec.rb +12 -0
  42. data/spec/normatron/filters/swapcase_filter_spec.rb +12 -0
  43. data/spec/normatron/filters/titleize_filter_spec.rb +12 -0
  44. data/spec/normatron/filters/underscore_filter_spec.rb +26 -0
  45. data/spec/normatron/filters/upcase_filter_spec.rb +10 -0
  46. data/spec/normatron_spec.rb +28 -2
  47. data/spec/spec_helper.rb +37 -4
  48. data/spec/support/my_filters.rb +7 -0
  49. data/spec/support/user_model.rb +14 -0
  50. metadata +64 -13
  51. data/spec/configuration_spec.rb +0 -53
  52. data/spec/extensions/active_record_spec.rb +0 -114
  53. data/spec/filters_spec.rb +0 -442
  54. data/spec/support/model_model.rb +0 -3
  55. data/spec/support/schema.rb +0 -7
@@ -0,0 +1,28 @@
1
+ require 'normatron/filters/helpers'
2
+
3
+ module Normatron
4
+ module Filters
5
+ module SquishFilter
6
+
7
+ ##
8
+ # Strip input, remove line-breaks and multiple spaces.
9
+ #
10
+ # @example
11
+ # SquishFilter.evaluate(" the simpsons ") #=> "the simpsons"
12
+ # SquishFilter.evaluate("family guy") #=> "family guy"
13
+ # SquishFilter.evaluate("the \n simpsons") #=> "the simpsons"
14
+ # SquishFilter.evaluate("the\nsimpsons") #=> "the simpsons"
15
+ #
16
+ # @example Using as ActiveRecord::Base normalizer
17
+ # normalize :attribute, :with => [:custom_filter, :squish]
18
+ #
19
+ # @param [String] input A character sequence
20
+ # @return [String] The clean character sequence or the object itself
21
+ # @see http://api.rubyonrails.org/classes/String.html#method-i-squish String#squish
22
+ # @see SqueezeFilter Normatron::Filters::SqueezeFilter
23
+ def self.evaluate(input)
24
+ input.kind_of?(String) ? input.squish : input
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ require 'normatron/filters/helpers'
2
+
3
+ module Normatron
4
+ module Filters
5
+ module StripFilter
6
+ extend Helpers
7
+
8
+ ##
9
+ # Remove traling and/or leading spaces from the string.
10
+ #
11
+ # @example
12
+ # StripFilter.evaluate(" copy ") #=> "copy"
13
+ # StripFilter.evaluate(" copy ", :L) #=> "copy "
14
+ # StripFilter.evaluate(" copy ", :R) #=> " copy"
15
+ # StripFilter.evaluate(" copy ", :LR) #=> "copy"
16
+ #
17
+ # @example Using as ActiveRecord::Base normalizer
18
+ # normalize :attribute_a, :with => :strip
19
+ # normalize :attribute_b, :with => { :strip => :L }
20
+ # normalize :attribute_c, :with => [:custom_filter, :strip]
21
+ # normalize :attribute_d, :with => [:custom_filter, [:strip, :L]]
22
+ # normalize :attribute_e, :with => [:custom_filter, {:strip => :R}]
23
+ #
24
+ # @param [String] input A character sequence
25
+ # @param [Symbol] option :L to strip trailing spaces, :R for leading spaces and :LR for both
26
+ # @return [String] The character sequence without trailing and leading spaces or the object itself
27
+ # @see http://www.ruby-doc.org/core-1.9.3/String.html#method-i-strip String#strip
28
+ def self.evaluate(input, option=:LR)
29
+ input.kind_of?(String) ? evaluate_strip(input, option) : input
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ require 'normatron/filters/helpers'
2
+
3
+ module Normatron
4
+ module Filters
5
+ module SwapcaseFilter
6
+ extend Helpers
7
+
8
+ ##
9
+ # Replaces uppercased characters by lowercased and vice versa.
10
+ #
11
+ # @example
12
+ # SwapcaseFilter.evaluate("As you Wish!") #=> "aS YOU wISH!"
13
+ #
14
+ # @example Using as ActiveRecord::Base normalizer
15
+ # normalize :attribute_a, :with => :swapcase
16
+ # normalize :attribute_b, :with => [:custom_filter, :swapcase]
17
+ #
18
+ # @param [String] input A character sequence
19
+ # @return [String] The swapped case character sequence or the object itself
20
+ # @see http://www.ruby-doc.org/core-1.9.3/String.html#method-i-swapcase String#swapcase
21
+ # @see DownFilter Normatron::Filters::DownFilter
22
+ # @see TitleizeFilter Normatron::Filters::TitleizeFilter
23
+ # @see UpcaseFilter Normatron::Filters::UpcaseFilter
24
+ def self.evaluate(input)
25
+ return input unless input.kind_of?(String)
26
+ input.gsub(/([\p{Ll}])|(\p{Lu})|([^\p{Ll}\p{Lu}])/u) { $3 || ($2 ? mb_send(:downcase, $2) : mb_send(:upcase, $1)) }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ require 'normatron/filters/helpers'
2
+
3
+ module Normatron
4
+ module Filters
5
+ module TitleizeFilter
6
+ extend Helpers
7
+
8
+ ##
9
+ # Capitalizes the first character of each word.
10
+ #
11
+ # @example
12
+ # TitleizeFilter.evaluate("at your will!") #=> "At Your Will!"
13
+ #
14
+ # @example Using as ActiveRecord::Base normalizer
15
+ # normalize :attribute_a, :with => :titleize
16
+ # normalize :attribute_b, :with => [:custom_filter, :titleize]
17
+ #
18
+ # @param [String] input A character sequence
19
+ # @return [String] The titleized character sequence or the object itself
20
+ # @see http://api.rubyonrails.org/classes/ActiveSupport/Multibyte/Chars.html#method-i-titleize ActiveSupport::Multibyte::Chars#titleize
21
+ # @see DownFilter Normatron::Filters::DownFilter
22
+ # @see SwapcaseFilter Normatron::Filters::SwapcaseFilter
23
+ # @see UpcaseFilter Normatron::Filters::UpcaseFilter
24
+ def self.evaluate(input)
25
+ input.kind_of?(String) ? mb_send(:titleize, input) : input
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,45 @@
1
+ require 'normatron/filters/helpers'
2
+
3
+ module Normatron
4
+ module Filters
5
+ module UnderscoreFilter
6
+ extend Helpers
7
+
8
+ ##
9
+ # Makes an underscored, lowercase form from the expression in the string.
10
+ #
11
+ # Changes ‘::’ to ‘/’ to convert namespaces to paths.
12
+ #
13
+ # As a rule of thumb you can think of underscore as the inverse of camelize, though there are cases where that does not hold:
14
+ # "SSLError".underscore.camelize # => "SslError"
15
+ #
16
+ # @example
17
+ # UnderscoreFilter.evaluate("ActiveRecord::Errors") #=> "active_record/errors"
18
+ #
19
+ # @example Using as ActiveRecord::Base normalizer
20
+ # normalize :attribute_a, :with => :underscore
21
+ # normalize :attribute_b, :with => [:custom_filter, :underscore]
22
+ # normalize :attribute_c, :with => [[:underscore, :lower]]
23
+ # normalize :attribute_d, :with => [{:underscore => :lower}]
24
+ # normalize :attribute_e, :with => [:custom_filter, [:underscore, :lower]]
25
+ # normalize :attribute_f, :with => [:custom_filter, {:underscore => :lower}]
26
+ #
27
+ # @param [String] input A character sequence
28
+ # @return [String] The underscored character sequence or the object itself
29
+ # @see http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore ActiveSupport::Inflector#underscore
30
+ # @see CamelizeFilter Normatron::Filters::CamelizeFilter
31
+ # @todo Performance tests
32
+ # @todo Exception class
33
+ def self.evaluate(input)
34
+ return input unless input.kind_of?(String)
35
+
36
+ input.gsub!(/::/, '/')
37
+ input.gsub!(/(?:([\p{Ll}\p{Lu}\d])|^)(#{acronym_regex})(?=\b|[^\p{Ll}])/u) { "#{$1}#{$1 && '_'}#{mb_send(:downcase, $2)}" }
38
+ input.gsub!(/([\p{Lu}\d]+)([\p{Lu}][\p{Ll}])/u,'\1_\2')
39
+ input.gsub!(/([\p{Ll}\d])([\p{Lu}])/u,'\1_\2')
40
+ input.tr!("-", "_")
41
+ mb_send(:downcase, input)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ require 'normatron/filters/helpers'
2
+
3
+ module Normatron
4
+ module Filters
5
+ module UpcaseFilter
6
+ extend Helpers
7
+
8
+ ##
9
+ # Uppercase all characters.
10
+ #
11
+ # @example
12
+ # upcase("borderlands") #=> "BORDERLANDS"
13
+ #
14
+ # @example Using as ActiveRecord::Base normalizer
15
+ # normalize :attribute_a, :with => :upcase
16
+ # normalize :attribute_b, :with => [:custom_filter, :upcase]
17
+ #
18
+ # @return [String, Chars] The uppercased character sequence or the object itself
19
+ # @see http://www.ruby-doc.org/core-1.9.3/String.html#method-i-upcase String#upcase
20
+ # @see http://api.rubyonrails.org/classes/ActiveSupport/Multibyte/Chars.html#method-i-upcase ActiveSupport::Multibyte::Chars#upcase
21
+ # @see DownFilter Normatron::Filters::DownFilter
22
+ # @see TitleizeFilter Normatron::Filters::TitleizeFilter
23
+ # @see SwapcaseFilter Normatron::Filters::SwapcaseFilter
24
+ def self.evaluate(input)
25
+ input.kind_of?(String) ? mb_send(:upcase, input) : input
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Normatron
2
+ VERSION = "0.3.0"
3
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'normatron/configuration'
3
+
4
+ describe Normatron::Configuration do
5
+
6
+ before :each do
7
+ @instance = described_class.new
8
+ end
9
+
10
+ subject { @instance }
11
+
12
+ describe :default_filters do
13
+ it "should be initialized" do
14
+ subject.default_filters.should == { blank: nil, squish: nil }
15
+ end
16
+
17
+ it "should parse and set filters properly" do
18
+ subject.default_filters = :upcase, :blank, { keep: [:L, :N] }, [:remove, :S, :Z]
19
+ subject.default_filters.should == { upcase: nil, blank: nil, keep: [:L, :N], remove: [:S, :Z] }
20
+ end
21
+ end
22
+
23
+ describe :filters do
24
+ it "should be initialized" do
25
+ subject.filters[:blank] .should eq Normatron::Filters::BlankFilter
26
+ subject.filters[:camelize] .should eq Normatron::Filters::CamelizeFilter
27
+ subject.filters[:capitalize].should eq Normatron::Filters::CapitalizeFilter
28
+ subject.filters[:chomp] .should eq Normatron::Filters::ChompFilter
29
+ subject.filters[:dasherize] .should eq Normatron::Filters::DasherizeFilter
30
+ subject.filters[:downcase] .should eq Normatron::Filters::DowncaseFilter
31
+ subject.filters[:dump] .should eq Normatron::Filters::DumpFilter
32
+ subject.filters[:keep] .should eq Normatron::Filters::KeepFilter
33
+ subject.filters[:remove] .should eq Normatron::Filters::RemoveFilter
34
+ subject.filters[:squeeze] .should eq Normatron::Filters::SqueezeFilter
35
+ subject.filters[:squish] .should eq Normatron::Filters::SquishFilter
36
+ subject.filters[:strip] .should eq Normatron::Filters::StripFilter
37
+ subject.filters[:swapcase] .should eq Normatron::Filters::SwapcaseFilter
38
+ subject.filters[:titleize] .should eq Normatron::Filters::TitleizeFilter
39
+ subject.filters[:underscore].should eq Normatron::Filters::UnderscoreFilter
40
+ subject.filters[:upcase] .should eq Normatron::Filters::UpcaseFilter
41
+ end
42
+
43
+ it "should allow add new filters" do
44
+ subject.filters[:smile] = MyFilters::SmileFilter
45
+ subject.filters[:smile].should eq MyFilters::SmileFilter
46
+ end
47
+
48
+ it "should allow remove filters" do
49
+ lambda { subject.filters.delete(subject.filters.keys.first) }.should_not raise_error
50
+ end
51
+ end
52
+
53
+ describe :add_orm do
54
+ it "should include ActiveRecord extension" do
55
+ ActiveRecord::Base.include?(Normatron::Extensions::ActiveRecord).should be_false
56
+ subject.add_orm Normatron::Extensions::ActiveRecord
57
+ ActiveRecord::Base.include?(Normatron::Extensions::ActiveRecord).should be_true
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,96 @@
1
+ require 'normatron'
2
+ require 'spec_helper'
3
+
4
+ describe Normatron::Extensions::ActiveRecord do
5
+
6
+ it { subject.constants.should include(:ORM_CLASS) }
7
+
8
+ let(:ext) { Normatron::Extensions }
9
+ let(:configuration) { Normatron.configuration }
10
+ let(:model) { User }
11
+
12
+ before(:all) { ActiveRecord::Base.send(:include, Normatron::Extensions::ActiveRecord) }
13
+ before(:each) { model.normalize_filters = nil }
14
+ after(:all) do
15
+ ActiveRecord.send(:remove_const, :Base)
16
+ load 'active_record/base.rb'
17
+ end
18
+
19
+
20
+ describe :normalize do
21
+ subject { model }
22
+
23
+ it "should raise UnknownAttributeError" do
24
+ lambda { subject.normalize :unknown }.should raise_error(ext::UnknownAttributeError)
25
+ lambda { subject.normalize nil }.should raise_error(ext::UnknownAttributeError)
26
+ lambda { subject.normalize :phone, :unknown }.should raise_error(ext::UnknownAttributeError)
27
+ end
28
+
29
+ it "should append default filters" do
30
+ subject.normalize :login, :email
31
+ subject.normalize_filters.should == { :login => configuration.default_filters,
32
+ :email => configuration.default_filters }
33
+ end
34
+
35
+ it "should stack filters for multiple calls" do
36
+ subject.normalize :login
37
+ subject.normalize :login, :with => :upcase
38
+ subject.normalize_filters.should == { :login => configuration.default_filters.merge({ :upcase => nil }) }
39
+ end
40
+
41
+ it "should append multiple attributes" do
42
+ subject.normalize :login, :email, :phone
43
+ subject.normalize_filters.should == { login: { squish: nil, blank: nil },
44
+ email: { squish: nil, blank: nil },
45
+ phone: { squish: nil, blank: nil } }
46
+ end
47
+
48
+ it "should allow multiple filters" do
49
+ subject.normalize :login, :with => [:upcase, :blank]
50
+ subject.normalize_filters.should == { login: { upcase: nil, blank: nil } }
51
+ end
52
+
53
+ it "should allow multiple filters" do
54
+ subject.normalize :login, :with => [[:keep, :L], { :remove => [:N] }]
55
+ subject.normalize_filters.should == { login: { keep: [:L], remove: [:N] } }
56
+ end
57
+ end
58
+
59
+ describe :apply_normalizations do
60
+ before(:each) { @instance = model.new }
61
+ subject { @instance }
62
+
63
+ it "should run instance method filter" do
64
+ model.class_eval do
65
+ define_method :sad_face do |value|
66
+ value + " =("
67
+ end
68
+ end
69
+
70
+ model.normalize :login, :with => :sad_face
71
+ subject.login = "..."
72
+ subject.apply_normalizations
73
+ subject.login.should eq "... =("
74
+ end
75
+
76
+ it "should run native filter" do
77
+ model.normalize :login, :with => :squish
78
+ subject.login = " word "
79
+ subject.apply_normalizations
80
+ subject.login.should eq "word"
81
+ end
82
+
83
+ it "should be called before validation" do
84
+ model.normalize :login, :with => :blank
85
+ subject.login = " "
86
+ subject.valid?
87
+ subject.login.should == nil
88
+ end
89
+
90
+ it "should raise UnknownFilterError" do
91
+ model.normalize :login, :with => :unknown
92
+ subject.login = " "
93
+ lambda { subject.apply_normalizations }.should raise_error(ext::UnknownFilterError)
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'normatron/filters/blank_filter'
3
+
4
+ describe Normatron::Filters::BlankFilter do
5
+ it_should_behave_like "string processor"
6
+ it_should_behave_like "evaluable filter", ["18pm"], "18pm"
7
+
8
+ describe :blank do
9
+ let(:word) { "phase" }
10
+ it { subject.send(:evaluate, " ").should be_nil }
11
+ it { subject.send(:evaluate, "\n \t \r \f").should be_nil }
12
+ it { subject.send(:evaluate, "\n\t\r\f" ).should be_nil }
13
+ it { subject.send(:evaluate, word ).should equal word }
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'normatron/filters/camelize_filter'
5
+
6
+ describe Normatron::Filters::CamelizeFilter do
7
+ it_should_behave_like "string processor"
8
+ it_should_behave_like "evaluable filter", ["active_record/errors" ], "ActiveRecord::Errors"
9
+ it_should_behave_like "evaluable filter", ["active_record/errors", :upper ], "ActiveRecord::Errors"
10
+ it_should_behave_like "evaluable filter", ["active_record/errors", :lower ], "activeRecord::Errors"
11
+ it_should_behave_like "evaluable filter", ["dados_históricos/período/empresa" ], "DadosHistóricos::Período::Empresa"
12
+ it_should_behave_like "evaluable filter", ["dados_históricos/período/empresa", :upper], "DadosHistóricos::Período::Empresa"
13
+ it_should_behave_like "evaluable filter", ["dados_históricos/período/empresa", :lower], "dadosHistóricos::Período::Empresa"
14
+ it_should_behave_like "evaluable filter", ["ímpar_par/norte_sul" ], "ÍmparPar::NorteSul"
15
+ it_should_behave_like "evaluable filter", ["ímpar_par/norte_sul", :upper ], "ÍmparPar::NorteSul"
16
+ it_should_behave_like "evaluable filter", ["ímpar_par/norte_sul", :lower ], "ímparPar::NorteSul"
17
+
18
+ context "should affect acronyms" do
19
+ let(:inflections) { ActiveSupport::Inflector::Inflections.instance }
20
+
21
+ before(:all) do
22
+ inflections.acronym 'HTTP'
23
+ inflections.acronym 'SSL'
24
+ inflections.acronym 'Xml'
25
+ inflections.acronym 'docType'
26
+ end
27
+
28
+ after(:all) do
29
+ inflections.acronyms.delete("http")
30
+ inflections.acronyms.delete("ssl")
31
+ inflections.acronyms.delete("xml")
32
+ inflections.acronyms.delete("doctype")
33
+ end
34
+
35
+ it_should_behave_like "evaluable filter", ["http_address/ssl/xml_file/doctype" ], "HTTPAddress::SSL::XmlFile::docType"
36
+ it_should_behave_like "evaluable filter", ["http_address/ssl/xml_file/doctype", :upper], "HTTPAddress::SSL::XmlFile::docType"
37
+ it_should_behave_like "evaluable filter", ["http_address/ssl/xml_file/doctype", :lower], "httpAddress::SSL::XmlFile::docType"
38
+ it_should_behave_like "evaluable filter", ["doctype_stop/run_ssl/xml/mix_http" ], "docTypeStop::RunSSL::Xml::MixHTTP"
39
+ it_should_behave_like "evaluable filter", ["doctype_stop/run_ssl/xml/mix_http", :upper], "docTypeStop::RunSSL::Xml::MixHTTP"
40
+ it_should_behave_like "evaluable filter", ["doctype_stop/run_ssl/xml/mix_http", :lower], "doctypeStop::RunSSL::Xml::MixHTTP"
41
+ end
42
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'normatron/filters/capitalize_filter'
5
+
6
+ describe Normatron::Filters::CapitalizeFilter do
7
+ it_should_behave_like "string processor"
8
+ it_should_behave_like "evaluable filter", ["i love winter" ], "I love winter"
9
+ it_should_behave_like "evaluable filter", ["I LOVE WINTER" ], "I love winter"
10
+ it_should_behave_like "evaluable filter", ["ó, vida cruel!"], "Ó, vida cruel!"
11
+ it_should_behave_like "evaluable filter", ["Ó, VIDA CRUEL!"], "Ó, vida cruel!"
12
+ it_should_behave_like "evaluable filter", ["1 minute" ], "1 minute"
13
+ it_should_behave_like "evaluable filter", ["1 MINUTE" ], "1 minute"
14
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'normatron/filters/chomp_filter'
5
+
6
+ describe Normatron::Filters::ChompFilter do
7
+ it_should_behave_like "string processor"
8
+ it_should_behave_like "evaluable filter", ["show me the money" ], "show me the money"
9
+ it_should_behave_like "evaluable filter", ["show me the money\n" ], "show me the money"
10
+ it_should_behave_like "evaluable filter", ["show me the money\r" ], "show me the money"
11
+ it_should_behave_like "evaluable filter", ["show me the money\r\n" ], "show me the money"
12
+ it_should_behave_like "evaluable filter", ["show me the money\n\r" ], "show me the money\n"
13
+ it_should_behave_like "evaluable filter", ["show me the money", " money" ], "show me the"
14
+ it_should_behave_like "evaluable filter", ["show me the money", " money".mb_chars], "show me the"
15
+ end