rakedotnet 1.1.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ require "base"
2
+ require "iis"
3
+ require "basetaskmocking"
4
+
5
+ describe BradyW::IIS do
6
+
7
+ it "Standard Command" do
8
+ task = BradyW::IIS.new do |task|
9
+ task.command = :start
10
+ end
11
+
12
+ task.exectaskpublic
13
+ task.excecutedPop.should == "net.exe start W3SVC"
14
+ end
15
+
16
+ it "Forgot Command" do
17
+ task = BradyW::IIS.new
18
+ lambda {task.exectaskpublic}.should raise_exception("You forgot to supply a service command (:start, :stop)")
19
+ end
20
+
21
+ it "Custom Service With Failure on STOP" do
22
+ task = BradyW::IIS.new do |task|
23
+ task.command = :stop
24
+ task.service = "SVC"
25
+ end
26
+
27
+ task.stub!(:shell).and_yield(nil, SimulateProcessFailure.new)
28
+ task.exectaskpublic
29
+ end
30
+
31
+ it "Standard Service With Failure on some other command" do
32
+ task = BradyW::IIS.new do |task|
33
+ task.command = :start
34
+ end
35
+
36
+ task.stub!(:shell).and_yield(nil, SimulateProcessFailure.new)
37
+ lambda {task.exectaskpublic}.should raise_exception(RuntimeError,
38
+ "Command failed with status (BW Rake Task Problem):")
39
+ end
40
+
41
+ it "Standard Service With Success on STOP" do
42
+ task = BradyW::IIS.new do |task|
43
+ task.command = :stop
44
+ end
45
+
46
+ task.exectaskpublic
47
+ task.excecutedPop.should == "net.exe stop W3SVC"
48
+ end
49
+ end
@@ -0,0 +1,114 @@
1
+ require "base"
2
+ require "jstest"
3
+ require "basetaskmocking"
4
+
5
+ def jspath
6
+ FileList["data/jstest/path/**/*.js"]
7
+ end
8
+
9
+ RSpec::Matchers.define :have_same_config_as do |e|
10
+ expected = YAML::load(File.read(e))
11
+ match do |a|
12
+ actual = YAML::load(File.read(a))
13
+ actual['server'].should == expected['server']
14
+ expLoad = expected['load']
15
+ actLoad = actual['load']
16
+ expLoad.each { |file| actLoad.include? file }
17
+ actLoad.each { |file| expLoad.include? file }
18
+ end
19
+
20
+ failure_message_for_should do |a|
21
+ actual = YAML::load(File.read(a))
22
+ expSvr = expected['server']
23
+ actSvr = actual['server']
24
+ expLoad = expected['load'].join("\n")
25
+ actLoad = actual['load'].join("\n")
26
+ "Expected server #{expSvr} but got #{actSvr}.\n\nExpected Files:\n#{expLoad}\n\nActual Files:\n#{actLoad}"
27
+ end
28
+ end
29
+
30
+ describe BradyW::JsTest do
31
+ before(:each) do
32
+ ENV["CCNetProject"] = nil
33
+ end
34
+
35
+ after(:each) do
36
+ # Remove our generated test data
37
+ FileUtils::rm_rf "data/output/jsTestDriver.conf"
38
+ end
39
+
40
+ it "Standard Test With Browsers and Files" do
41
+ task = BradyW::JsTest.new do |js|
42
+ js.browsers = ["iexplore.exe", "firefox.exe"]
43
+ js.files = jspath
44
+ end
45
+
46
+ task.exectaskpublic
47
+ task.excecutedPop.should == "java -jar lib/jsTestDriver-1.2.1.jar --port 9876 "+
48
+ "--browser iexplore.exe,firefox.exe --tests all"
49
+
50
+ "data/output/jsTestDriver.conf".should have_same_config_as "data/jstest/jsTestDriver_expected.conf"
51
+ end
52
+
53
+ it "Standard Test With Browsers and Files In CI tool" do
54
+ ENV["CCNetProject"] = "yes"
55
+ task = BradyW::JsTest.new do |js|
56
+ js.browsers = ["iexplore.exe", "firefox.exe"]
57
+ js.files = jspath
58
+ end
59
+
60
+ task.exectaskpublic
61
+ task.excecutedPop.should == "java -jar lib/jsTestDriver-1.2.1.jar --port 9876 "+
62
+ "--browser iexplore.exe,firefox.exe --tests all --testOutput ."
63
+
64
+ "data/output/jsTestDriver.conf".should have_same_config_as "data/jstest/jsTestDriver_expected.conf"
65
+ end
66
+
67
+ it "Standard Test With Browsers and Files with manual XML config" do
68
+ task = BradyW::JsTest.new do |js|
69
+ js.browsers = ["iexplore.exe", "firefox.exe"]
70
+ js.files = jspath
71
+ js.xmloutput = true
72
+ end
73
+
74
+ task.exectaskpublic
75
+ task.excecutedPop.should == "java -jar lib/jsTestDriver-1.2.1.jar --port 9876 "+
76
+ "--browser iexplore.exe,firefox.exe --tests all --testOutput ."
77
+
78
+ "data/output/jsTestDriver.conf".should have_same_config_as "data/jstest/jsTestDriver_expected.conf"
79
+ end
80
+
81
+ it "Custom version, Test Output, JAR path, port, and server" do
82
+ ENV["CCNetProject"] = "yes"
83
+ task = BradyW::JsTest.new do |js|
84
+ js.files = jspath
85
+ js.jarpath = "newpath/"
86
+ js.port = 1234
87
+ js.server = "anotherbox"
88
+ js.outpath = "testdir"
89
+ end
90
+
91
+ task.exectaskpublic
92
+ task.excecutedPop.should == "java -jar newpath/jsTestDriver-1.2.1.jar "+
93
+ "--tests all --testOutput testdir"
94
+
95
+ "data/output/jsTestDriver.conf".should have_same_config_as "data/jstest/jsTestDriver_expected_custom.conf"
96
+ end
97
+
98
+ it "Should clean up generated file if JS-Test-Driver fails" do
99
+ task = BradyW::JsTest.new do |js|
100
+ js.browsers = ["iexplore.exe", "firefox.exe"]
101
+ js.files = jspath
102
+ end
103
+
104
+ task.stub!(:shell).and_yield(nil, SimulateProcessFailure.new)
105
+
106
+ lambda {task.exectaskpublic}.should raise_exception("Command failed with status (BW Rake Task Problem):")
107
+
108
+ # This means our temporary file was correctly cleaned up
109
+ File.exist?("jsTestDriver.conf").should_not == true
110
+ # Our test code should have done this
111
+ File.exist?("data/output/jsTestDriver.conf").should == true
112
+ end
113
+
114
+ end
@@ -0,0 +1,27 @@
1
+ require "base"
2
+ require "minifyjs"
3
+ require "basetaskmocking"
4
+
5
+ describe BradyW::MinifyJs do
6
+
7
+ it "Should work with default settings" do
8
+ task = BradyW::MinifyJs.new do |task|
9
+ task.files = ["file1.js", "file2.js"]
10
+ end
11
+ task.exectaskpublic
12
+ task.excecutedPop.should == "java -jar lib/yuicompressor-2.4.2.jar --charset utf-8 file2.js -o file2.js"
13
+ task.excecutedPop.should == "java -jar lib/yuicompressor-2.4.2.jar --charset utf-8 file1.js -o file1.js"
14
+ end
15
+
16
+ it "Should work with custom settings" do
17
+ task = BradyW::MinifyJs.new do |task|
18
+ task.files = ["file1.js", "file2.js"]
19
+ task.version = "3.0"
20
+ task.charset = "ascii"
21
+ task.path = "newpath/"
22
+ end
23
+ task.exectaskpublic
24
+ task.excecutedPop.should == "java -jar newpath/yuicompressor-3.0.jar --charset ascii file2.js -o file2.js"
25
+ task.excecutedPop.should == "java -jar newpath/yuicompressor-3.0.jar --charset ascii file1.js -o file1.js"
26
+ end
27
+ end
@@ -0,0 +1,127 @@
1
+ require "base"
2
+ require "msbuild"
3
+ require "basetaskmocking"
4
+
5
+ describe BradyW::MSBuild do
6
+ RSpec::Matchers.define :have_build_property do |expected|
7
+ match do |actual|
8
+ actualProps = parseProps actual
9
+ actualProps.include? expected
10
+ end
11
+
12
+ def parseProps (actual)
13
+ actualProps = actual.match(/\/property:(\S+)/)[1].split(';').map do |kv|
14
+ arr = kv.split('=')
15
+ {:k => arr[0], :v =>arr[1]}
16
+ end
17
+ actualProps
18
+ end
19
+ end
20
+
21
+ RSpec::Matchers.define :have_build_property_count do |expected|
22
+ match do |actual|
23
+ actualProps = parseProps actual
24
+ actualProps.should have(expected).items
25
+ end
26
+
27
+ def parseProps (actual)
28
+ actual.match(/\/property:(\S+)/)[1].split(';')
29
+ end
30
+ end
31
+
32
+ it "should build OK vanilla (.NET 4.5)" do
33
+ task = BradyW::MSBuild.new
34
+ task.should_receive(:dotnet).with("v4\\Client").and_return("C:\\yespath\\")
35
+ task.exectaskpublic
36
+ execed = task.excecutedPop
37
+ execed.should include "C:\\yespath\\msbuild.exe"
38
+ execed.should have_build_property ({:k => "Configuration", :v => "Debug"})
39
+ execed.should have_build_property ({:k => "TargetFrameworkVersion", :v => "v4.5"})
40
+ execed.should have_build_property_count 2
41
+ end
42
+
43
+ it "should build OK (.NET 4.0)" do
44
+ task = BradyW::MSBuild.new do |t|
45
+ t.dotnet_bin_version = :v4_0
46
+ t.compile_version = :v4_0
47
+ end
48
+ task.should_receive(:dotnet).with("v4\\Client").and_return("C:\\yespath\\")
49
+ task.exectaskpublic
50
+ execed = task.excecutedPop
51
+ execed.should include "C:\\yespath\\msbuild.exe"
52
+ execed.should have_build_property ({:k => "Configuration", :v => "Debug"})
53
+ execed.should have_build_property ({:k => "TargetFrameworkVersion", :v => "v4.0"})
54
+ execed.should have_build_property_count 2
55
+ end
56
+
57
+ it "should fail with an unsupported dotnet_bin_version" do
58
+ task = BradyW::MSBuild.new do |t|
59
+ t.dotnet_bin_version = :v2_25
60
+ end
61
+ lambda {task.exectaskpublic}.should raise_exception("You supplied a .NET MSBuild binary version that's not supported. Please use :v4_0, :v3_5, or :v2_0")
62
+ end
63
+
64
+ it "should build OK with a single target" do
65
+ task = BradyW::MSBuild.new do |t|
66
+ t.targets = 't1'
67
+ end
68
+
69
+ task.should_receive(:dotnet).with("v4\\Client").and_return("C:\\yespath\\")
70
+ task.exectaskpublic
71
+ execed = task.excecutedPop
72
+ execed.should include "C:\\yespath\\msbuild.exe /target:t1"
73
+ execed.should have_build_property ({:k => "Configuration", :v => "Debug"})
74
+ execed.should have_build_property ({:k => "TargetFrameworkVersion", :v => "v4.5"})
75
+ execed.should have_build_property_count 2
76
+ end
77
+
78
+ it "should build OK with everything customized (.NET 3.5)" do
79
+ task = BradyW::MSBuild.new do |t|
80
+ t.targets = ['t1', 't2']
81
+ t.dotnet_bin_version = :v3_5
82
+ t.solution = "solutionhere"
83
+ t.compile_version = :v3_5
84
+ t.properties = {'prop1' => 'prop1val',
85
+ 'prop2' => 'prop2val'}
86
+ t.release = true
87
+ end
88
+ task.should_receive(:dotnet).with("v3.5").and_return("C:\\yespath2\\")
89
+ task.exectaskpublic
90
+ execed = task.excecutedPop
91
+ execed.should have_build_property ({:k => "Configuration", :v => "Release"})
92
+ execed.should have_build_property ({:k => "TargetFrameworkVersion", :v => "v3.5"})
93
+ execed.should have_build_property ({:k => "prop1", :v => "prop1val"})
94
+ execed.should have_build_property ({:k => "prop2", :v => "prop2val"})
95
+ execed.should have_build_property_count 4
96
+ execed.should match(/C:\\yespath2\\msbuild\.exe \/target:t1,t2 .* solutionhere/)
97
+ end
98
+
99
+ it "should build OK with custom properties that are also defaults (.NET 4.0)" do
100
+ task = BradyW::MSBuild.new do |t|
101
+ t.properties = {'Configuration' => 'myconfig',
102
+ 'prop2' => 'prop2val'}
103
+ t.release = true
104
+ end
105
+ task.should_receive(:dotnet).with("v4\\Client").and_return("C:\\yespath2\\")
106
+ task.exectaskpublic
107
+ execed = task.excecutedPop
108
+ execed.should include "C:\\yespath2\\msbuild.exe"
109
+ execed.should have_build_property ({:k => "Configuration", :v => "myconfig"})
110
+ execed.should have_build_property ({:k => "TargetFrameworkVersion", :v => "v4.5"})
111
+ execed.should have_build_property ({:k => "prop2", :v => "prop2val"})
112
+ execed.should have_build_property_count 3
113
+ end
114
+
115
+ it "should build OK with .NET 2.0" do
116
+ task = BradyW::MSBuild.new do |t|
117
+ t.dotnet_bin_version = :v2_0
118
+ t.compile_version = :v2_0
119
+ end
120
+ task.exectaskpublic
121
+ execed = task.excecutedPop
122
+ execed.should include "C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\msbuild.exe"
123
+ execed.should have_build_property ({:k => "Configuration", :v => "Debug"})
124
+ execed.should have_build_property ({:k => "TargetFrameworkVersion", :v => "v2.0"})
125
+ execed.should have_build_property_count 2
126
+ end
127
+ end
@@ -0,0 +1,25 @@
1
+ require "base"
2
+ require "mstest"
3
+ require "basetaskmocking"
4
+
5
+ describe BradyW::MSTest do
6
+
7
+ it "Should work with default settings" do
8
+ task = BradyW::MSTest.new do |test|
9
+ test.files = ["file1.dll", "file2.dll"]
10
+ end
11
+ task.should_receive(:visual_studio).with("10.0").and_return("C:\\yespath\\")
12
+ task.exectaskpublic
13
+ task.excecutedPop.should == "\"C:\\yespath\\MSTest.exe\" /testcontainer:file1.dll /testcontainer:file2.dll"
14
+ end
15
+
16
+ it "Should work with custom settings" do
17
+ task = BradyW::MSTest.new do |test|
18
+ test.files = ["file1.dll"]
19
+ test.version = "8.0"
20
+ end
21
+ task.should_receive(:visual_studio).with("8.0").and_return("C:\\yespath2\\")
22
+ task.exectaskpublic
23
+ task.excecutedPop.should == "\"C:\\yespath2\\MSTest.exe\" /testcontainer:file1.dll"
24
+ end
25
+ end
@@ -0,0 +1,118 @@
1
+ require "base"
2
+ require "nunit"
3
+ require "basetaskmocking"
4
+
5
+ describe BradyW::Nunit do
6
+
7
+ it 'shows correct default command line' do
8
+ task = BradyW::Nunit.new do |test|
9
+ test.files = ["file1.dll", "file2.dll"]
10
+ end
11
+ task.exectaskpublic
12
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
13
+ end
14
+
15
+ it 'doesnt test duplicate files' do
16
+ task = BradyW::Nunit.new do |test|
17
+ test.files = ["file1.dll", "file1.dll"]
18
+ end
19
+ task.exectaskpublic
20
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll"
21
+ end
22
+
23
+ it 'uses NUnit 2.6.1' do
24
+ task = BradyW::Nunit.new do |test|
25
+ test.files = ["file1.dll", "file2.dll"]
26
+ test.version = "2.6.1"
27
+ end
28
+ task.exectaskpublic
29
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.1\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
30
+ end
31
+
32
+ it 'uses a configured custom path' do
33
+ task = BradyW::Nunit.new do |test|
34
+ test.files = ["file1.dll", "file2.dll"]
35
+ test.path = "C:\\SomeOtherplace"
36
+ end
37
+ task.exectaskpublic
38
+ task.excecutedPop.should == "\"C:\\SomeOtherplace\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
39
+ end
40
+
41
+ it 'uses a custom timeout' do
42
+ task = BradyW::Nunit.new do |test|
43
+ test.files = ["file1.dll", "file2.dll"]
44
+ test.timeout = 25
45
+ end
46
+ task.exectaskpublic
47
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=25 file1.dll file2.dll"
48
+ end
49
+
50
+ it 'uses .NET 3.5' do
51
+ task = BradyW::Nunit.new do |test|
52
+ test.files = ["file1.dll", "file2.dll"]
53
+ test.framework_version = :v3_5
54
+ end
55
+ task.exectaskpublic
56
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /noxml /framework=3.5 /timeout=35000 file1.dll file2.dll"
57
+ end
58
+
59
+ it 'can handle a single specific test to run' do
60
+ task = BradyW::Nunit.new do |test|
61
+ test.files = ["file1.dll", "file2.dll"]
62
+ test.tests = "some.test"
63
+ end
64
+
65
+ task.exectaskpublic
66
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 /run=some.test file1.dll file2.dll"
67
+ end
68
+
69
+ it 'can handle a multiple specific tests to run' do
70
+ task = BradyW::Nunit.new do |test|
71
+ test.files = ["file1.dll", "file2.dll"]
72
+ test.tests = ["some.test", "some.other.test"]
73
+ end
74
+
75
+ task.exectaskpublic
76
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /noxml /framework=4.5 /timeout=35000 /run=some.test,some.other.test file1.dll file2.dll"
77
+ end
78
+
79
+ it 'should work OK if XML output is turned on' do
80
+ task = BradyW::Nunit.new do |test|
81
+ test.files = ["file1.dll", "file2.dll"]
82
+ test.xml_output = :enabled
83
+ end
84
+ task.exectaskpublic
85
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /labels /framework=4.5 /timeout=35000 file1.dll file2.dll"
86
+
87
+ end
88
+
89
+ it 'Should work without labels' do
90
+ task = BradyW::Nunit.new do |test|
91
+ test.files = ["file1.dll", "file2.dll"]
92
+ test.labels = :exclude_labels
93
+ end
94
+ task.exectaskpublic
95
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
96
+
97
+ end
98
+
99
+ it 'Should work OK with custom errors and console output' do
100
+ task = BradyW::Nunit.new do |test|
101
+ test.files = ["file1.dll", "file2.dll"]
102
+ test.output = "somefile.txt"
103
+ test.errors = "someerrorfile.txt"
104
+ end
105
+ task.exectaskpublic
106
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console.exe\" /output=somefile.txt /err=someerrorfile.txt /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
107
+ end
108
+
109
+ it 'Should work OK with x86 arch' do
110
+ task = BradyW::Nunit.new do |test|
111
+ test.files = ["file1.dll", "file2.dll"]
112
+ test.arch = :x86
113
+ end
114
+ task.exectaskpublic
115
+ task.excecutedPop.should == "\"C:\\Program Files (x86)\\NUnit 2.6.2\\bin\\nunit-console-x86.exe\" /labels /noxml /framework=4.5 /timeout=35000 file1.dll file2.dll"
116
+
117
+ end
118
+ end