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
data/lib/sapphire.rb CHANGED
@@ -9,10 +9,10 @@ require 'Forwardable'
9
9
  require 'colorize'
10
10
 
11
11
  require 'sapphire/Adapters'
12
- require 'sapphire/Strategies'
13
12
  require 'sapphire/Testing'
14
13
  require 'sapphire/Web'
15
14
  require 'sapphire/DSL'
15
+ require 'sapphire/Extensions'
16
16
  require 'sapphire/CommandLine'
17
17
  require 'sapphire/Configuration'
18
18
  require 'sapphire/Data'
@@ -21,12 +21,13 @@ require 'sapphire/TeamCity'
21
21
 
22
22
  module Sapphire
23
23
  module Sapphire
24
- include DSL::Strategies
24
+ include DSL
25
25
  include DSL::Scenarios
26
26
  include DSL::Browser
27
27
  include DSL::Configuration
28
28
  include DSL::Data
29
29
  include DSL::TestPlans
30
+ include DSL::Events
30
31
  include Configuration::AttrMethods
31
32
  include Configuration
32
33
  include DataAbstractions
@@ -33,6 +33,19 @@ module Sapphire
33
33
  self.browser.switch_to.window(self.browser.window_handles[0])
34
34
  end
35
35
 
36
+ def FindAlert()
37
+ begin
38
+ return self.browser.switch_to.alert
39
+ rescue
40
+ return nil
41
+ end
42
+ end
43
+
44
+ def AlertShown()
45
+ alert = self.FindAlert()
46
+ return alert != nil
47
+ end
48
+
36
49
  def ClosePopup
37
50
  self.browser.switch_to.window(self.browser.window_handles.last)
38
51
  self.browser.close
@@ -58,14 +71,13 @@ module Sapphire
58
71
 
59
72
  def NavigateTo(page)
60
73
  if(page.is_a? Class)
61
- nav = page.new
74
+ $page = page.new
62
75
  else
63
- nav = page
76
+ $page = page
64
77
  end
65
78
 
66
- self.browser.get "https://" + nav.Url
67
- nav.Init
68
- nav
79
+ self.browser.get $page.Url
80
+ $page.Init
69
81
  end
70
82
 
71
83
  def CurrentUrl
@@ -81,33 +93,38 @@ module Sapphire
81
93
  self.browser.get self.CurrentUrl
82
94
  end
83
95
 
84
- def ShouldNavigateTo(page)
96
+ def ShouldNavigateTo(page, comparator)
85
97
  if(page.is_a? Class)
86
- nav = page.new
98
+ $page = page.new
87
99
  else
88
- nav = page
100
+ $page = page
89
101
  end
90
102
 
103
+ $page.Init
104
+
91
105
  wait = Selenium::WebDriver::Wait.new(:timeout => 20)
92
106
  begin
93
- found = wait.until {
94
- x = self.CurrentUrl.upcase.start_with?("HTTP://" + nav.Url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + nav.Url.upcase)
95
- if(x == false)
96
- nav.AlternateUrls.each do |url|
97
- if( x == false)
98
- x = self.CurrentUrl.upcase.start_with?("HTTP://" + url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + url.upcase)
107
+ item = wait.until {
108
+ x = self.CurrentUrl.upcase.start_with?($page.Url.upcase)
109
+ y = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, $page.Url.upcase))
110
+ if(comparator.Compare(x == false, true))
111
+ $page.AlternateUrls.each do |url|
112
+ if(comparator.Compare(x == false, true))
113
+ x = self.CurrentUrl.upcase.start_with?(url.upcase)
114
+ y = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, url.upcase))
99
115
  end
100
116
  end
101
117
  end
102
- x
118
+
119
+ return y if comparator.Compare(x == true, true)
103
120
  }
104
121
  rescue
105
- temp = Evaluation.new(self.CurrentUrl, nav.Url)
106
- return temp, nav
122
+ temp = StartsWithComparison.new(Evaluation.new(self.CurrentUrl, $page.Url))
123
+ return temp
107
124
  end
108
125
 
109
- temp = Evaluation.new(found, true)
110
- return temp, nav
126
+ temp = item
127
+ return temp
111
128
  end
112
129
 
113
130
  def Run(background)
@@ -115,24 +132,20 @@ module Sapphire
115
132
  scenario.Run
116
133
  end
117
134
 
118
- def ShouldShow(page)
119
- self.ShouldNavigateTo page
120
- end
121
-
122
- def ShouldTransitionTo(url)
135
+ def ShouldTransitionTo(url, comparator)
123
136
  if(url.instance_of?(String))
124
- temp = Evaluation.new(self.CurrentUrl.upcase.start_with?("HTTP://" + url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + url.upcase), true)
137
+ temp = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, url.upcase))
125
138
  @rootUrl = url
