Sha256: 022b0f2ca6dc39d353f3dcda77a329feeab9f2c319dae09280fbb43a0a261576

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "ActiverecordPostgresHstore" do

  it "should convert hash to hstore string" do
    ["('a'=>'1') || ('b'=>'2')", "('b'=>'2') || ('a'=>'1')"].should include({:a => 1, :b => 2}.to_hstore)
  end

  it "should convert hstore string to hash" do
    '"a"=>"1", "b"=>"2"'.from_hstore.should eq({'a' => '1', 'b' => '2'})
  end
 
  it "should quote correctly" do
    {:a => "'a'"}.to_hstore.should eq("('a'=>'''a''')")
  end

  it "should quote keys correctly" do
    {"'a'" => "a"}.to_hstore.should  eq("('''a'''=>'a')")
  end

  it "should unquote keys correctly" do
    "\"'a'\"=>\"a\"".from_hstore.should eq({"'a'" => "a"})
  end

  it "should convert empty hash" do
    {}.to_hstore.should eq("''")
  end

  it "should convert empty string" do
    ''.from_hstore.should eq({})
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-postgres-hstore-0.1.2 spec/activerecord-postgres-hstore_spec.rb