Sha256: b8f4e61db5e776ef0d9085dc63d0fc8c02072ffc9e590ff324f46ca69bd0624c

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))

class Post < Ohm::Model
  include Ohm::Typecast

  attribute :content
end

test "handles nil case correctly" do
  post = Post.create(:content => nil)
  post = Post[post.id]

  assert nil == post.content
end

test "still responds to string methods properly" do
  post = Post.create(:content => "FooBar")
  post = Post[post.id]

  assert "foobar" == post.content.downcase
end

test "mutating methods like upcase!" do
  post = Post.create(:content => "FooBar")
  post = Post[post.id]

  post.content.upcase!

  assert "FOOBAR" == post.content.to_s
end

test "inspecting" do
  post = Post.new(:content => "FooBar")
  assert 'FooBar' == post.content
end

test "type is String" do
  post = Post.new(:content => "FooBar")
  assert String == post.content.type
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ohm-contrib-0.0.36 test/typecast_string_test.rb
ohm-contrib-0.0.35 test/typecast_string_test.rb