test/model.rb in ohm-1.0.0.rc1 vs test/model.rb in ohm-1.0.0.rc2
- old
+ new
@@ -59,11 +59,11 @@
test "customized ID" do
inv = Invoice.create
assert_equal "_custom_id", inv.id
- i = Invoice.create(id: "_diff_id")
+ i = Invoice.create(:id => "_diff_id")
assert_equal "_diff_id", i.id
assert_equal i, Invoice["_diff_id"]
end
test "empty model is ok" do
@@ -72,11 +72,11 @@
foo = Foo.create
end
test "counters are cleaned up during deletion" do
- e = Event.create(name: "Foo")
+ e = Event.create(:name => "Foo")
e.incr :votes, 10
assert_equal 10, e.votes
e.delete
@@ -91,19 +91,19 @@
event = Meetup.create(:name => "Ruby Tuesday")
assert !event.update(:name => nil)
end
test "get" do
- m = Meetup.create(name: "Foo")
+ m = Meetup.create(:name => "Foo")
m.name = "Bar"
assert_equal "Foo", m.get(:name)
assert_equal "Foo", m.name
end
test "set" do
- m = Meetup.create(name: "Foo")
+ m = Meetup.create(:name => "Foo")
m.set :name, "Bar"
assert_equal "Bar", m.name
m = Meetup[m.id]
@@ -409,11 +409,11 @@
post = Post.create :body => "Hello world!"
post.related.key.rpush(Post.create(:body => "C").id)
post.related.key.rpush(Post.create(:body => "B").id)
post.related.key.rpush(Post.create(:body => "A").id)
- res = post.related.sort_by(:body, order: "ALPHA ASC").map { |r| r.body }
+ res = post.related.sort_by(:body, :order => "ALPHA ASC").map { |r| r.body }
assert_equal ["A", "B", "C"], res
end
# Loading attributes
setup do
@@ -437,23 +437,23 @@
tags.split(/\s+/)
end
end
setup do
- Entry.create(tags: "foo bar baz")
+ Entry.create(:tags => "foo bar baz")
end
test "finding by one entry in the enumerable" do |entry|
- assert Entry.find(tag: "foo").include?(entry)
- assert Entry.find(tag: "bar").include?(entry)
- assert Entry.find(tag: "baz").include?(entry)
+ assert Entry.find(:tag => "foo").include?(entry)
+ assert Entry.find(:tag => "bar").include?(entry)
+ assert Entry.find(:tag => "baz").include?(entry)
end
test "finding by multiple entries in the enumerable" do |entry|
- assert Entry.find(tag: ["foo", "bar"]).include?(entry)
- assert Entry.find(tag: ["bar", "baz"]).include?(entry)
- assert Entry.find(tag: ["baz", "oof"]).empty?
+ assert Entry.find(:tag => ["foo", "bar"]).include?(entry)
+ assert Entry.find(:tag => ["bar", "baz"]).include?(entry)
+ assert Entry.find(:tag => ["baz", "oof"]).empty?
end
# Attributes of type Set
setup do
@person1 = Person.create(:name => "Albert")
@@ -560,16 +560,16 @@
people = @event.attendees.sort_by(:name, :order => "ALPHA")
assert %w[A B C D] == people.map { |person| person.name }
end
test "accept a number in the limit parameter" do
- people = @event.attendees.sort_by(:name, limit: [0, 2], order: "ALPHA")
+ people = @event.attendees.sort_by(:name, :limit => [0, 2], :order => "ALPHA")
assert %w[A B] == people.map { |person| person.name }
end
test "use the start parameter as an offset if the limit is provided" do
- people = @event.attendees.sort_by(:name, limit: [1, 2], order: "ALPHA")
+ people = @event.attendees.sort_by(:name, :limit => [1, 2], :order => "ALPHA")
assert %w[B C] == people.map { |person| person.name }
end
# Collections initialized with a Model parameter
setup do
@@ -740,11 +740,11 @@
class Option < Ohm::Model
attribute :votes, lambda { |x| x.to_i }
end
option = Option.create :votes => 20
- option.update(votes: option.votes + 1)
+ option.update(:votes => option.votes + 1)
assert_equal 21, option.votes
end
test "poster-example for overriding writers" do
@@ -756,10 +756,10 @@
attributes[:email] = e.to_s.downcase.strip
end
end
end
- a = Advertiser.new(email: " FOO@BAR.COM ")
+ a = Advertiser.new(:email => " FOO@BAR.COM ")
assert_equal "foo@bar.com", a.email
end
__END__