Sha256: 3b56efc705a6553f684c58b78bc59d426cd0a5dea8c10f790956e151f90c572c

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe MassiveRecord::Wrapper::Row do
  let(:connection) do
    MassiveRecord::Wrapper::Connection.new(:host => MR_CONFIG['host'], :port => MR_CONFIG['port']).tap do |connection|
      connection.open
    end
  end

  let(:table) do
    MassiveRecord::Wrapper::Table.new(connection, MR_CONFIG['table']).tap do |table|
      table.column_families.create(:misc)
      table.save
    end
  end

  let(:id) { 'thorbjørn' }
  let(:name) { 'Thorbjorn' }

  subject do
    MassiveRecord::Wrapper::Row.new.tap do |row|
      row.id = id
      row.values = {:misc => {:name => name}}
      row.table = table
    end
  end



  after do
    table.all.each &:destroy
  end

  after :all do
    table.destroy
    connection.close
  end

  



  describe "ids utf-8 encoded" do
    context "new record" do
      it "saves" do
        subject.save.should be_true
      end
    end

    context "persisted record" do
      before { subject.save }

      it "finds" do
        table.find(id).values["misc:name"].should eq name
      end

      it "gets a cell" do
        table.get(id, :misc, :name).should eq name
      end

      it "finds with starts_with option" do
        table.all(:starts_with => id).first.values["misc:name"].should eq name
      end

      it "finds with offset option" do
        table.all(:offset => id).first.values["misc:name"].should eq name
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
massive_record-0.2.2 spec/adapter/thrift/utf8_encoding_of_id_spec.rb
massive_record-0.2.2.rc2 spec/adapter/thrift/utf8_encoding_of_id_spec.rb
massive_record-0.2.2.rc1 spec/adapter/thrift/utf8_encoding_of_id_spec.rb