Sha256: e41fe794444f84ea40bd16a1f8beea9de8703e78cbdabe7c08b65581c63af51b

Contents?: true

Size: 644 Bytes

Versions: 4

Compression:

Stored size: 644 Bytes

Contents

require 'spec_helper'

class User < SuperModel::Base
  include ActiveModel::Validations::Callbacks
  extend FormatUrl::ModelAdditions
  format_url :website
end

describe FormatUrl::ModelAdditions do
  it "adds http:// to URL upon saving" do
    User.create!(website: "example.com").website.should eq("http://example.com")
    User.create!(website: "http://example.com").website.should eq("http://example.com")
  end

  it "validates URL format" do
    user = User.new(website: "foo bar")
    user.should_not be_valid
    user.errors[:website].should eq(["is not a valid URL"])
    user.website = "example.com"
    user.should be_valid
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
format_url-0.0.4 spec/format_url/model_additions_spec.rb
format_url-0.0.3 spec/format_url/model_additions_spec.rb
format_url-0.0.2 spec/format_url/model_additions_spec.rb
format_url-0.0.1 spec/format_url/model_additions_spec.rb