Skip to content

Commit

Permalink
made serenity jasmine runner recycle when asset.config files change
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Nov 15, 2011
1 parent acf428d commit ca8860c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
@@ -0,0 +1 @@
# nothing to see heregfd
1 change: 1 addition & 0 deletions src/Serenity.Testing/Serenity.Testing.csproj
Expand Up @@ -118,6 +118,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Jasmine\TestPackage1\player.asset.config" />
<None Include="Jasmine\TestPackage2\fake.asset.config" />
<None Include="packages.config" />
<None Include="Serenity.Testing.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
20 changes: 18 additions & 2 deletions src/Serenity/Jasmine/JasmineRunner.cs
Expand Up @@ -7,6 +7,7 @@
using FubuCore;
using FubuCore.CommandLine;
using FubuMVC.Core;
using FubuMVC.Core.Assets;
using FubuMVC.Core.Assets.Caching;
using FubuMVC.OwinHost;
using OpenQA.Selenium;
Expand Down Expand Up @@ -142,6 +143,11 @@ void ISpecFileListener.Deleted()
}

void ISpecFileListener.Added()
{
Recycle();
}

public void Recycle()
{
_host.Recycle(watchAssetFiles);
_applicationUnderTest.Driver.Navigate().Refresh();
Expand Down Expand Up @@ -192,16 +198,25 @@ public void StartWatching(ISpecFileListener listener)
{
addContentFolder(contentFolder, listener);
}
var watcher = new FileSystemWatcher(dir, "*.config");
watcher.Changed += (x, y) => listener.Recycle();
watcher.Deleted += (x, y) => listener.Recycle();
watcher.EnableRaisingEvents = true;
watcher.IncludeSubdirectories = true;
_watchers.Add(watcher);
});
});
}

private void addContentFolder(string dir, ISpecFileListener listener)
{
var watcher = new FileSystemWatcher(dir);
watcher.Changed += (x, y) =>
watcher.Changed += (x, file) =>
{
Console.WriteLine("Detected a change to " + y.FullPath);
Console.WriteLine("Detected a change to " + file.FullPath);
_cache.FlushAll();
listener.Changed();
};
Expand Down Expand Up @@ -232,5 +247,6 @@ public interface ISpecFileListener
void Changed();
void Deleted();
void Added();
void Recycle();
}
}

0 comments on commit ca8860c

Please sign in to comment.