Sha256: 23a779505a0e255cd01dbae63033f7cbe133d1c5436607290f5e7c3158297851

Contents?: true

Size: 1.03 KB

Versions: 83

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe "#pretty_format" do
  include ActiveAdmin::ViewHelpers::DisplayHelper

  context "when a String is passed in" do
    it "should return the String passed in" do
      pretty_format("hello").should == "hello"
    end
  end

  context "when a Date or a Time is passed in" do
    it "should return a localized Date or Time with long format" do
      t = Time.now
      self.should_receive(:localize).with(t, {:format => :long}) { "Just Now!" }
      pretty_format(t).should == "Just Now!"
    end
  end

  context "when an ActiveRecord object is passed in" do
    it "should delegate to auto_link" do
      post = Post.new
      self.should_receive(:auto_link).with(post) { "model name" }
      pretty_format(post).should == "model name"
    end
  end

  context "when something else is passed in" do
    it "should delegate to display_name" do
      something = Class.new.new
      self.should_receive(:display_name).with(something) { "I'm not famous" }
      pretty_format(something).should == "I'm not famous"
    end
  end
end

Version data entries

83 entries across 83 versions & 7 rubygems

Version Path
lalala-4.0.0.dev.128 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.94 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.92 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.90 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.84 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.80 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.79 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.78 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb
lalala-4.0.0.dev.77 vendor/deps/active_admin/spec/unit/pretty_format_spec.rb