rakedotnet 1.1.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ require "base"
2
+ require "registry_accessor"
3
+
4
+ describe BradyW::RegistryAccessor do
5
+ before(:each) do
6
+ # partial mocking is done with this
7
+ @windowPathsWrapper = BradyW::RegistryAccessor.new
8
+ end
9
+
10
+ it "should work OK with a 64 bit registry call" do
11
+ @windowPathsWrapper.should_receive(:regvalue64).any_number_of_times.with("regkey",
12
+ "regvalue").and_return("hi")
13
+ @windowPathsWrapper.stub!(:regvalue32).and_return("not me")
14
+ result = @windowPathsWrapper.regvalue "regkey", "regvalue"
15
+ result.should == "hi"
16
+ end
17
+
18
+ it "should use standard 32 bit registry mode if 64 fails" do
19
+ @windowPathsWrapper.stub!(:regvalue64).and_raise("Registry failure")
20
+ @windowPathsWrapper.should_receive(:regvalue32).any_number_of_times.with("regkey",
21
+ "regvalue").and_return("hi")
22
+ result = @windowPathsWrapper.regvalue "regkey", "regvalue"
23
+ result.should == "hi"
24
+ end
25
+
26
+ it "should fail if the 32 bit call fails after trying 64" do
27
+ @windowPathsWrapper.stub!(:regvalue64).and_raise("Registry failure")
28
+ @windowPathsWrapper.stub!(:regvalue32).and_raise("Registry failure")
29
+ lambda {@windowPathsWrapper.regvalue("regkey", "regvalue")}.should raise_exception("Unable to find registry value in either 32 or 64 bit mode: regkey\\regvalue")
30
+ end
31
+ end
@@ -0,0 +1,323 @@
1
+ require "base"
2
+ require "sqlcmd"
3
+ require "basetaskmocking"
4
+
5
+ def testdata
6
+ FileList["data/sqlcmd/input/**/*"]
7
+ end
8
+
9
+ describe BradyW::Sqlcmd do
10
+ RSpec::Matchers.define :have_sql_property do |expected|
11
+ match do |actual|
12
+ actualProps = parseProps actual
13
+ actualProps.include? expected
14
+ end
15
+
16
+ def parseProps (actual)
17
+ actualProps = actual.match(/.*-v (.+) -/)[1].scan(/('.*?'|\S+=".*?"|\S+)/).map do |kv|
18
+ arr = kv[0].split('=')
19
+ {:k => arr[0], :v => arr[1]}
20
+ end
21
+ actualProps
22
+ end
23
+ end
24
+
25
+ RSpec::Matchers.define :have_sql_property_count do |expected|
26
+ match do |actual|
27
+ actualProps = parseProps actual
28
+ actualProps.should have(expected).items
29
+ end
30
+
31
+ def parseProps (actual)
32
+ actual.match(/.*-v (.+) -/)[1].scan(/('.*?'|\S+=".*?"|\S+)/)
33
+ end
34
+ end
35
+
36
+ before(:each) do
37
+ # It uses the current date, which is harder to test
38
+ BradyW::Sqlcmd.stub!(:generatetempfilename).and_return "tempfile.sql"
39
+ end
40
+
41
+ before(:each) do
42
+ @db = BradyW::Database.new
43
+
44
+ def @config.db_name
45
+ "regulardb"
46
+ end
47
+
48
+ def @config.db_hostname
49
+ "myhostname"
50
+ end
51
+
52
+ def @config.db_general_authmode
53
+ :sqlauth
54
+ end
55
+
56
+ def @config.db_general_user
57
+ "theuser"
58
+ end
59
+
60
+ def @config.db_general_password
61
+ "thepassword"
62
+ end
63
+
64
+ def @config.project_prefix
65
+ "PRE"
66
+ end
67
+
68
+ def @config.db_system_authmode
69
+ :sqlauth
70
+ end
71
+
72
+ def @config.db_system_user
73
+ "systemuser"
74
+ end
75
+
76
+ def @config.db_system_password
77
+ "systempassword"
78
+ end
79
+
80
+ def @config.db_system_datadir
81
+ "F:\\"
82
+ end
83
+
84
+ def @config.db_objectcreation_authmode
85
+ :sqlauth
86
+ end
87
+
88
+ def @config.db_objectcreation_user
89
+ "objectcreateuser"
90
+ end
91
+
92
+ def @config.db_objectcreation_password
93
+ "objectcreatepassword"
94
+ end
95
+ end
96
+
97
+ after(:each) do
98
+ # Remove our generated test data
99
+ FileUtils::rm_rf "data/output/tempfile.sql"
100
+ FileUtils::rm_rf "data/output/makedynamic"
101
+ end
102
+
103
+ it "Should work with default version and default (non create) credentials in SQL auth mode" do
104
+ task = BradyW::Sqlcmd.new do |sql|
105
+ sql.files = testdata
106
+ end
107
+
108
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
109
+
110
+ task.exectaskpublic
111
+ execed = task.excecutedPop
112
+ execed.should match(/"z:\\sqlcmd\.exe" -U theuser -P thepassword -S myhostname -e -b -v .* -i tempfile.sql/)
113
+
114
+ execed.should have_sql_property ({:k => "dbname", :v => "regulardb"})
115
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
116
+ execed.should have_sql_property_count 2
117
+
118
+ expected = IO.readlines("data/sqlcmd/expected.sql")
119
+ actual = IO.readlines("data/output/tempfile.sql")
120
+
121
+ actual.should == expected
122
+ end
123
+
124
+ it "Should work with a custom version and default (non create) credentials in Win auth mode" do
125
+ def @config.db_general_authmode
126
+ :winauth
127
+ end
128
+
129
+ task = BradyW::Sqlcmd.new do |sql|
130
+ sql.files = testdata
131
+ sql.version = "902"
132
+ end
133
+
134
+ task.should_receive(:sql_tool).any_number_of_times.with("902").and_return("z:\\")
135
+
136
+ task.exectaskpublic
137
+
138
+ execed = task.excecutedPop
139
+ execed.should match(/"z:\\sqlcmd\.exe" -E -S myhostname -e -b -v .* -i tempfile.sql/)
140
+
141
+ execed.should have_sql_property ({:k => "dbname", :v => "regulardb"})
142
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
143
+ execed.should have_sql_property_count 2
144
+
145
+ expected = IO.readlines("data/sqlcmd/expected.sql")
146
+ actual = IO.readlines("data/output/tempfile.sql")
147
+
148
+ actual.should == expected
149
+ end
150
+
151
+ it "Works fine with system credentials in SQL auth mode" do
152
+ task = BradyW::Sqlcmd.new do |sql|
153
+ sql.files = testdata
154
+ sql.credentials = :system
155
+ end
156
+
157
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
158
+
159
+ task.exectaskpublic
160
+ execed = task.excecutedPop
161
+ execed.should match(/"z:\\sqlcmd\.exe" -U systemuser -P systempassword -S myhostname -e -b -v .* -i tempfile.sql/)
162
+
163
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
164
+ execed.should have_sql_property ({:k => "dbpassword", :v => "thepassword"})
165
+ execed.should have_sql_property ({:k => "sqlserverdatadirectory", :v => "\"F:\\\""})
166
+ execed.should have_sql_property_count 4
167
+
168
+ expected = IO.readlines("data/sqlcmd/expected.sql")
169
+ actual = IO.readlines("data/output/tempfile.sql")
170
+
171
+ actual.should == expected
172
+ end
173
+
174
+ it "Fails properly with invalid credential specifier" do
175
+ task = BradyW::Sqlcmd.new do |sql|
176
+ sql.files = testdata
177
+ lambda { sql.credentials = :foo }.should raise_exception("Invalid credentials value! Allowed values: :system, :objectcreation, :general")
178
+ end
179
+ end
180
+
181
+ it "Works fine with objectcreation credentials in SQL auth mode" do
182
+ task = BradyW::Sqlcmd.new do |sql|
183
+ sql.files = testdata
184
+ sql.credentials = :objectcreation
185
+ end
186
+
187
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
188
+
189
+ task.exectaskpublic
190
+
191
+ execed = task.excecutedPop
192
+ execed.should match(/"z:\\sqlcmd\.exe" -U objectcreateuser -P objectcreatepassword -S myhostname -e -b -v .* -i tempfile.sql/)
193
+
194
+ execed.should have_sql_property ({:k => "dbname", :v => "regulardb"})
195
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
196
+ execed.should have_sql_property_count 2
197
+
198
+ expected = IO.readlines("data/sqlcmd/expected.sql")
199
+ actual = IO.readlines("data/output/tempfile.sql")
200
+
201
+ actual.should == expected
202
+ end
203
+
204
+ it "Works fine with system credentials in Win auth mode" do
205
+ def @config.db_system_authmode
206
+ :winauth
207
+ end
208
+
209
+ task = BradyW::Sqlcmd.new do |sql|
210
+ sql.files = testdata
211
+ sql.credentials = :system
212
+ end
213
+
214
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
215
+
216
+ task.exectaskpublic
217
+ execed = task.excecutedPop
218
+ execed.should match(/"z:\\sqlcmd\.exe" -E -S myhostname -e -b -v .* -i tempfile.sql/)
219
+
220
+ execed.should have_sql_property ({:k => "dbname", :v => "regulardb"})
221
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
222
+ execed.should have_sql_property ({:k => "sqlserverdatadirectory", :v => "\"F:\\\""})
223
+ execed.should have_sql_property ({:k => "dbpassword", :v => "thepassword"})
224
+ execed.should have_sql_property_count 4
225
+
226
+ expected = IO.readlines("data/sqlcmd/expected.sql")
227
+ actual = IO.readlines("data/output/tempfile.sql")
228
+
229
+ actual.should == expected
230
+ end
231
+
232
+ it "Works fine with additional variables" do
233
+ task = BradyW::Sqlcmd.new do |sql|
234
+ sql.files = testdata
235
+ sql.credentials = :system
236
+ sql.variables = {"var1" => "val1",
237
+ "dbpassword" => "yesitsoktooverride",
238
+ "spacevar" => "deals with space right"}
239
+ end
240
+
241
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
242
+
243
+ task.exectaskpublic
244
+ execed = task.excecutedPop
245
+ execed.should match(/"z:\\sqlcmd\.exe" -U systemuser -P systempassword -S myhostname -e -b -v .* -i tempfile.sql/)
246
+
247
+ execed.should have_sql_property ({:k => "dbname", :v => "regulardb"})
248
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
249
+ execed.should have_sql_property ({:k => "dbpassword", :v => "yesitsoktooverride"})
250
+ execed.should have_sql_property ({:k => "var1", :v => "val1"})
251
+ execed.should have_sql_property ({:k => "spacevar", :v => "\"deals with space right\""})
252
+ execed.should have_sql_property ({:k => "sqlserverdatadirectory", :v => "\"F:\\\""})
253
+
254
+ execed.should have_sql_property_count 6
255
+
256
+ expected = IO.readlines("data/sqlcmd/expected.sql")
257
+ actual = IO.readlines("data/output/tempfile.sql")
258
+ actual.should == expected
259
+
260
+ end
261
+
262
+ it "Works fine with custom variables" do
263
+ task = BradyW::Sqlcmd.new do |sql|
264
+ sql.files = testdata
265
+ sql.variables = {"var1" => "val1",
266
+ "dbpassword" => "yesitsoktooverride",
267
+ "spacevar" => "deals with space right"}
268
+ end
269
+
270
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
271
+
272
+ task.exectaskpublic
273
+ execed = task.excecutedPop
274
+ execed.should match(/"z:\\sqlcmd\.exe" -U theuser -P thepassword -S myhostname -e -b -v .* -i tempfile.sql/)
275
+
276
+ execed.should have_sql_property ({:k => "dbname", :v => "regulardb"})
277
+ execed.should have_sql_property ({:k => "dbuser", :v => "theuser"})
278
+ execed.should have_sql_property ({:k => "dbpassword", :v => "yesitsoktooverride"})
279
+ execed.should have_sql_property ({:k => "var1", :v => "val1"})
280
+ execed.should have_sql_property ({:k => "spacevar", :v => "\"deals with space right\""})
281
+
282
+ execed.should have_sql_property_count 5
283
+
284
+ expected = IO.readlines("data/sqlcmd/expected.sql")
285
+ actual = IO.readlines("data/output/tempfile.sql")
286
+ actual.should == expected
287
+
288
+ end
289
+
290
+ it "Fails the build properly (and gracefully) if sqlcmd has an error" do
291
+ task = BradyW::Sqlcmd.new do |sql|
292
+ sql.files = testdata
293
+ end
294
+
295
+ task.should_receive(:sql_tool).any_number_of_times.with("100").and_return("z:\\")
296
+ task.stub!(:shell).and_yield(nil, SimulateProcessFailure.new)
297
+
298
+ lambda { task.exectaskpublic }.should raise_exception("Command failed with status (BW Rake Task Problem):")
299
+
300
+ # This means our temporary file was correctly cleaned up
301
+ File.exist?("tempfile.sql").should_not == true
302
+ # Our test code should have done this
303
+ File.exist?("data/output/tempfile.sql").should == true
304
+ end
305
+
306
+ it "Properly changes strings to dynamic ones in SQL files" do
307
+ FileUtils::cp_r "data/sqlcmd/makedynamic", "data/output"
308
+
309
+ task = BradyW::Sqlcmd.new do |sql|
310
+ sql.files = FileList['data/output/makedynamic/**/*']
311
+ sql.makedynamic = true
312
+ end
313
+
314
+ task.exectaskpublic
315
+
316
+ task.excecutedPop.should == nil
317
+
318
+ expected = IO.readlines("data/sqlcmd/dynamic_expected.sql")
319
+ actual = IO.readlines("data/output/makedynamic/01-tables/dynamic_input.sql")
320
+ actual.should == expected
321
+ end
322
+
323
+ end
@@ -0,0 +1,39 @@
1
+ require "base"
2
+ require "windowspaths"
3
+
4
+ class WindowsPathsWrapper
5
+ include BradyW::WindowsPaths
6
+ def log text
7
+ puts text
8
+ end
9
+ end
10
+
11
+ describe BradyW::WindowsPaths do
12
+ before(:each) do
13
+ @windowPathsWrapper = WindowsPathsWrapper.new
14
+ @mockedRegistryAccessor = BradyW::RegistryAccessor.new
15
+ # No dependency injection framework required :)
16
+ BradyW::RegistryAccessor.stub!(:new).and_return(@mockedRegistryAccessor)
17
+ end
18
+
19
+ it "should retrieve SQL Server tools properly" do
20
+ @mockedRegistryAccessor.should_receive(:regvalue).any_number_of_times.with("SOFTWARE\\Microsoft\\Microsoft SQL Server\\verhere\\Tools\\ClientSetup",
21
+ "Path").and_return("hi")
22
+ result = @windowPathsWrapper.send(:sql_tool,"verhere")
23
+ result.should == "hi"
24
+ end
25
+
26
+ it "should retrieve the Visual Studio path properly" do
27
+ @mockedRegistryAccessor.should_receive(:regvalue).any_number_of_times.with("SOFTWARE\\Microsoft\\VisualStudio\\verhere",
28
+ "InstallDir").and_return("hi")
29
+ result = @windowPathsWrapper.send(:visual_studio,"verhere")
30
+ result.should == "hi"
31
+ end
32
+
33
+ it "should retrieve .NET runtime path properly" do
34
+ @mockedRegistryAccessor.should_receive(:regvalue).any_number_of_times.with("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\verhere",
35
+ "InstallPath").and_return("hi")
36
+ result = @windowPathsWrapper.send(:dotnet,"verhere")
37
+ result.should == "hi"
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rakedotnet
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.51
5
+ platform: ruby
6
+ authors:
7
+ - Brady Wied
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: windows-pr
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Provides MSBuild, NUnit, BCP, SqlCmd, MsTest, MinifyJS, jstest tasks
28
+ for Rake build files
29
+ email: brady@bswtechconsulting.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/basetask.rb
35
+ - lib/base_config.rb
36
+ - lib/bcp.rb
37
+ - lib/config.rb
38
+ - lib/database.rb
39
+ - lib/dotframeworksymbolhelp.rb
40
+ - lib/iis.rb
41
+ - lib/jstest.rb
42
+ - lib/minifyjs.rb
43
+ - lib/msbuild.rb
44
+ - lib/mstest.rb
45
+ - lib/nunit.rb
46
+ - lib/registry_accessor.rb
47
+ - lib/sqlcmd.rb
48
+ - lib/TODO-publish.rb
49
+ - lib/TODO-settingsfiles.rb
50
+ - lib/tools.rb
51
+ - lib/windowspaths.rb
52
+ - spec/base.rb
53
+ - spec/basetaskmocking.rb
54
+ - spec/basetask_spec.rb
55
+ - spec/bcp_spec.rb
56
+ - spec/config_spec.rb
57
+ - spec/config_testdata/defaultpartialuser_default.rb
58
+ - spec/config_testdata/defaultpartialuser_user.rb
59
+ - spec/config_testdata/local_properties.rb
60
+ - spec/config_testdata/local_properties_default.rb
61
+ - spec/config_testdata/onlydefault.rb
62
+ - spec/db_spec.rb
63
+ - spec/iis_spec.rb
64
+ - spec/jstest_spec.rb
65
+ - spec/minifyjs_spec.rb
66
+ - spec/msbuild_spec.rb
67
+ - spec/mstest_spec.rb
68
+ - spec/nunit_spec.rb
69
+ - spec/registry_accessor_spec.rb
70
+ - spec/sqlcmd_spec.rb
71
+ - spec/windowspaths_spec.rb
72
+ homepage: https://github.com/wied03/Rake.NET
73
+ licenses:
74
+ - BSD
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options:
78
+ - --inline-source
79
+ - --line-numbers
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.7
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Rake tasks for building .NET projects
98
+ test_files:
99
+ - spec/base.rb
100
+ - spec/basetaskmocking.rb
101
+ - spec/basetask_spec.rb
102
+ - spec/bcp_spec.rb
103
+ - spec/config_spec.rb
104
+ - spec/config_testdata/defaultpartialuser_default.rb
105
+ - spec/config_testdata/defaultpartialuser_user.rb
106
+ - spec/config_testdata/local_properties.rb
107
+ - spec/config_testdata/local_properties_default.rb
108
+ - spec/config_testdata/onlydefault.rb
109
+ - spec/db_spec.rb
110
+ - spec/iis_spec.rb
111
+ - spec/jstest_spec.rb
112
+ - spec/minifyjs_spec.rb
113
+ - spec/msbuild_spec.rb
114
+ - spec/mstest_spec.rb
115
+ - spec/nunit_spec.rb
116
+ - spec/registry_accessor_spec.rb
117
+ - spec/sqlcmd_spec.rb
118
+ - spec/windowspaths_spec.rb