126
139
  else
127
140
  x = url.new().Url
128
- temp = Evaluation.new(self.CurrentUrl.upcase.start_with?("HTTP://" + x.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + x.upcase), true)
141
+ temp = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, x.upcase))
129
142
  @rootUrl = x
130
143
  end
131
144
 
132
145
  return temp
133
146
  end
134
147
 
135
- def FindItem(array)
148
+ def FindItem(array, comparator = nil)
136
149
  masterWait = Selenium::WebDriver::Wait.new(:timeout => 5)
137
150
 
138
151
  element = masterWait.until {
@@ -150,13 +163,16 @@ module Sapphire
150
163
  x = self.FindElement item[0], item[1] if item.is_a? Array
151
164
 
152
165
  return x if x != nil
166
+ return x if comparator.Compare(x != nil, true) if comparator != nil
153
167
 
154
168
  end if array.is_a? Array
155
169
 
156
170
  x = self.FindElement array.keys.first, array.fetch(array.keys.first) if array.is_a? Hash
157
171
  return x if x != nil
172
+ return x if comparator.Compare(x != nil, true) if comparator != nil
158
173
  }
159
174
  return element if element != nil
175
+ return element if comparator.Compare(element != nil, true) if comparator != nil
160
176
  raise "Could not find control for array: " + array.to_s
161
177
  end
162
178
 
@@ -11,7 +11,7 @@ module Sapphire
11
11
  end
12
12
 
13
13
  def self.Current
14
- @@instance
14
+ @@instance if $config
15
15
  end
16
16
 
17
17
  def Browser
data/lib/sapphire/DSL.rb CHANGED
@@ -1,10 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) +'/DSL/Evaluators/Evaluator.rb', __FILE__)
2
+ require File.expand_path(File.dirname(__FILE__) +'/DSL/Comparisons/Comparison.rb', __FILE__)
3
+ Dir[File.dirname(__FILE__) + '/DSL/Evaluators/*.rb'].each {|file| require file }
4
+ Dir[File.dirname(__FILE__) + '/DSL/Comparisons/*.rb'].each {|file| require file }
5
+ Dir[File.dirname(__FILE__) + '/DSL/Evaluations/*.rb'].each {|file| require file }
1
6
  Dir[File.dirname(__FILE__) + '/DSL/TestPlans/*.rb'].each {|file| require file }
2
7
  Dir[File.dirname(__FILE__) + '/DSL/Browser/*.rb'].each {|file| require file }
3
8
  Dir[File.dirname(__FILE__) + '/DSL/Browser/Fluff/*.rb'].each {|file| require file }
4
- Dir[File.dirname(__FILE__) + '/DSL/Browser/Extensions/*.rb'].each {|file| require file }
5
9
  Dir[File.dirname(__FILE__) + '/DSL/Browser/Nouns/*.rb'].each {|file| require file }
6
10
  Dir[File.dirname(__FILE__) + '/DSL/Browser/Verbs/*.rb'].each {|file| require file }
7
11
  Dir[File.dirname(__FILE__) + '/DSL/Browser/Keys/*.rb'].each {|file| require file }
8
12
  Dir[File.dirname(__FILE__) + '/DSL/Configuration/*.rb'].each {|file| require file }
9
13
  Dir[File.dirname(__FILE__) + '/DSL/Data/*.rb'].each {|file| require file }
10
14
  Dir[File.dirname(__FILE__) + '/DSL/Scenarios/*.rb'].each {|file| require file }
15
+ Dir[File.dirname(__FILE__) + '/DSL/Events/*.rb'].each {|file| require file }
@@ -1,32 +1,18 @@
1
1
  module Sapphire
2
2
  module DSL
3
3
  module Browser
4
- def ExecuteHashAgainstControl(hash, page, &block)
4
+ def ExecuteHashAgainstControl(hash, &block)
5
5
  hash.keys.each do |key|
6
- page.fields.each do |field|
7
- field.keys.each do |field_key|
8
- if(field_key == key)
9
- block.call(field[field_key], hash[key])
10
- return
11
- end
12
- end
13
- end
6
+ return block.call($page.Get(key), hash[key]) if($page.Contains key)
14
7
  end
15
8
 
16
- raise "cannot find control matching " + hash.to_s + " for page " + @page.to_s
9
+ raise "Cannot find control matching " + hash.to_s + " for page " + $page.to_s
17
10
  end
18
11
 
19
- def ExecuteAgainstControl(item, page, &block)
20
- page.fields.each do |field|
21
- field.keys.each do |field_key|
22
- if(field_key == item)
23
- block.call(field[field_key], item)
24
- return
25
- end
26
- end
27
- end
12
+ def ExecuteAgainstControl(item, &block)
13
+ return block.call($page.Get(item), item) if($page.Contains item)
28
14
 
