sapphire 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/bin/sapphire +0 -0
  2. data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +4 -4
  3. data/lib/sapphire/DSL/Browser/Create.rb +10 -10
  4. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +20 -20
  5. data/lib/sapphire/DSL/Browser/Fluff/By.rb +10 -10
  6. data/lib/sapphire/DSL/Browser/Fluff/To.rb +10 -10
  7. data/lib/sapphire/DSL/Browser/Fluff/With.rb +10 -10
  8. data/lib/sapphire/DSL/Browser/Nouns/Browser.rb +17 -17
  9. data/lib/sapphire/DSL/Browser/Nouns/Enter.rb +10 -10
  10. data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
  11. data/lib/sapphire/DSL/Browser/Verbs/Accept.rb +8 -8
  12. data/lib/sapphire/DSL/Browser/Verbs/Check.rb +10 -10
  13. data/lib/sapphire/DSL/Browser/Verbs/Clear.rb +8 -8
  14. data/lib/sapphire/DSL/Browser/Verbs/Click.rb +10 -10
  15. data/lib/sapphire/DSL/Browser/Verbs/Compare.rb +18 -18
  16. data/lib/sapphire/DSL/Browser/Verbs/Complete.rb +13 -13
  17. data/lib/sapphire/DSL/Browser/Verbs/Exists.rb +16 -16
  18. data/lib/sapphire/DSL/Browser/Verbs/Exit.rb +11 -11
  19. data/lib/sapphire/DSL/Browser/Verbs/MouseOver.rb +10 -10
  20. data/lib/sapphire/DSL/Browser/Verbs/Navigate.rb +10 -10
  21. data/lib/sapphire/DSL/Browser/Verbs/Press.rb +8 -8
  22. data/lib/sapphire/DSL/Browser/Verbs/Reload.rb +11 -11
  23. data/lib/sapphire/DSL/Browser/Verbs/Set.rb +10 -10
  24. data/lib/sapphire/DSL/Browser/Verbs/Uncheck.rb +10 -10
  25. data/lib/sapphire/DSL/Comparisons/CheckedComparison.rb +17 -17
  26. data/lib/sapphire/DSL/Comparisons/Comparison.rb +50 -50
  27. data/lib/sapphire/DSL/Comparisons/ContainsComparison.rb +17 -17
  28. data/lib/sapphire/DSL/Comparisons/DifferComparison.rb +17 -17
  29. data/lib/sapphire/DSL/Comparisons/EqualsComparison.rb +16 -16
  30. data/lib/sapphire/DSL/Comparisons/NotComparison.rb +20 -20
  31. data/lib/sapphire/DSL/Comparisons/SelectedComparison.rb +17 -17
  32. data/lib/sapphire/DSL/Comparisons/StartsWithComparison.rb +17 -17
  33. data/lib/sapphire/DSL/Comparisons/VisibleComparison.rb +17 -17
  34. data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
  35. data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
  36. data/lib/sapphire/DSL/Configuration/Use.rb +18 -18
  37. data/lib/sapphire/DSL/Data/Find.rb +10 -10
  38. data/lib/sapphire/DSL/Data/GetPageField.rb +13 -13
  39. data/lib/sapphire/DSL/Data/Verify.rb +10 -10
  40. data/lib/sapphire/DSL/Evaluations/Evaluation.rb +1 -0
  41. data/lib/sapphire/DSL/Evaluations/FieldNotDefinedEvaluation.rb +20 -20
  42. data/lib/sapphire/DSL/Evaluations/FieldNotFoundEvaluation.rb +22 -22
  43. data/lib/sapphire/DSL/Evaluators/Contain.rb +10 -10
  44. data/lib/sapphire/DSL/Evaluators/Count.rb +8 -8
  45. data/lib/sapphire/DSL/Evaluators/Differ.rb +10 -10
  46. data/lib/sapphire/DSL/Evaluators/Exist.rb +9 -9
  47. data/lib/sapphire/DSL/Evaluators/In.rb +10 -10
  48. data/lib/sapphire/DSL/Evaluators/Selected.rb +10 -10
  49. data/lib/sapphire/DSL/Evaluators/Show.rb +10 -10
  50. data/lib/sapphire/DSL/Evaluators/Transition.rb +10 -10
  51. data/lib/sapphire/DSL/Evaluators/Validate.rb +8 -8
  52. data/lib/sapphire/DSL/Scenarios/Is.rb +9 -9
  53. data/lib/sapphire/DSL/Scenarios/Pending.rb +28 -28
  54. data/lib/sapphire/DSL/Scenarios/and.rb +25 -25
  55. data/lib/sapphire/DSL/Scenarios/dsl.rb +59 -59
  56. data/lib/sapphire/DSL/Scenarios/runner.rb +40 -40
  57. data/lib/sapphire/Data.rb +1 -1
  58. data/lib/sapphire/DataAbstractions/Database.rb +57 -57
  59. data/lib/sapphire/DataAbstractions/Query.rb +20 -20
  60. data/lib/sapphire/Extensions/Hash.rb +112 -112
  61. data/lib/sapphire/Extensions/Numeric.rb +6 -6
  62. data/lib/sapphire/JobAbstractions/Job.rb +32 -32
  63. data/lib/sapphire/Plugins/Debugging/VerboseObserver.rb +36 -35
  64. data/lib/sapphire/Plugins/Highlighters/Highlighter.rb +40 -39
  65. data/lib/sapphire/Plugins/Plugin.rb +20 -20
  66. data/lib/sapphire/TeamCity.rb +10 -10
  67. data/lib/sapphire/Testing.rb +3 -3
  68. data/lib/sapphire/Testing/RakeTask.rb +108 -108
  69. data/lib/sapphire/Testing/ResultList.rb +18 -18
  70. data/lib/sapphire/Testing/ScenarioResult.rb +36 -36
  71. data/lib/sapphire/Testing/TestResult.rb +21 -21
  72. data/lib/sapphire/Testing/TestRunnerAdapter.rb +85 -85
  73. data/lib/sapphire/UI/ProcessBuilder.rb +173 -173
  74. data/lib/sapphire/Virtualization.rb +7 -7
  75. data/lib/sapphire/Web.rb +2 -2
  76. data/lib/sapphire/WebAbstractions/Controls/AlertBox.rb +20 -20
  77. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +1 -1
  78. data/lib/sapphire/WebAbstractions/Controls/Button.rb +7 -7
  79. data/lib/sapphire/WebAbstractions/Controls/Date.rb +11 -11
  80. data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
  81. data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
  82. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +1 -1
  83. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +1 -1
  84. data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
  85. data/lib/sapphire/version.rb +1 -1
  86. metadata +24 -9
