Sha256: b5c050cb0ba242f6cb5f9e920b934cfe643f6c1e4881e90e2ff592addf8e2f78
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require 'validates_formatting_of/validation' module ValidatesFormattingOf describe Validation do context "valid validation creation" do let(:validation) { Validation.new(:name, /something/i, "is an invalid value") } subject { validation } its(:name) { should == :name } its(:regex) { should == %r{something}i } its(:message) { should == 'is an invalid value' } its(:to_s) { should == "<Validation::name>" } its(:inspect) { should =~ /Validation/ } its(:inspect) { should =~ /\/something\/i/ } its(:inspect) { should =~ /\:name/ } end context "invalid validation creation" do it "should raise an error if the specified regex is not a Regexp objct" do expect { Validation.new(:name, 123, "is an invalid value") }.to raise_error InvalidRegularExpression end it "should not raise an error if the specified regex is a proc or a lambda" do expect { Validation.new(:name, lambda { "my record" }, "is an invalid value") }.not_to raise_error InvalidRegularExpression expect { Validation.new(:name, proc { "my record" }, "is an invalid value") }.not_to raise_error InvalidRegularExpression end it "should not raise an error if the regex if valid" do expect { Validation.new(:name, /something/i, "is an invalid value") }.not_to raise_error InvalidRegularExpression end end end end
Version data entries
3 entries across 3 versions & 1 rubygems