示例#1
0
         assert_equals(true, transient()->setup1);
     });
     should("have called its own setup", function () {
         assert_equals(true, transient()->setup2);
     });
     context("nested in a context", function () {
         setup(function () {
             transient()->setup3 = true;
         });
         should("have called all three setups", function () {
             assert_equals(true, transient()->setup1);
             assert_equals(true, transient()->setup2);
             assert_equals(true, transient()->setup3);
         });
         should("have the proper test description", function () {
             assert_equals("a context nested in a context nested in a context should have the proper test description", Smoothie::instance()->test_description());
         });
     });
 });
 should("have ran teardown", function () {
     assert_true($GLOBALS['I_RAN_TEARDOWN']);
 });
 context("with no setup", function () {
     should("work", function () {
         assert_true(true);
     });
 });
 // TODO
 should("cause a failure", function () {
     assert_equals(1, 2);
 });
示例#2
0
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("accept --filter", function () {
            $smoothie = new Smoothie(array("--filter", "your regex"));
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("add slashes if missing", function () {
            $smoothie = new Smoothie(array("-n", "your regex"));
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("not add slahes if already there", function () {
            $smoothie = new Smoothie(array("-n", "/your regex/"));
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("return true if no filter was set", function () {
            $smoothie = new Smoothie();
            assert_true($smoothie->passes_filter("my awesome test"));
        });
        context("tests with passes_filter()", function () {
            setup(function () {
                transient()->smoothie = new Smoothie(array("-n", "/my awesome test/"));
            });
            should("return true if filter was set and passes", function () {
                assert_true(transient()->smoothie->passes_filter("this is my awesome test that is awesome"));
            });
            should("return false if filter was set and does not pass", function () {
                assert_false(transient()->smoothie->passes_filter("blah"));
            });
        });
    });
});