forked from nspec/NSpec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotnet.watchr.rb
87 lines (66 loc) · 3.27 KB
/
dotnet.watchr.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require './watcher_dot_net.rb'
#edit the code below to pick your builder and runner,
#for :builder you can use either :MSBuilder, or :RakeBuilder
#for :test_runner you can use :NSpecRunner, :NUnitRunner, or :MSTestRunner
@dw = WatcherDotNet.new ".", { :builder => :MSBuilder, :test_runner => :NUnitRunner }
#if you choose :NSpecRunner as your :test_runner,
#this is the execution path for the NSpecRunner, the recommendation is that you install nspec via nuget: Install-Package nspec
#if you do install from nuget, specwatchr will automatically find the file.
#if you want to explicitly set the execution path for nspecrunner.exe, uncomment the line below
#NSpecRunner.nspec_path = '.\packages\nspec.0.9.24\tools\nspecrunner.exe'
#if you choose :MSTestRunner as your :test_runner
#this is the execution path for MSTest.exe
MSTestRunner.ms_test_path =
'C:\program files (x86)\microsoft visual studio 10.0\common7\ide\mstest.exe'
#if you choose :NUnitRunner as your :test_runner
#this is the execution path for NUnit.exe
NUnitRunner.nunit_path =
'.\libs\NUnit.Runners.2.6.0.12051\tools\nunit-console.exe'
#if you choose :MSBuilder as your :builder
#this is the execution path for MSBuild.exe
MSBuilder.ms_build_path =
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe'
#if you choose :RakeBuilder as your :builder
#this is the rake command that will get executed
RakeBuilder.rake_command = 'rake'
#all notifications are faciltated throw Growl for Windows
#set to empty string if you dont have growl installed
GrowlNotifier.growl_path =
'C:\program files (x86)\Growl for Windows\growlnotify.exe'
#specwathcr tries to automatically find your test dlls (it'll look for projects that end in the word Test, Tests, Spec or Specs)
#if for some reason you deviate from this convention, you can OVERRIDE the dlls selected using the following line of code
@dw.test_runner.test_dlls = ['.\NSpecSpecs\bin\Debug\NSpecSpecs.dll']
#everything after this is specwatchr specific, you dont have to worry about this stuff
def handle filename
@dw.consider filename
end
def reload file
@dw.notifier.execute "reloading", "Reloading SpecWatchr because #{file} changed.", "green"
FileUtils.touch "dotnet.watchr.rb"
end
def tutorial
puts "======================== SpecWatcher has started ==========================\n\n"
puts "TEST RUNNER: #{@dw.test_runner.class}\n\n"
puts "(you can change your test runner in dotnet.watchr.rb...)\n\n"
if(@dw.test_runner.test_dlls.count == 0)
puts "WARNING WARNING WARNING"
puts "I didn't find any test projects. Test projects MUST end in the word Test or Tests. For example: UnitTests.csproj"
puts "If you have these projects, try building your solution and re-running SpecWatchr\n\n"
else
puts "I have found the following test dll's in your solution:"
@dw.test_runner.test_dlls.each { |dll| puts dll }
end
puts "\n\n"
if(GrowlNotifier.growl_path)
puts "GROWL PATH: #{GrowlNotifier.growl_path}"
puts "If you do not have Growl For Windows installed, open up dotnet.watchr.rb and set GrowlNotifier.growl_path to \"\" (empty string)"
end
puts "\n\n"
puts "USAGE INSTRUCTIONS FOR #{@dw.test_runner.class}"
puts @dw.test_runner.usage
end
tutorial
watch ('.*.cs$') { |md| handle md[0] }
watch ('(.*.csproj$)|(.*.sln$)') do |md|
reload md[0]
end