test/base/test_data_source.rb in nanoc-3.8.0 vs test/base/test_data_source.rb in nanoc-4.0.0a1
- old
+ new
@@ -24,19 +24,29 @@
data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
# Test optional methods
data_source.up
data_source.down
- data_source.update
- # Test required methods - general
- assert_raises(NotImplementedError) { data_source.setup }
-
# Test methods - loading data
assert_equal [], data_source.items
assert_equal [], data_source.layouts
+ end
- # Test required method - creating data
- assert_raises(NotImplementedError) { data_source.create_item(nil, nil, nil) }
- assert_raises(NotImplementedError) { data_source.create_layout(nil, nil, nil) }
+ def test_new_item
+ data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
+
+ item = data_source.new_item('stuff', { title: 'Stuff!' }, '/asdf/')
+ assert_equal 'stuff', item.raw_content
+ assert_equal 'Stuff!', item.attributes[:title]
+ assert_equal Nanoc::Identifier.new('/asdf/'), item.identifier
+ end
+
+ def test_new_layout
+ data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
+
+ layout = data_source.new_layout('stuff', { title: 'Stuff!' }, '/asdf/')
+ assert_equal 'stuff', layout.raw_content
+ assert_equal 'Stuff!', layout.attributes[:title]
+ assert_equal Nanoc::Identifier.new('/asdf/'), layout.identifier
end
end