tc_integration 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.rdoc +19 -0
  3. data/lib/tc_integration.rb +109 -0
  4. metadata +47 -0
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Nigel Thorne
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = tc_integration
2
+
3
+ Test Complete integration
4
+
5
+ == Contributing to tc_integration
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Nigel Thorne. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,109 @@
1
+ require 'rubygems'
2
+ require 'win32ole'
3
+
4
+ include WIN32OLE::VARIANT
5
+
6
+ class String
7
+ def strip_quotes
8
+ gsub(/\A['"]+|['"]+\Z/, "").gsub("\\\\","\\")
9
+ end
10
+ end
11
+
12
+ class TCUnit
13
+ def initialize(name, tc)
14
+ @framework, @unit = name.split(".")
15
+ @integration = tc.integration
16
+ end
17
+ private
18
+ def method_missing(meth, *args, &blk)
19
+ @integration.RunRoutineEx(@framework, @unit, meth.to_s, WIN32OLE_VARIANT.new(args.map{|a|
20
+ a.is_a?(String) ? WIN32OLE_VARIANT.new(a, VT_BSTR) : WIN32OLE_VARIANT.new(a, VT_VARIANT|VT_BYREF)}
21
+ ))
22
+ sleep(1) while @integration.IsRunning
23
+ @integration.RoutineResult
24
+ end
25
+ end
26
+
27
+
28
+ class TCLibrary
29
+ def initialize(name, tc)
30
+ @framework = name
31
+ @tc = tc
32
+ @units = {}
33
+ end
34
+ private
35
+ def method_missing(meth, *args, &blk)
36
+ raise("?") if(args.count > 0)
37
+ @units[meth] ||= TCUnit.new(@framework + "." + meth.to_s, @tc)
38
+ end
39
+ end
40
+
41
+ class Proj
42
+ def initialize(proj_file)
43
+ @tc = TC.new
44
+ @integration = @tc.integration
45
+ raise("Test Complete is already Running a test") if(@integration.IsRunning)
46
+ @suite = @integration.OpenProjectSuite(proj_file)
47
+ @libraries ||={}
48
+ end
49
+
50
+ private
51
+ def method_missing(meth, *args, &blk)
52
+ raise("?") if(args.count > 0)
53
+ @libraries[meth] ||= TCLibrary.new(meth.to_s, @tc)
54
+ end
55
+ end
56
+
57
+ class TC
58
+ def initialize
59
+ @tc = TC.get_TC
60
+ end
61
+
62
+ def self.get_TC
63
+ tc = get_OLE("TestComplete.TestCompleteApplication.9") unless tc
64
+ tc = get_OLE("TestExecute.TestExecuteApplication.9") unless tc
65
+ tc = get_OLE("TestComplete.TestCompleteApplication.8") unless tc
66
+ tc = get_OLE("TestExecute.TestExecuteApplication.8") unless tc
67
+ tc
68
+ end
69
+
70
+ def self.get_OLE(strAutomationEngine)
71
+ begin
72
+ tc = WIN32OLE.connect(strAutomationEngine)
73
+ rescue WIN32OLERuntimeError
74
+ begin
75
+ tc = WIN32OLE.new(strAutomationEngine)
76
+ rescue WIN32OLERuntimeError
77
+ end
78
+ end
79
+ tc
80
+ end
81
+
82
+ def library(name)
83
+ TCLibrary.new(name, @tc)
84
+ end
85
+
86
+ def method_missing(meth, *args, &blk)
87
+ @tc.send(meth, *args, &blk)
88
+ end
89
+
90
+ def StartProcess(executable, parameter, timeout)
91
+ shell = WIN32OLE.new('WScript.Shell')
92
+ shell.Run("#{executable} \"#{parameter}\"")
93
+
94
+ processName = executable.split(/[\/\\]/).last.split(/\./).first
95
+ sys = @tc.GetObjectByName("Sys")
96
+ x = Now + timeout
97
+
98
+ begin
99
+ process = sys.Find("ProcessName", processName)
100
+ end while(!process.Exists && Now < x)
101
+ return process
102
+ end
103
+
104
+ def LaunchIe(url, timeout)
105
+ executable = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
106
+ StartProcess(executable, url, timeout)
107
+ end
108
+ end
109
+
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tc_integration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nigel Thorne
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple layer ontop of TestComplete's COM layer.
15
+ email: github@nigelthorne.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/tc_integration.rb
21
+ - LICENSE.txt
22
+ - README.rdoc
23
+ homepage: http://www.github.com/nigelthorne/tc_integration
24
+ licenses: []
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project: nowarning
43
+ rubygems_version: 1.8.24
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: Test Complete integration.
47
+ test_files: []