Sha256: e929ccf7f999f09b2448bb9d80768c0646530de40b924ba381f1fcc47cf02152

Contents?: true

Size: 1.11 KB

Versions: 16

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

class Resource < ActiveRecord::Base
  has_validated_attributes :username_attr => {:format => :username, :allow_blank => false}
end

describe "HasValidatedAttributes" do
  before(:each) do
    @resource = Resource.create(:username_attr => "testusername", :name_attr => "testname", :email_attr => "test@example.com", 
      :phone_number_attr => "1111111111", :phone_extension_attr => "111111", :domain_attr => "www.test.com", :zipcode_attr => "11111",
      :middle_initial_attr => "A", :dollar_attr => "-11", :positive_dollar_attr => "1", :percent_attr => "12",
      :positive_percent_attr => "99", :url_attr => "http://www.google.com", :ssn_attr => "111111111", :taxid_attr => "111111111",
      :number_attr => "1")
  end

  describe "#username" do    
    it "should return error" do
      [">*,.<><", "<<< test", "Kansas City", "-- Hey --", "& youuuu", "21 Jump", ""].each do |value|
        @resource.username_attr = value 
        @resource.valid?.should be_false
        @resource.errors.full_messages.should == ["Username attr use only letters, numbers, and .-_@ please."]
      end
    end
  end


end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
has_validated_attributes-1.0.3 spec/test.rb
has_validated_attributes-1.0.2 spec/test.rb
has_validated_attributes-1.0.1 spec/test.rb
has_validated_attributes-1.0.0 spec/test.rb
has_validated_attributes-0.0.14 spec/test.rb
has_validated_attributes-0.0.13 spec/test.rb
has_validated_attributes-0.0.12 spec/test.rb
has_validated_attributes-0.0.11 spec/test.rb
has_validated_attributes-0.0.10 spec/test.rb
has_validated_attributes-0.0.9 spec/test.rb
has_validated_attributes-0.0.8 spec/test.rb
has_validated_attributes-0.0.6 spec/test.rb
has_validated_attributes-0.0.4 spec/test.rb
has_validated_attributes-0.0.3 spec/test.rb
has_validated_attributes-0.0.2 spec/test.rb
has_validated_attributes-0.0.1 spec/test.rb