@@ -1,21 +1,21 @@
1
- module Sapphire
2
- module DataAbstractions
3
- module Query
4
- def Execute(block)
5
- x = self.Database.new
6
-
7
- x.Open $config[x.Connection]
8
- y = ""
9
- y = AppConfig.Current.SqlPath if AppConfig.Current
10
- path = File.expand_path(y + self.Script, __FILE__)
11
- file = File.open(path)
12
- contents = file.read
13
- self.Tokenize(contents)
14
-
15
- results = x.query(contents)
16
- block.call results
17
- x.close
18
- end
19
- end
20
- end
1
+ module Sapphire
2
+ module DataAbstractions
3
+ module Query
4
+ def Execute(block)
5
+ x = self.Database.new
6
+
7
+ x.Open $config[x.Connection]
8
+ y = ""
9
+ y = AppConfig.Current.SqlPath if AppConfig.Current
10
+ path = File.expand_path(y + self.Script, __FILE__)
11
+ file = File.open(path)
12
+ contents = file.read
13
+ self.Tokenize(contents)
14
+
15
+ results = x.query(contents)
16
+ block.call results
17
+ x.close
18
+ end
19
+ end
20
+ end
21
21
  end
@@ -1,113 +1,113 @@
1
- class Hash < Object
2
-
3
- def Set(hash)
4
- hash.keys.first.Set(hash)
5
- end
6
-
7
- def For(item)
8
- {item => GetPageField(item).Text}
9
- end
10
-
11
- def Examine(item, comparator, &block)
12
-
13
- flip = false
14
- key = GetKey(item) do |item| item.keys.first end
15
-
16
- return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key and !Parameters.instance.Contains key
17
-
18
- field = $page.Get(key) if $page.Contains key
19
-
20
- if(field.nil?)
21
- key1 = GetKey(item) do |item| item[item.keys.first] end
22
- if $page.Contains key1
23
- field = $page.Get(key1)
24
- flip = true
25
- end
26
- end
27
-
28
- return Fix(Evaluation.new(Parameter(key), item.first[key]), comparator) if Parameters.instance.Contains(key) and field.nil?
29
-
30
- return FieldNotFoundEvaluation.new(key, $page, "selenium could not find the field") if field == nil
31
- evaluation = field.Evaluate(key, item, comparator, block)
32
-
33
- if(flip)
34
- left = evaluation.left
35
- right = evaluation.right
36
-
37
- evaluation.right = left
38
- evaluation.left = right
39
- end
40
-
41
-
42
- return Fix(evaluation, comparator)
43
- end
44
-
45
- def GetKey(item, &block)
46
- return block.call(item.first) if item.first.is_a? Hash
47
- return item.first.first if item.first.is_a? Array
48
- end
49
-
50
- def Show(item, comparator)
51
- Examine(item, comparator) do |field, value|
52
- field.Equals(value, comparator)
53
- end
54
- end
55
-
56
- def AltText(item, comparator)
57
- Examine(item, comparator) do |field, value|
58
- field.AltText(value, comparator)
59
- end
60
- end
61
-
62
- def Source(item, comparator)
63
- Examine(item, comparator) do |field, value|
64
- field.Source(value, comparator)
65
- end
66
- end
67
-
68
- def Contain(item, comparator)
69
- Examine(item, comparator) do |field, value|
70
- field.Contain(value)
71
- end
72
- end
73
-
74
- def Count(item, comparator)
75
- Examine(item, comparator) do |field, value|
76
- field.Count(value)
77
- end
78
- end
79
-
80
- def In(item, comparator)
81
- Examine(item, comparator) do |field, value|
82
- field.In(value, comparator)
83
- end
84
- end
85
-
86
-
87
- def Validate(hash, comparator)
88
- Fix(Evaluation.new(hash.keys.first.to_s, hash[hash.keys.first].to_s), comparator)
89
- end
90
-
91
- def Fix(evaluation, comparator)
92
- comparator = comparator.Create(evaluation)
93
- comparator
94
- end
95
-
96
- def Using(items)
97
- $matrices ||= {}
98
-
99
- master_array = []
100
- master_array = $matrices[$matrix_variable] if $matrices.has_key? $matrix_variable
101
-
102
- array = []
103
-
104
- items.keys.each do |key|
105
- array << Proc.new { Parameter key => items[key] }
106
- end
107
-
108
- master_array << array
109
-
110
- $matrices.merge! $matrix_variable => master_array
111
- end
112
-
1
+ class Hash < Object
2
+
3
+ def Set(hash)
4
+ hash.keys.first.Set(hash)
5
+ end
6
+
7
+ def For(item)
8
+ {item => GetPageField(item).Text}
9
+ end
10
+
11
+ def Examine(item, comparator, &block)
12
+
13
+ flip = false
14
+ key = GetKey(item) do |item| item.keys.first end
15
+
16
+ return FieldNotDefinedEvaluation.new(key, $page) if !$page.Contains key and !Parameters.instance.Contains key
17
+
18
+ field = $page.Get(key) if $page.Contains key
19
+
20
+ if(field.nil?)
21
+ key1 = GetKey(item) do |item| item[item.keys.first] end
22
+ if $page.Contains key1
23
+ field = $page.Get(key1)
24
+ flip = true
25
+ end
26
+ end
27
+
28
+ return Fix(Evaluation.new(Parameter(key), item.first[key]), comparator) if Parameters.instance.Contains(key) and field.nil?
29
+
30
+ return FieldNotFoundEvaluation.new(key, $page, "selenium could not find the field") if field == nil
31
+ evaluation = field.Evaluate(key, item, comparator, block)
32
+
33
+ if(flip)
34
+ left = evaluation.left
35
+ right = evaluation.right
36
+
37
+ evaluation.right = left
38
+ evaluation.left = right
39
+ end
40
+
41
+
42
+ return Fix(evaluation, comparator)
43
+ end
44
+
45
+ def GetKey(item, &block)
46
+ return block.call(item.first) if item.first.is_a? Hash
47
+ return item.first.first if item.first.is_a? Array
48
+ end
49
+
50
+ def Show(item, comparator)
51
+ Examine(item, comparator) do |field, value|
52
+ field.Equals(value, comparator)
53
+ end
54
+ end
55
+
56
+ def AltText(item, comparator)
57
+ Examine(item, comparator) do |field, value|
58
+ field.AltText(value, comparator)
59
+ end
60
+ end
61
+
62
+ def Source(item, comparator)
63
+ Examine(item, comparator) do |field, value|
64
+ field.Source(value, comparator)
65
+ end
66
+ end
67
+
68
+ def Contain(item, comparator)
69
+ Examine(item, comparator) do |field, value|
70
+ field.Contain(value)
71
+ end
72
+ end
73
+
74
+ def Count(item, comparator)
75
+ Examine(item, comparator) do |field, value|
76
+ field.Count(value)
77
+ end
78
+ end
79
+
80
+ def In(item, comparator)
81
+ Examine(item, comparator) do |field, value|
82
+ field.In(value, comparator)
83
+ end
84
+ end
85
+
86
+
87
+ def Validate(hash, comparator)
88
+ Fix(Evaluation.new(hash.keys.first.to_s, hash[hash.keys.first].to_s), comparator)
89
+ end
90
+
91
+ def Fix(evaluation, comparator)
92
+ comparator = comparator.Create(evaluation)
93
+ comparator
94
+ end
95
+
96
+ def Using(items)
97
+ $matrices ||= {}
98
+
99
+ master_array = []
100
+ master_array = $matrices[$matrix_variable] if $matrices.has_key? $matrix_variable
101
+
102
+ array = []
103
+
104
+ items.keys.each do |key|
105
+ array << Proc.new { Parameter key => items[key] }
106
+ end
107
+
108
+ master_array << array
109
+
110
+ $matrices.merge! $matrix_variable => master_array
111
+ end
112
+
113
113
  end
@@ -1,7 +1,7 @@
1
- class Numeric < Object
2
-
3
- def Wait
4
- sleep(self)
5
- end
6
-
1
+ class Numeric < Object
2
+
3
+ def Wait
4
+ sleep(self)
5
+ end
6
+
7
7
  end
@@ -1,32 +1,32 @@
1
- module Sapphire
2
- module JobAbstractions
3
- class Job
4
-
5
- def Server
6
- return ""
7
- end
8
-
9
- def User
10
- return ""
11
- end
12
-
13
- def Password
14
- return ""
15
- end
16
-
17
- def Path
18
- return ""
19
- end
20
-
21
- def PsExecPath
22
- return ""
23
- end
24
-
25
- def Arg
26
- return nil
27
- end
28
-
29
- end
30
- end
31
- end
32
-
1
+ module Sapphire
2
+ module JobAbstractions
3
+ class Job
4
+
5
+ def Server
6
+ return ""
7
+ end
8
+
9
+ def User
10
+ return ""
11
+ end
12
+
13
+ def Password
14
+ return ""
15
+ end
16
+
17
+ def Path
18
+ return ""
19
+ end
20
+
21
+ def PsExecPath
22
+ return ""
23
+ end
24
+
25
+ def Arg
26
+ return nil
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+
@@ -1,36 +1,37 @@
1
- module Sapphire
2
- module Plugins
3
-
4
- class VerbosePlugin < Plugin
5
-
6
- def initialize
7
-
8
- observes :class => :all,
9
- :method => :all
10
-
11
- end
12
-
13
- def Before(instance, method, args)
14
- puts "before #{method} on #{instance}" if ENV["verbose"] == "true"
15
- end
16
-
17
- def After(instance, method, args)
18
- puts "after" if ENV["verbose"] == "true"
19
- end
20
-
21
- def OnSuccess(instance, method, args)
22
- puts "success" if ENV["verbose"] == "true"
23
- end
24
-
25
- def OnFailure(instance, method, exception, args)
26
- puts "failure" if ENV["verbose"] == "true"
27
- end
28
-
29
- #def self.IsObserver()
30
- # true
31
- #end
32
-
33
- end
34
-
35
- end
1
+ module Sapphire
2
+ module Plugins
3
+
4
+ class VerbosePlugin < Plugin
5
+
6
+ def initialize
7
+
8
+ observes :class => :all,
9
+ :method => :all
10
+
11
+ end
12
+
13
+ def Before(instance, method, args)
14
+ puts "before #{method} on #{instance}" if ENV["verbose"] == "true"
15
+ end
16
+
17
+ def After(instance, method, args)
18
+ puts "after" if ENV["verbose"] == "true"
19
+ end
20
+
21
+ def OnSuccess(instance, method, args)
22
+ puts "success" if ENV["verbose"] == "true"
23
+ end
24
+
25
+ def OnFailure(instance, method, exception, args)
26
+ puts "failure" if ENV["verbose"] == "true"
27
+ end
28
+
29
+ def self.IsObserver()
30
+ true
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
36
37
  end
