|
Lift Framework example source code file (ToHeadSpec.scala)
The Lift Framework ToHeadSpec.scala source code/* * Copyright 2007-2011 WorldWide Conferencing, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.liftweb package util import xml.XML._ import org.specs.Specification import common._ import ControlHelpers._ import HeadHelper._ /** * Systems under specification for ToHead. */ object ToHeadSpec extends Specification("ToHead Specification") { "lift <head> merger" should { "merge /html/body//head into existing /html/head section" in { val susfiles = for { act <- tryo(getClass.getResource("ToHeadSpec.actual1.html")).filter(_ ne null) exp <- tryo(getClass.getResource("ToHeadSpec.expected1.html")).filter(_ ne null) } yield (act, exp) susfiles match { case Full(sus) => val actual = load(sus._1) val expected = load(sus._2) mergeToHtmlHead(actual).toString.replaceAll("\\s", "") must_== (expected.toString.replaceAll("\\s", "")) case _ => fail("Failed loading test files") // TODO: Improve error message } } "merge <head> from real example" in { val susfiles = for { act <- tryo(getClass.getResource("ToHeadSpec.actual2.html")).filter(_ ne null) exp <- tryo(getClass.getResource("ToHeadSpec.expected2.html")).filter(_ ne null) } yield (act, exp) susfiles match { case Full(sus) => val actual = load(sus._1) val expected = load(sus._2) mergeToHtmlHead(actual) must ==/(expected) case _ => fail("Failed loading test files") // TODO: Improve error message } } "merge <lift:tohead> into a new head if not previously exist" in { val susfiles = for { act <- tryo(getClass.getResource("ToHeadSpec.actual3.html")).filter(_ ne null) exp <- tryo(getClass.getResource("ToHeadSpec.expected3.html")).filter(_ ne null) } yield (act, exp) susfiles match { case Full(sus) => val actual = load(sus._1) val expected = load(sus._2) mergeToHtmlHead(actual).toString.replaceAll("\\s", "") must_== (expected.toString.replaceAll("\\s", "")) case _ => fail("Failed loading test files") // TODO: Improve error message } } } /* "lift head cleaner" should { "remove duplicate title tag" >> { val actual = (<title>hello Other Lift Framework examples (source code examples)Here is a short list of links related to this Lift Framework ToHeadSpec.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.