sapphire 0.6.7 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/lib/sapphire.rb +3 -2
  2. data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +43 -27
  3. data/lib/sapphire/Configuration/AppConfig.rb +1 -1
  4. data/lib/sapphire/DSL.rb +6 -1
  5. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +6 -20
  6. data/lib/sapphire/DSL/Browser/Fluff/Be.rb +10 -0
  7. data/lib/sapphire/DSL/Browser/Fluff/By.rb +2 -2
  8. data/lib/sapphire/DSL/Browser/Fluff/Have.rb +10 -0
  9. data/lib/sapphire/DSL/Browser/Fluff/To.rb +2 -2
  10. data/lib/sapphire/DSL/Browser/For.rb +9 -10
  11. data/lib/sapphire/DSL/Browser/Nouns/Browser.rb +2 -2
  12. data/lib/sapphire/DSL/Browser/Nouns/Day.rb +42 -24
  13. data/lib/sapphire/DSL/Browser/Nouns/Enter.rb +1 -1
  14. data/lib/sapphire/DSL/Browser/Nouns/Month.rb +42 -24
  15. data/lib/sapphire/DSL/Browser/Nouns/Popup.rb +2 -2
  16. data/lib/sapphire/DSL/Browser/Nouns/Second.rb +42 -0
  17. data/lib/sapphire/DSL/Browser/Should.rb +1 -46
  18. data/lib/sapphire/DSL/Browser/Verbs/Accept.rb +1 -2
  19. data/lib/sapphire/DSL/Browser/Verbs/Check.rb +0 -1
  20. data/lib/sapphire/DSL/Browser/Verbs/Click.rb +0 -1
  21. data/lib/sapphire/DSL/Browser/Verbs/Compare.rb +5 -5
  22. data/lib/sapphire/DSL/Browser/Verbs/Complete.rb +2 -2
  23. data/lib/sapphire/DSL/Browser/Verbs/Disable.rb +1 -1
  24. data/lib/sapphire/DSL/Browser/Verbs/Exists.rb +6 -11
  25. data/lib/sapphire/DSL/Browser/Verbs/{Close.rb → Exit.rb} +0 -0
  26. data/lib/sapphire/DSL/Browser/Verbs/Has.rb +9 -0
  27. data/lib/sapphire/DSL/Browser/Verbs/MouseOver.rb +0 -1
  28. data/lib/sapphire/DSL/Browser/Verbs/Navigate.rb +1 -2
  29. data/lib/sapphire/DSL/Browser/Verbs/On.rb +19 -0
  30. data/lib/sapphire/DSL/Browser/Verbs/Press.rb +1 -1
  31. data/lib/sapphire/DSL/Browser/Verbs/Reload.rb +1 -1
  32. data/lib/sapphire/DSL/Browser/Verbs/Remove.rb +22 -0
  33. data/lib/sapphire/DSL/Browser/Verbs/Set.rb +1 -1
  34. data/lib/sapphire/DSL/Browser/Verbs/Start.rb +14 -16
  35. data/lib/sapphire/DSL/Browser/Verbs/Uncheck.rb +0 -1
  36. data/lib/sapphire/DSL/Comparisons/CheckedComparison.rb +17 -0
  37. data/lib/sapphire/DSL/Comparisons/Comparison.rb +34 -0
  38. data/lib/sapphire/DSL/Comparisons/ContainsComparison.rb +17 -0
  39. data/lib/sapphire/DSL/Comparisons/DifferComparison.rb +17 -0
  40. data/lib/sapphire/DSL/Comparisons/EqualsComparison.rb +16 -0
  41. data/lib/sapphire/DSL/Comparisons/NotComparison.rb +21 -0
  42. data/lib/sapphire/DSL/Comparisons/SelectedComparison.rb +17 -0
  43. data/lib/sapphire/DSL/Comparisons/StartsWithComparison.rb +17 -0
  44. data/lib/sapphire/DSL/Comparisons/VisibleComparison.rb +17 -0
  45. data/lib/sapphire/DSL/Configuration/Use.rb +3 -0
  46. data/lib/sapphire/DSL/Data/GetPageField.rb +4 -8
  47. data/lib/sapphire/DSL/Evaluations/Evaluation.rb +46 -0
  48. data/lib/sapphire/DSL/Evaluations/FieldNotDefinedEvaluation.rb +21 -0
  49. data/lib/sapphire/DSL/Evaluations/FieldNotFoundEvaluation.rb +21 -0
  50. data/lib/sapphire/DSL/Evaluators/AltText.rb +17 -0
  51. data/lib/sapphire/DSL/Evaluators/Checked.rb +17 -0
  52. data/lib/sapphire/DSL/Evaluators/Contain.rb +10 -0
  53. data/lib/sapphire/DSL/Evaluators/Count.rb +9 -0
  54. data/lib/sapphire/DSL/Evaluators/Differ.rb +10 -0
  55. data/lib/sapphire/DSL/Evaluators/Evaluator.rb +22 -0
  56. data/lib/sapphire/DSL/Evaluators/Exist.rb +9 -0
  57. data/lib/sapphire/DSL/Evaluators/In.rb +10 -0
  58. data/lib/sapphire/DSL/Evaluators/Selected.rb +10 -0
  59. data/lib/sapphire/DSL/Evaluators/Show.rb +10 -0
  60. data/lib/sapphire/DSL/Evaluators/Source.rb +17 -0
  61. data/lib/sapphire/DSL/Evaluators/Transition.rb +10 -0
  62. data/lib/sapphire/DSL/Evaluators/Validate.rb +8 -0
  63. data/lib/sapphire/DSL/Events/Causes.rb +3 -0
  64. data/lib/sapphire/DSL/Events/Event.rb +19 -0
  65. data/lib/sapphire/DSL/Events/Expect.rb +19 -0
  66. data/lib/sapphire/DSL/Scenarios/then.rb +1 -1
  67. data/lib/sapphire/DSL/Scenarios/when.rb +1 -1
  68. data/lib/sapphire/DSL/TestPlans/FileHandler.rb +7 -2
  69. data/lib/sapphire/DSL/TestPlans/PathHandler.rb +2 -1
  70. data/lib/sapphire/DataAbstractions/NonQuery.rb +2 -1
  71. data/lib/sapphire/DataAbstractions/Query.rb +2 -1
  72. data/lib/sapphire/Extensions.rb +1 -0
  73. data/lib/sapphire/{DSL/Browser/Extensions → Extensions}/Class.rb +10 -0
  74. data/lib/sapphire/Extensions/Hash.rb +85 -0
  75. data/lib/sapphire/{DSL/Browser/Extensions → Extensions}/Numeric.rb +6 -6
  76. data/lib/sapphire/Extensions/Object.rb +9 -0
  77. data/lib/sapphire/{DSL/Browser/Extensions → Extensions}/String.rb +4 -0
  78. data/lib/sapphire/Extensions/Symbol.rb +105 -0
  79. data/lib/sapphire/Sessions/Parameter.rb +36 -0
  80. data/lib/sapphire/Sessions/Storage.rb +17 -0
  81. data/lib/sapphire/UI/Functions.rb +2 -1
  82. data/lib/sapphire/UI/ProcessBuilder.rb +174 -0
  83. data/lib/sapphire/Virtualization.rb +1 -1
  84. data/lib/sapphire/WebAbstractions/Browsers/Chrome.rb +22 -21
  85. data/lib/sapphire/WebAbstractions/Browsers/FireFox.rb +24 -22
  86. data/lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb +22 -21
  87. data/lib/sapphire/WebAbstractions/Controls/AlertBox.rb +21 -0
  88. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +32 -14
  89. data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +74 -65
  90. data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +29 -28
  91. data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +59 -26
  92. data/lib/sapphire/WebAbstractions/Controls/Image.rb +10 -0
  93. data/lib/sapphire/WebAbstractions/Controls/List.rb +45 -4
  94. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +29 -18
  95. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +9 -8
  96. data/lib/sapphire/WebAbstractions/Controls/Title.rb +1 -1
  97. data/lib/sapphire/version.rb +1 -1
  98. metadata +55 -39
  99. data/lib/sapphire/Configuration/SapphireConfig.rb +0 -33
  100. data/lib/sapphire/DSL/Browser/Extensions/Hash.rb +0 -11
  101. data/lib/sapphire/DSL/Browser/Extensions/Symbol.rb +0 -37
  102. data/lib/sapphire/DSL/Browser/Not.rb +0 -39
  103. data/lib/sapphire/DSL/Browser/Nouns/AlertBox.rb +0 -15
  104. data/lib/sapphire/DSL/Browser/Verbs/Attempt.rb +0 -14
  105. data/lib/sapphire/DSL/Browser/Verbs/Contain.rb +0 -25
  106. data/lib/sapphire/DSL/Browser/Verbs/Count.rb +0 -24
  107. data/lib/sapphire/DSL/Browser/Verbs/Differ.rb +0 -19
  108. data/lib/sapphire/DSL/Browser/Verbs/Error.rb +0 -25
  109. data/lib/sapphire/DSL/Browser/Verbs/Hide.rb +0 -25
  110. data/lib/sapphire/DSL/Browser/Verbs/Show.rb +0 -25
  111. data/lib/sapphire/DSL/Browser/Verbs/Transition.rb +0 -25
  112. data/lib/sapphire/DSL/Data/Exist.rb +0 -26
  113. data/lib/sapphire/DSL/Data/Validate.rb +0 -25
  114. data/lib/sapphire/Strategies.rb +0 -2
  115. data/lib/sapphire/Strategies/ClassStrategy.rb +0 -13
  116. data/lib/sapphire/Strategies/ContainsEvaluation.rb +0 -16
  117. data/lib/sapphire/Strategies/ContainsNullModifier.rb +0 -34
  118. data/lib/sapphire/Strategies/DefaultStrategy.rb +0 -17
  119. data/lib/sapphire/Strategies/Evaluation.rb +0 -16
  120. data/lib/sapphire/Strategies/HashStrategy.rb +0 -72
  121. data/lib/sapphire/Strategies/NullModifier.rb +0 -34
  122. data/lib/sapphire/Strategies/Strategy.rb +0 -11
  123. data/lib/sapphire/Strategies/SymbolStrategy.rb +0 -59
  124. data/lib/sapphire/WebAbstractions/Controls/TableCell.rb +0 -10
