Skip to content

Commit

Permalink
added the add_folders mode to the JasmineCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Nov 15, 2011
1 parent 5072673 commit 588f745
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/Serenity/Jasmine/JasmineCommand.cs
@@ -1,14 +1,30 @@
using System;
using FubuCore;
using FubuCore.CommandLine;
using System.Linq;
using System.Collections.Generic;

namespace Serenity.Jasmine
{
[CommandDescription("Opens up a web browser application to browse and execute Jasmine specifications",
Name = "jasmine")]
[Usage("default", "runs the jasmine tests")]
[Usage("add_folders", "adds new folders to a Serenity/Jasmine project")]
public class JasmineCommand : FubuCommand<JasmineInput>
{
public override bool Execute(JasmineInput input)
{
if (input.Mode == JasmineMode.add_folders)
{
new FileSystem().AlterFlatFile(input.SerenityFile, list =>
{
var includes = input.Folders.Select(folder => "include:" + folder);
list.Fill(includes);
});

return true;
}

// TODO -- tighten up the defensive programming against bad input
var runner = new JasmineRunner(input);

Expand All @@ -25,6 +41,8 @@ public override bool Execute(JasmineInput input)
}
}



return true;
}
}
Expand Down
19 changes: 18 additions & 1 deletion src/Serenity/Jasmine/JasmineInput.cs
@@ -1,12 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using FubuCore.CommandLine;
using OpenQA.Selenium;


namespace Serenity.Jasmine
{
public enum JasmineMode
{
interactive,
run
run,
add_folders

}

public class JasmineInput
Expand All @@ -18,13 +24,24 @@ public JasmineInput()

}

[Description("Chooses whether to open the browser application or just run all the specs in CLI mode")]
[RequiredUsage("default", "add_folders")]
public JasmineMode Mode { get; set; }

[Description("Name of the file containing directives for where the specifications are located")]
[RequiredUsage("default", "add_folders")]
public string SerenityFile { get; set; }

[Description("Optionally overrides which port number Kayak uses for the web application. Default is 5500")]
public int PortFlag { get; set; }

[Description("Choose which browser to use for the testing")]
public BrowserType BrowserFlag { get; set; }

[Description("Adds folders to a Jasmine project in the add_folders. \nFolders can be either absolute paths or relative to the jasmine text file")]
[RequiredUsage("add_folders")]
public IEnumerable<string> Folders { get; set; }

public Func<IWebDriver> GetBrowserBuilder()
{
return new WebDriverSettings{
Expand Down
10 changes: 9 additions & 1 deletion src/Serenity/Jasmine/JasminePages.cs
Expand Up @@ -5,6 +5,7 @@
using FubuMVC.Core.UI;
using HtmlTags;
using FubuCore;
using System.Linq;

namespace Serenity.Jasmine
{
Expand All @@ -15,7 +16,7 @@ public class JasminePages
private readonly SpecHierarchyBuilder _builder;
private readonly SpecAssetRequirements _requirements;
private readonly FubuHtmlDocument _document;
private static string _header;
private static readonly string _header;

static JasminePages()
{
Expand Down Expand Up @@ -76,6 +77,13 @@ private void writeNode(ISpecNode node)
_document.Add("hr");

_requirements.WriteAssetsInto(_document, node.AllSpecifications);

var fileSystem = new FileSystem();
node.AllSpecifications.SelectMany(x => x.HtmlFiles).Each(file =>
{
var html = fileSystem.ReadStringFromFile(file.FullPath);
_document.Add("div").Text(html).Encoded(false);
});
}
}
}
3 changes: 1 addition & 2 deletions src/Serenity/Jasmine/SpecAssetRequirements.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using FubuMVC.Core.Assets;
using FubuMVC.Core.Assets.Files;
using FubuMVC.Core.UI;

namespace Serenity.Jasmine
Expand All @@ -22,11 +21,11 @@ public void WriteAssetsInto(FubuHtmlDocument document, IEnumerable<Specification

RegisterSpecifications(specs);
document.WriteAssetsToHead();

}

public void RegisterRequirements(IEnumerable<Specification> specs)
{
_requirements.Require("core");
_requirements.Require("jasmine");

specs.SelectMany(x => x.Libraries).Each(lib => _requirements.Require(lib.Name));
Expand Down

0 comments on commit 588f745

Please sign in to comment.