Sha256: 25e8872de45a322715c860b9822c9abeabbf7d435ab584754faa5977ef7efc72

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

# encoding: UTF-8

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

class Event < Ohm::Model
  attribute :name
  attribute :location

  def setup
    txn = Transaction.new do |t|
      related = nil

      t.watch(key[:related]) unless new?

      t.read do
       related = db.smembers(key[:related])
      end

      t.write do
        related.each do |k|
          db.del(k)
        end

        db.del(key[:related])
      end
    end

    __delete__.append(txn)
  end
end

test "assign attributes from the hash" do
  event = Event.new(:name => "Ruby Tuesday")
  assert_equal event.name, "Ruby Tuesday"
end

test "assign an ID and save the object" do
  event1 = Event.create(:name => "Ruby Tuesday")
  event2 = Event.create(:name => "Ruby Meetup")

  assert_equal "1", event1.id
  assert_equal "2", event2.id
end

test "save the attributes in UTF8" do
 event = Event.create(:name => "32° Kisei-sen")
 assert "32° Kisei-sen" == Event[event.id].name
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ohm-1.3.0 test/setup.rb