@@ -1,40 +1,41 @@
1
- module Sapphire
2
- module Plugins
3
-
4
- class Highlighter < Plugin
5
-
6
- def initialize
7
-
8
- observes :class => WebAbstractions::RubySeleniumWebDriver,
9
- :method => :FindElement
10
-
11
- end
12
-
13
- def Before(instance, method, args)
14
- return if ENV["highlighter"] != "true"
15
-
16
- discriminator = args[0]
17
- selector = args[1]
18
-
19
- begin
20
- if(discriminator == :id)
21
- instance.ExecuteScript("document.getElementById('#{selector}').style.backgroundColor = '#FFF467'; ")
22
- elsif (discriminator == :name )
23
- instance.ExecuteScript("document.getElementByName('#{selector}').style.backgroundColor = '#FFF467'; ")
24
- elsif (discriminator == :xpath)
25
- instance.ExecuteScript("document.evaluate( '#{selector}', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.backgroundColor = '#FFF467'; ")
26
- end
27
-
28
- rescue
29
- end
30
-
31
- end
32
-
33
- def self.IsObserver()
34
- true
35
- end
36
-
37
- end
38
-
39
- end
1
+ module Sapphire
2
+ module Plugins
3
+
4
+ class Highlighter < Plugin
5
+
6
+ def initialize
7
+
8
+ observes :class => WebAbstractions::RubySeleniumWebDriver,
9
+ :method => :FindElement
10
+
11
+ end
12
+
13
+ def Before(instance, method, args)
14
+ return if ENV["highlighter"] != "true"
15
+
16
+ discriminator = args[0]
17
+ selector = args[1]
18
+
19
+ begin
20
+ if(discriminator == :id)
21
+ instance.ExecuteScript("document.getElementById('#{selector}').style.backgroundColor = '#FFF467'; ")
22
+ elsif (discriminator == :name )
23
+ instance.ExecuteScript("document.getElementByName('#{selector}').style.backgroundColor = '#FFF467'; ")
24
+ elsif (discriminator == :xpath)
25
+ instance.ExecuteScript("document.evaluate( '#{selector}', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.backgroundColor = '#FFF467'; ")
26
+ end
27
+
28
+ rescue
29
+ end
30
+
31
+ end
32
+
33
+ def self.IsObserver()
34
+ true
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
40
41
  end