@@ -0,0 +1,16 @@
1
+ module Sapphire
2
+ module DSL
3
+ class EqualsComparison < Comparison
4
+
5
+ def Compare(left, right)
6
+ return @comparator.Compare(left == right, true) if @comparator != nil
7
+ left == right
8
+ end
9
+
10
+ def Text
11
+ ""
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module Sapphire
2
+ module DSL
3
+ def Not(item)
4
+ NotComparison.new(item)
5
+ end
6
+
7
+ class NotComparison < Comparison
8
+
9
+ def Compare(left, right)
10
+ return @comparator.Compare(left != right, true) if @comparator != nil
11
+ left != right
12
+ end
13
+
14
+ def Text
15
+ return @comparator.Text + " NOT" if @comparator != nil
16
+ " NOT"
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module Sapphire
2
+ module DSL
3
+ class SelectedComparison < Comparison
4
+
5
+ def Compare(left, right)
6
+ return @comparator.Compare(left.Selected, true) if @comparator != nil
7
+ left.Selected
8
+ end
9
+
10
+ def Text
11
+ return @comparator.Text + " to be selected" if @comparator != nil
12
+ " to be selected"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Sapphire
2
+ module DSL
3
+ class StartsWithComparison < Comparison
4
+
5
+ def Compare(left, right)
6
+ return @comparator.Compare((left.start_with? right), true) if @comparator != nil
7
+ left.start_with? right
8
+ end
9
+
10
+ def Text
11
+ return @comparator.Text if @comparator != nil
12
+ ""
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Sapphire
2
+ module DSL
3
+ class VisibleComparison < Comparison
4
+
5
+ def Compare(left, right)
6
+ return @comparator.Compare(left.Visible, true) if @comparator != nil
7
+ left.Visible
8
+ end
9
+
10
+ def Text
11
+ return @comparator.Text + " to be visible" if @comparator != nil
12
+ " to be visible"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -3,6 +3,9 @@ module Sapphire
3
3
  module Configuration
