tc_integration 0.0.2 → 0.0.3

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 (2) hide show
  1. data/lib/tc_integration.rb +82 -79
  2. metadata +1 -1
@@ -3,107 +3,110 @@ require 'win32ole'
3
3
 
4
4
  include WIN32OLE::VARIANT
5
5
 
6
+
6
7
  class String
7
8
  def strip_quotes
8
9
  gsub(/\A['"]+|['"]+\Z/, "").gsub("\\\\","\\")
9
10
  end
10
11
  end
11
12
 
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
13
+ module TCIntegration
14
+
15
+ class TCUnit
16
+ def initialize(name, tc)
17
+ @framework, @unit = name.split(".")
18
+ @integration = tc.integration
19
+ end
20
+ private
21
+ def method_missing(meth, *args, &blk)
22
+ @integration.RunRoutineEx(@framework, @unit, meth.to_s, WIN32OLE_VARIANT.new(args.map{|a|
23
+ a.is_a?(String) ? WIN32OLE_VARIANT.new(a, VT_BSTR) : WIN32OLE_VARIANT.new(a, VT_VARIANT|VT_BYREF)}
24
+ ))
25
+ sleep(1) while @integration.IsRunning
26
+ @integration.RoutineResult
27
+ end
24
28
  end
25
- end
26
29
 
27
30
 
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)
31
+ class TCLibrary
32
+ def initialize(name, tc)
33
+ @framework = name
34
+ @tc = tc
35
+ @units = {}
36
+ end
37
+ private
38
+ def method_missing(meth, *args, &blk)
39
+ raise("?") if(args.count > 0)
40
+ @units[meth] ||= TCUnit.new(@framework + "." + meth.to_s, @tc)
41
+ end
38
42
  end
39
- end
40
43
 
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
44
+ class Proj
45
+ def initialize(proj_file)
46
+ @tc = TC.new
47
+ @integration = @tc.integration
48
+ raise("Test Complete is already Running a test") if(@integration.IsRunning)
49
+ @suite = @integration.OpenProjectSuite(proj_file)
50
+ @libraries ||={}
51
+ end
56
52
 
57
- class TC
58
- def initialize
59
- @tc = TC.get_TC
53
+ private
54
+ def method_missing(meth, *args, &blk)
55
+ raise("?") if(args.count > 0)
56
+ @libraries[meth] ||= TCLibrary.new(meth.to_s, @tc)
57
+ end
60
58
  end
61
59
 
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
60
+ class TC
61
+ def initialize
62
+ @tc = TC.get_TC
63
+ end
64
+
65
+ def self.get_TC
66
+ tc = get_OLE("TestComplete.TestCompleteApplication.9") unless tc
67
+ tc = get_OLE("TestExecute.TestExecuteApplication.9") unless tc
68
+ tc = get_OLE("TestComplete.TestCompleteApplication.8") unless tc
69
+ tc = get_OLE("TestExecute.TestExecuteApplication.8") unless tc
70
+ tc
71
+ end
72
+
73
+ def self.get_OLE(strAutomationEngine)
74
74
  begin
75
- tc = WIN32OLE.new(strAutomationEngine)
75
+ tc = WIN32OLE.connect(strAutomationEngine)
76
76
  rescue WIN32OLERuntimeError
77
+ begin
78
+ tc = WIN32OLE.new(strAutomationEngine)
79
+ rescue WIN32OLERuntimeError
80
+ end
77
81
  end
82
+ tc
78
83
  end
79
- tc
80
- end
81
84
 
82
- def library(name)
83
- TCLibrary.new(name, @tc)
84
- end
85
+ def library(name)
86
+ TCLibrary.new(name, @tc)
87
+ end
85
88
 
86
- def method_missing(meth, *args, &blk)
87
- @tc.send(meth, *args, &blk)
88
- end
89
+ def method_missing(meth, *args, &blk)
90
+ @tc.send(meth, *args, &blk)
91
+ end
89
92
 
90
- def StartProcess(executable, parameter, timeout)
91
- shell = WIN32OLE.new('WScript.Shell')
92
- shell.Run("#{executable} \"#{parameter}\"")
93
+ def StartProcess(executable, parameter, timeout)
94
+ shell = WIN32OLE.new('WScript.Shell')
95
+ shell.Run("#{executable} \"#{parameter}\"")
93
96
 
94
- processName = executable.split(/[\/\\]/).last.split(/\./).first
95
- sys = @tc.GetObjectByName("Sys")
96
- x = Now + timeout
97
+ processName = executable.split(/[\/\\]/).last.split(/\./).first
98
+ sys = @tc.GetObjectByName("Sys")
99
+ x = Now + timeout
97
100
 
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)
101
+ begin
102
+ process = sys.Find("ProcessName", processName)
103
+ end while(!process.Exists && Now < x)
104
+ return process
105
+ end
106
+
107
+ def LaunchIe(url, timeout)
108
+ executable = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
109
+ StartProcess(executable, url, timeout)
110
+ end
107
111
  end
108
112
  end
109
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tc_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: