test/base/test_item.rb in nanoc-3.5.0 vs test/base/test_item.rb in nanoc-3.6.0
- old
+ new
@@ -18,18 +18,13 @@
end
def test_frozen_identifier
item = Nanoc::Item.new("foo", {}, '/foo')
- raised = false
- begin
+ assert_raises_frozen_error do
item.identifier.chop!
- rescue => error
- raised = true
- assert_match(/(^can't modify frozen [Ss]tring|^unable to modify frozen object$)/, error.message)
end
- assert raised, 'Should have raised when trying to modify a frozen string'
end
def test_lookup
# Create item
item = Nanoc::Item.new(
@@ -142,26 +137,16 @@
def test_freeze_should_disallow_changes
item = Nanoc::Item.new("foo", { :a => { :b => 123 }}, '/foo/')
item.freeze
- raised = false
- begin
+ assert_raises_frozen_error do
item[:abc] = '123'
- rescue => e
- raised = true
- assert_match(/(^can't modify frozen |^unable to modify frozen object$)/, e.message)
end
- assert raised
- raised = false
- begin
+ assert_raises_frozen_error do
item[:a][:b] = '456'
- rescue => e
- raised = true
- assert_match(/(^can't modify frozen |^unable to modify frozen object$)/, e.message)
end
- assert raised
end
def test_dump_and_load
item = Nanoc::Item.new(
"foobar",