test/base/test_item.rb in nanoc-3.7.4 vs test/base/test_item.rb in nanoc-3.7.5

- old
+ new

@@ -1,9 +1,8 @@ # encoding: utf-8 class Nanoc::ItemTest < Nanoc::TestCase - def test_initialize_with_attributes_with_string_keys item = Nanoc::Item.new('foo', { 'abc' => 'xyz' }, '/foo/') assert_equal nil, item.attributes['abc'] assert_equal 'xyz', item.attributes[:abc] @@ -25,11 +24,11 @@ def test_lookup # Create item item = Nanoc::Item.new( 'content', - { :one => 'one in item' }, + { one: 'one in item' }, '/path/' ) # Test finding one assert_equal('one in item', item[:one]) @@ -47,11 +46,13 @@ end def test_compiled_content_with_default_rep_and_default_snapshot # Mock rep rep = Object.new - def rep.name; :default; end + def rep.name + :default + end def rep.compiled_content(params) "content at #{params[:snapshot].inspect}" end # Mock item @@ -63,47 +64,51 @@ end def test_compiled_content_with_custom_rep_and_default_snapshot # Mock reps rep = Object.new - def rep.name; :foo; end + def rep.name + :foo + end def rep.compiled_content(params) "content at #{params[:snapshot].inspect}" end # Mock item item = Nanoc::Item.new('foo', {}, '/foo') item.expects(:reps).returns([rep]) # Check - assert_equal 'content at nil', item.compiled_content(:rep => :foo) + assert_equal 'content at nil', item.compiled_content(rep: :foo) end def test_compiled_content_with_default_rep_and_custom_snapshot # Mock reps rep = Object.new - def rep.name; :default; end + def rep.name + :default + end def rep.compiled_content(params) "content at #{params[:snapshot].inspect}" end # Mock item item = Nanoc::Item.new('foo', {}, '/foo') item.expects(:reps).returns([rep]) # Check - assert_equal 'content at :blah', item.compiled_content(:snapshot => :blah) + assert_equal 'content at :blah', item.compiled_content(snapshot: :blah) end def test_compiled_content_with_custom_nonexistant_rep # Mock item item = Nanoc::Item.new('foo', {}, '/foo') item.expects(:reps).returns([]) # Check assert_raises(Nanoc::Errors::Generic) do - item.compiled_content(:rep => :lkasdhflahgwfe) + item.compiled_content(rep: :lkasdhflahgwfe) end end def test_path_with_default_rep # Mock reps @@ -128,15 +133,15 @@ # Mock item item = Nanoc::Item.new('foo', {}, '/foo') item.expects(:reps).returns([rep]) # Check - assert_equal 'the correct path', item.path(:rep => :moo) + assert_equal 'the correct path', item.path(rep: :moo) end def test_freeze_should_disallow_changes - item = Nanoc::Item.new('foo', { :a => { :b => 123 }}, '/foo/') + item = Nanoc::Item.new('foo', { a: { b: 123 } }, '/foo/') item.freeze assert_raises_frozen_error do item[:abc] = '123' end @@ -147,16 +152,15 @@ end def test_dump_and_load item = Nanoc::Item.new( 'foobar', - { :a => { :b => 123 }}, + { a: { b: 123 } }, '/foo/') item = Marshal.load(Marshal.dump(item)) assert_equal '/foo/', item.identifier assert_equal 'foobar', item.raw_content - assert_equal({ :a => { :b => 123 }}, item.attributes) + assert_equal({ a: { b: 123 } }, item.attributes) end - end