Here is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing totoo many "acts", I end up breaking it up into separate specifications.
class describe_JavaScriptBundle : nspec
{
JavaScriptBundle bundle;
void AddTest1JS()
{
bundle.Add("test.js");
}
void before_each()
{
bundle = Bundle.JavaScript();
}
void adding_a_bundle()
{
context["no files added"] = () =>
{
it["GroupBundle contains default key"] = () =>
bundle.GroupBundles.ContainsKey("default").is_true();
it["has no Assets"] () =>
bundle.GroupBundles["default"].Assets.Count.Is(0);
};
context["adding one file"] = () =>
{
act = () => AddTest1JS();
it["contains the file"] = () =>
bundle.GroupBundles["default"].Assets.Count.Is(1);
context["adding the same file again"] = () =>
{
act = () => AddTest1JS();
it["should still only contain one file"] = () =>
bundle.GroupBundles["default"].Assets.Count.Is(1);
};
};
}
}