29
- raise "Cannot find controls matching: " + item + "for page " + @page.to_s
15
+ raise "Cannot find controls matching: " + item.to_s + "for page " + $page.to_s
30
16
  end
31
17
  end
32
18
  end
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Be(item)
5
+ item
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,8 +1,8 @@
1
1
  module Sapphire
2
2
  module DSL
3
3
  module Browser
4
- def By(value, compare1, compare2)
5
- return value, compare1, compare2
4
+ def By(value)
5
+ value
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Have(item)
5
+ item
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,8 +1,8 @@
1
1
  module Sapphire
2
2
  module DSL
3
3
  module Browser
4
- def To(url)
5
- url
4
+ def To(item)
5
+ item
6
6
  end
7
7
  end
8
8
  end
@@ -1,10 +1,9 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def For(item)
5
- {item => GetPageField(item).Text}
6
- end
7
- end
8
- end
9
- end
10
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def For(item)
5
+ {item => GetPageField(item).Text}
6
+ end
7
+ end
8
+ end
9
+ end
@@ -4,11 +4,11 @@ module Sapphire
4
4
  class Browser
5
5
  def Close
6
6
  sleep(2)
7
- $browser.Close
7
+ $driver.Close
8
8
  end
9
9
 
10
10
  def Switch
11
- $browser.Switch
11
+ $driver.Switch
12
12
  end
13
13
  end
14
14
  end
@@ -1,24 +1,42 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Day(value, compare1, compare2)
5
- Day.new(value, compare1, compare2)
6
- end
7
-
8
- class Day
9
-
10
- def initialize(value, compare1, compare2)
11
- @value = value
12
- @compare1 = compare1
13
- @compare2 = compare2
14
- end
15
-
16
- def Differ()
17
- return (@compare1 + @value) == @compare2
18
- end
19
-
20
- end
21
- end
22
- end
23
- end
24
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Day(value)
5
+ day = Day.new(value, $compare1, $compare2)
6
+ $compare1 = nil
7
+ $compare2 = nil
8
+ return day
9
+ end
10
+
11
+ class Day
12
+
13
+ def initialize(value, compare1, compare2)
14
+ @value = value
15
+ if(compare1.is_a?(String))
16
+ @compare1 = Date.parse(compare1)
17
+ else
18
+ @compare1 = compare1
19
+ end
20
+
21
+ if(compare2.is_a?(String))
22
+ @compare2 = Date.parse(compare2)
23
+ else
24
+ @compare2 = compare2
25
+ end
26
+ end
27
+
28
+ def Differ(comparator)
29
+ return Fix(DifferComparison.new(Evaluation.new(@compare1 + @value, @compare2)), comparator)
30
+ end
31
+
32
+ def Fix(evaluation, comparator)
33
+ comparator = comparator.Create(evaluation)
34
+
35
+ comparator
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
42
+
@@ -3,7 +3,7 @@ module Sapphire
3
3
  module Browser
4
4
  class Enter
5
5
  def Press
6
- $browser.Type("\n")
6
+ $driver.Type("\n")
7
7
  end
8
8
  end
9
9
  end
@@ -1,24 +1,42 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Month(value, compare1, compare2)
5
- Month.new(value, compare1, compare2)
6
- end
7
-
8
- class Month
9
-
10
- def initialize(value, compare1, compare2)
11
- @value = value
12
- @compare1 = compare1
13
- @compare2 = compare2
14
- end
15
-
16
- def Differ()
17
- return (@compare1 >> @value) == @compare2
18
- end
19
-
20
- end
21
- end
22
- end
23
- end
24
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Month(value)
5
+ month = Month.new(value, $compare1, $compare2)
6
+ $compare1 = nil
7
+ $compare2 = nil
8
+ return month
9
+ end
10
+
11
+ class Month
12
+
13
+ def initialize(value, compare1, compare2)
14
+ @value = value
15
+ if(compare1.is_a?(String))
16
+ @compare1 = Date.parse(compare1)
17
+ else
18
+ @compare1 = compare1
19
+ end
20
+
21
+ if(compare2.is_a?(String))
22
+ @compare2 = Date.parse(compare2)
23
+ else
24
+ @compare2 = compare2
25
+ end
26
+ end
27
+
28
+ def Differ(comparator)
29
+ return Fix(DifferComparison.new(Evaluation.new(@compare1 >> @value, @compare2)), comparator)
30
+ end
31
+
32
+ def Fix(evaluation, comparator)
33
+ comparator = comparator.Create(evaluation)
34
+
35
+ comparator
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
42
+