Sha256: e5e8bd9cb8eaefd91fb6e19c6e449b6372989cb1252a0f1d73bbdaa1258c15f4
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
require File.expand_path('../../helper', __FILE__) class HydeTest < TestCase def assert_fixture_works(path) build_fixture(path) { |control, var| assert File.exists?(var) if read(control) != read(var) flunk "Failed in #{var}\n" + "Control:\n" + read(control).gsub(/^/, '| ') + "\n\n" + "Variable:\n" + read(var).gsub(/^/, '| ') end } end def assert_fixture_fails(path, error=Hyde::Error, &blk) begin build_fixture(path) rescue error => e yield e else flunk "Assertion failed" end end def build_fixture(path, &blk) # Build project = build path Dir[project.root('control/**/*')].each do |control| next unless File.file?(control) var = control.sub('/control/', '/public/') yield control, var end if block_given? end def read(file) File.open(file) { |f| f.read } end teardown do # Remove the generated Dir[fixture('*', 'public')].each { |dir| FileUtils.rm_rf dir } end test "fixture one" do assert_fixture_works fixture('one') end test "fixture subclass" do assert_fixture_works fixture('subclass') end test "fixture extensions" do assert_fixture_works fixture('extensions') end test "fixture parent" do assert_fixture_works fixture('parent') end test "fixture sort" do assert_fixture_works fixture('sort') end test "fixture metadata" do assert_fixture_works fixture('metadata') end test "fixture nested_layout" do assert_fixture_works fixture('nested_layout') end test "fixture fail_type" do assert_fixture_fails(fixture('fail_type')) { |e| assert e.message.include?('nonexistent') } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hydeweb-0.1.7 | test/unit/fixture_test.rb |
hydeweb-0.1.6 | test/unit/fixture_test.rb |