Sha256: 334bbab6c23fef9156dbffe825b2961059000b1e5f1d8988491bbc9877f0ac08

Contents?: true

Size: 913 Bytes

Versions: 3

Compression:

Stored size: 913 Bytes

Contents

# encoding: UTF-8
require "spec_helper"
require "active_record"
require "charwidth/active_record"

describe Charwidth::ActiveRecord do
  before(:all) do
    ActiveRecord::Base.establish_connection(
      adapter: "sqlite3",
      database: ":memory:"
    )
    ActiveRecord::Base.connection.execute <<-SQL
      CREATE TABLE users (
        id integer PRIMARY KEY AUTOINCREMENT,
        name text NOT NULL
      )
    SQL

    class User < ActiveRecord::Base; end
  end

  subject { User.new }
  context 'assign unnormalized valud' do
    before(:each) do
      subject.name = "ABCアイウ"
    end
    its(:name) { should == "ABCアイウ" }
  end
  context 'assign nil' do
    before(:each) do
      subject.name = nil
    end
    its(:name) { should == nil }
  end
  context 'mass assignment' do
    subject { User.new(name: "ABCアイウ") }
    its(:name) { should == "ABCアイウ" }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
charwidth-0.1.5 spec/charwidth/active_record_spec.rb
charwidth-0.1.4 spec/charwidth/active_record_spec.rb
charwidth-0.1.3 spec/charwidth/active_record_spec.rb