4
4
  def Use(user)
5
5
  if(user == ConfiguredUser)
6
+ if AppConfig.Current.nil?
7
+ raise "No App Config defined!"
8
+ end
6
9
  $user = AppConfig.new().User
7
10
  else
8
11
  $user = user.new
@@ -2,14 +2,10 @@ module Sapphire
2
2
  module DSL
3
3
  module Data
4
4
  def GetPageField(key)
5
- @page.fields.each do |field|
6
- field.keys.each do |field_key|
7
- if(field_key == key)
8
- return field[key]
9
- end
10
- end
11
- end
12
- raise "Could not find control for: " + key + " for page " + @page.to_s
5
+
6
+ return $page.Get(key) if $page.Contains key
7
+
8
+ raise "Could not find control for: " + key + " for page " + $page.to_s
13
9
  end
14
10
  end
15
11
  end
@@ -0,0 +1,46 @@
1
+ module Sapphire
2
+ module DSL
3
+ class Evaluation
4
+
5
+ attr_reader :left
6
+ attr_reader :right
7
+
8
+ def initialize(left, right)
9
+ @left = left
10
+ @right = right
11
+ end
12
+
13
+ def Compare(left, right)
14
+ return @comparator.Compare(left, right) if @comparator != nil
15
+ EqualsComparison.new(self).Compare(left, right) if @comparator == nil
16
+ end
17
+
18
+ def CompareWith(item)
19
+ @comparator = item
20
+ end
21
+
22
+ def execute()
23
+ self.Output()
24
+ end
25
+
26
+ def Evaluate()
27
+ Compare(@left, @right)
28
+ end
29
+
30
+ def Output()
31
+
32
+ if(!Compare(@left, @right))
33
+ messages = []
34
+
35
+ messages << "expected" + @comparator.Text + ": (nil)" if @left == nil
36
+ messages << "expected" + @comparator.Text + ": " + @left.to_s if @left != nil
37
+ messages << "got: (nil)" if @right == nil
38
+ messages << "got: " + @right.to_s if @right != nil
39
+
40
+ raise ExpectationException.new(messages)
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ module Sapphire
2
+ module DSL
3
+ class FieldNotDefinedEvaluation
4
+
5
+ attr_reader :field
6
+
7
+ def initialize(field, page)
8
+ @field = field
9
+ @page = page
10
+ end
11
+
12
+ def Output()
13
+ messages = []
14
+
15
+ messages << "Cannot find control " + @field.to_s + " defined for page " + @page.to_s
16
+
17
+ raise ExpectationException.new(messages)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Sapphire
2
+ module DSL
3
+ class FieldNotFoundEvaluation
4
+
5
+ attr_reader :field
6
+
7
+ def initialize(field, page)
8
+ @field = field
9
+ @page = page
10
+ end
11
+
12
+ def Output()
13
+ messages = []
14
+
15
+ messages << "Cannot find control matching " + @field.to_s + " for page " + @page.to_s
16
+
17
+ raise ExpectationException.new(messages)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def AltText(item)
5
+ AltText.new(item)
6
+ end
7
+
8
+ class AltText < Evaluator
9
+ def execute
10
+ @comparator = EqualsComparison.new(@item) if @comparator == nil
11
+ @item.AltText(@item, @comparator)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,17 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Checked(item)
5
+ Checked.new(item)
6
+ end
7
+
8
+ class Checked < Evaluator
9
+ def execute
10
+ @comparator = EqualsComparison.new(@item) if @comparator == nil
11
+ @item.Checked(@item, @comparator)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Contain(item)
5
+ Evaluator.new(item) do |item, comparator| item.Contain(item, comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,9 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Count(item)
5
+ Evaluator.new(item) do |item, comparator| item.Count(item, comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Differ(value)
5
+ Evaluator.new(value) do |value, comparator| value.Differ(comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,22 @@
1
+ module Sapphire
2
+ module DSL
3
+ class Evaluator
4
+ def initialize(item, &block)
5
+ @item = item
6
+ @block = block
7
+ end
8
+
9
+ def CompareWith(comparator)
10
+ @comparator = comparator
11
+ @item = comparator.Create(@item)
12
+ end
13
+
14
+ def execute
15
+ @comparator = EqualsComparison.new(@item) if @comparator == nil
16
+ @block.call(@item, @comparator)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,9 @@
1
+ module Sapphire
2
+ module DSL
3
+ def Exist(value)
4
+ Evaluator.new(value) do |item, comparator| item.NotBeNil(item, comparator) end
5
+ end
6
+ end
7
+ end
8
+
9
+
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def In(item)
5
+ Evaluator.new(item) do |item, comparator| item.In(item, comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Selected(item)
5
+ Evaluator.new(item) do |item, comparator| item.Selected(item, comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Show(item)
5
+ Evaluator.new(item) do |item, comparator| item.Show(item, comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,17 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Source(item)
5
+ Source.new(item)
6
+ end
7
+
8
+ class Source < Evaluator
9
+ def execute
10
+ @comparator = EqualsComparison.new(@item) if @comparator == nil
11
+ @item.Source(@item, @comparator)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Transition(url)
5
+ Evaluator.new(url) do |item, comparator| comparator.Create($driver.ShouldTransitionTo(item, comparator)) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,8 @@
1
+ module Sapphire
2
+ module DSL
3
+ def Validate(hash)
4
+ Evaluator.new(hash) do |item, comparator| item.Validate(item, comparator) end
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1,3 @@
1
+ def Causes
2
+
3
+ end
@@ -0,0 +1,19 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Events
4
+ def Event(name, &block)
5
+ $events ||= {}
6
+ $events.merge!(name => Event.new(name, block))
7
+ end
8
+
9
+ class Event
10
+
11
+ def initialize(name, block)
12
+ @name = name
13
+ @block = block
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Events
4
+ def Expect(item)
5
+ $events ||= {}
6
+ $events.merge!(name => Event.new(name, block))
7
+ end
8
+
9
+ class Expectation
10
+
11
+ def initialize(name, block)
12
+ @name = name
13
+ @block = block
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end