sapphire 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +190 -190
  2. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +34 -45
  3. data/lib/sapphire/DSL/Browser/Extensions/Class.rb +29 -0
  4. data/lib/sapphire/DSL/Browser/Extensions/Hash.rb +11 -0
  5. data/lib/sapphire/DSL/Browser/Extensions/Numeric.rb +7 -0
  6. data/lib/sapphire/DSL/Browser/Extensions/Symbol.rb +37 -0
  7. data/lib/sapphire/DSL/Browser/{By.rb → Fluff/By.rb} +10 -10
  8. data/lib/sapphire/DSL/Browser/{To.rb → Fluff/To.rb} +10 -10
  9. data/lib/sapphire/DSL/Browser/{With.rb → Fluff/With.rb} +10 -10
  10. data/lib/sapphire/DSL/Browser/For.rb +10 -10
  11. data/lib/sapphire/DSL/Browser/{AlertBox.rb → Nouns/AlertBox.rb} +14 -14
  12. data/lib/sapphire/DSL/Browser/{Browser.rb → Nouns/Browser.rb} +17 -17
  13. data/lib/sapphire/DSL/Browser/{Day.rb → Nouns/Day.rb} +24 -24
  14. data/lib/sapphire/DSL/Browser/{Keys → Nouns}/Enter.rb +10 -10
  15. data/lib/sapphire/DSL/Browser/{Month.rb → Nouns/Month.rb} +24 -24
  16. data/lib/sapphire/DSL/Browser/{Popup.rb → Nouns/Popup.rb} +0 -0
  17. data/lib/sapphire/DSL/Browser/Should.rb +42 -42
  18. data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
  19. data/lib/sapphire/DSL/Browser/{Accept.rb → Verbs/Accept.rb} +9 -9
  20. data/lib/sapphire/DSL/Browser/Verbs/Check.rb +11 -0
  21. data/lib/sapphire/DSL/Browser/{IsHidden.rb → Verbs/Clear.rb} +9 -10
  22. data/lib/sapphire/DSL/Browser/Verbs/Click.rb +11 -0
  23. data/lib/sapphire/DSL/Browser/{Close.rb → Verbs/Close.rb} +11 -12
  24. data/lib/sapphire/DSL/Browser/{Compare.rb → Verbs/Compare.rb} +18 -18
  25. data/lib/sapphire/DSL/Browser/Verbs/Complete.rb +10 -0
  26. data/lib/sapphire/DSL/Browser/{Differ.rb → Verbs/Differ.rb} +18 -18
  27. data/lib/sapphire/DSL/Browser/{Disable.rb → Verbs/Disable.rb} +0 -0
  28. data/lib/sapphire/DSL/Browser/{Error.rb → Verbs/Error.rb} +25 -26
  29. data/lib/sapphire/DSL/Browser/{Exists.rb → Verbs/Exists.rb} +22 -22
  30. data/lib/sapphire/DSL/Browser/{Hide.rb → Verbs/Hide.rb} +25 -26
  31. data/lib/sapphire/DSL/Browser/Verbs/MouseOver.rb +11 -0
  32. data/lib/sapphire/DSL/Browser/{Navigate.rb → Verbs/Navigate.rb} +11 -11
  33. data/lib/sapphire/DSL/Browser/{Press.rb → Verbs/Press.rb} +8 -10
  34. data/lib/sapphire/DSL/Browser/{Reload.rb → Verbs/Reload.rb} +11 -11
  35. data/lib/sapphire/DSL/Browser/Verbs/Set.rb +10 -0
  36. data/lib/sapphire/DSL/Browser/{Show.rb → Verbs/Show.rb} +25 -26
  37. data/lib/sapphire/DSL/Browser/{Start.rb → Verbs/Start.rb} +16 -16
  38. data/lib/sapphire/DSL/Browser/{Switch.rb → Verbs/Switch.rb} +0 -0
  39. data/lib/sapphire/DSL/Browser/{Transition.rb → Verbs/Transition.rb} +25 -26
  40. data/lib/sapphire/DSL/Browser/Verbs/Uncheck.rb +11 -0
  41. data/lib/sapphire/DSL/Browser/{Virtually.rb → Verbs/Virtually.rb} +0 -0
  42. data/lib/sapphire/DSL/Browser/{Wait.rb → Verbs/Wait.rb} +2 -2
  43. data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
  44. data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
  45. data/lib/sapphire/DSL/Configuration/Use.rb +15 -15
  46. data/lib/sapphire/DSL/Data/Exist.rb +27 -27
  47. data/lib/sapphire/DSL/Data/Find.rb +10 -10
  48. data/lib/sapphire/DSL/Data/GetPageField.rb +17 -17
  49. data/lib/sapphire/DSL/Data/Underscore.rb +8 -8
  50. data/lib/sapphire/DSL/Data/Validate.rb +26 -26
  51. data/lib/sapphire/DSL/Data/Verify.rb +10 -10
  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/background.rb +33 -33
  56. data/lib/sapphire/DSL/Scenarios/dsl.rb +59 -59
  57. data/lib/sapphire/DSL/Scenarios/finally.rb +33 -33
  58. data/lib/sapphire/DSL/Scenarios/given.rb +57 -57
  59. data/lib/sapphire/DSL/Scenarios/runner.rb +40 -40
  60. data/lib/sapphire/DSL/Scenarios/scenario.rb +53 -53
  61. data/lib/sapphire/DSL/Scenarios/then.rb +34 -34
  62. data/lib/sapphire/DSL/Scenarios/when.rb +47 -47
  63. data/lib/sapphire/DSL.rb +10 -6
  64. data/lib/sapphire/Data.rb +1 -1
  65. data/lib/sapphire/DataAbstractions/Database.rb +57 -57
  66. data/lib/sapphire/DataAbstractions/Query.rb +19 -19
  67. data/lib/sapphire/JobAbstractions/Job.rb +32 -32
  68. data/lib/sapphire/Strategies/ClassStrategy.rb +1 -1
  69. data/lib/sapphire/Strategies/Strategy.rb +1 -2
  70. data/lib/sapphire/Strategies.rb +1 -1
  71. data/lib/sapphire/TeamCity.rb +8 -8
  72. data/lib/sapphire/Testing/Executable.rb +30 -30
  73. data/lib/sapphire/Testing/RakeTask.rb +108 -108
  74. data/lib/sapphire/Testing/ResultList.rb +18 -18
  75. data/lib/sapphire/Testing/ResultTree.rb +44 -44
  76. data/lib/sapphire/Testing/ScenarioResult.rb +36 -36
  77. data/lib/sapphire/Testing/TestResult.rb +21 -21
  78. data/lib/sapphire/Testing/TestRunnerAdapter.rb +69 -69
  79. data/lib/sapphire/Testing.rb +2 -2
  80. data/lib/sapphire/Virtualization.rb +7 -7
  81. data/lib/sapphire/Web.rb +2 -2
  82. data/lib/sapphire/WebAbstractions/Browsers/Chrome.rb +21 -21
  83. data/lib/sapphire/WebAbstractions/Browsers/FireFox.rb +22 -22
  84. data/lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb +21 -21
  85. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +58 -59
  86. data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +61 -62
  87. data/lib/sapphire/WebAbstractions/Controls/Button.rb +7 -9
  88. data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -28
  89. data/lib/sapphire/WebAbstractions/Controls/Date.rb +11 -11
  90. data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +26 -26
  91. data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
  92. data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -9
  93. data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
  94. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -18
  95. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -31
  96. data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
  97. data/lib/sapphire/version.rb +3 -3
  98. data/lib/sapphire.rb +38 -38
  99. metadata +46 -45
  100. data/lib/sapphire/DSL/Browser/Check.rb +0 -12
  101. data/lib/sapphire/DSL/Browser/Clear.rb +0 -13
  102. data/lib/sapphire/DSL/Browser/Click.rb +0 -12
  103. data/lib/sapphire/DSL/Browser/Complete.rb +0 -15
  104. data/lib/sapphire/DSL/Browser/CurrentUrl.rb +0 -11
  105. data/lib/sapphire/DSL/Browser/IsVisible.rb +0 -33
  106. data/lib/sapphire/DSL/Browser/MouseOver.rb +0 -12
  107. data/lib/sapphire/DSL/Browser/Set.rb +0 -18
  108. data/lib/sapphire/DSL/Browser/Uncheck.rb +0 -12
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Reload(item)
5
- @browser.Reload
6
- Should Show item
7
- end
8
- end
9
- end
10
- end
11
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Reload(item)
5
+ $browser.Reload
6
+ Should Show item
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,10 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Set(hash)
5
+ hash.With(:page => @page)
6
+ hash.Set hash
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,26 +1,25 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Show(item)
5
- NullModifier.new(Show.new(item, @page, @browser))
6
- end
7
-
8
- class Show
9
- def initialize(item, page, browser)
10
- @item = item
11
- @page = page
12
- @browser = browser
13
- end
14
-
15
- def ModifyWith(item)
16
- @modifier = item
17
- end
18
-
19
- def execute
20
- return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page, @browser).Show(@item, @modifier), :modifier => @modifier }
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Show(item)
5
+ NullModifier.new(Show.new(item, @page))
6
+ end
7
+
8
+ class Show
9
+ def initialize(item, page)
10
+ @item = item
11
+ @page = page
12
+ end
13
+
14
+ def ModifyWith(item)
15
+ @modifier = item
16
+ end
17
+
18
+ def execute
19
+ return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Show(@item, @modifier), :modifier => @modifier }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -1,16 +1,16 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Start(browser)
5
- if(browser == ConfigurationBrowser)
6
- @browser = AppConfig.Current.Browser
7
- else
8
- @browser = browser
9
- end
10
-
11
- @browser.SetRootUrl(@rootUrl)
12
- end
13
- end
14
- end
15
- end
16
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Start(browser)
5
+ if(browser == ConfigurationBrowser)
6
+ AppConfig.Current.Browser
7
+ else
8
+ browser.new
9
+ end
10
+
11
+ $browser.SetRootUrl(@rootUrl)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -1,26 +1,25 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
-
5
- def Transition(url)
6
- NullModifier.new(Transition.new(url, @browser))
7
- end
8
-
9
- class Transition
10
- def initialize(item, browser)
11
- @item = item
12
- @browser = browser
13
- end
14
-
15
- def ModifyWith(item)
16
- @modifier = item
17
- end
18
-
19
- def execute
20
- @modifier.Modify(@browser.ShouldTransitionTo(@item))
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+
5
+ def Transition(url)
6
+ NullModifier.new(Transition.new(url))
7
+ end
8
+
9
+ class Transition
10
+ def initialize(item)
11
+ @item = item
12
+ end
13
+
14
+ def ModifyWith(item)
15
+ @modifier = item
16
+ end
17
+
18
+ def execute
19
+ @modifier.Modify($browser.ShouldTransitionTo(@item))
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,11 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Uncheck(item)
5
+ item.With(:page => @page)
6
+ item.Uncheck
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -1,8 +1,8 @@
1
1
  module Sapphire
2
2
  module DSL
3
3
  module Browser
4
- def Wait(seconds)
5
- sleep(seconds)
4
+ def Wait(item)
5
+ item.Wait
6
6
  end
7
7
  end
8
8
  end
@@ -1,13 +1,13 @@
1
- module Sapphire
2
- module DSL
3
- module Configuration
4
- def ConfiguredBrowser(url)
5
- @rootUrl = url
6
- ConfigurationBrowser
7
- end
8
-
9
- class ConfigurationBrowser
10
- end
11
- end
12
- end
1
+ module Sapphire
2
+ module DSL
3
+ module Configuration
4
+ def ConfiguredBrowser(url)
5
+ @rootUrl = url
6
+ ConfigurationBrowser
7
+ end
8
+
9
+ class ConfigurationBrowser
10
+ end
11
+ end
12
+ end
13
13
  end
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module DSL
3
- module Configuration
4
- def configured_user
5
- $user
6
- end
7
- class ConfiguredUser
8
- end
9
- end
10
- end
1
+ module Sapphire
2
+ module DSL
3
+ module Configuration
4
+ def configured_user
5
+ $user
6
+ end
7
+ class ConfiguredUser
8
+ end
9
+ end
10
+ end
11
11
  end
@@ -1,15 +1,15 @@
1
- module Sapphire
2
- module DSL
3
- module Configuration
4
- def Use(user)
5
- if(user == ConfiguredUser)
6
- $user = AppConfig.new().User
7
- else
8
- $user = user.new
9
- end
10
- end
11
- end
12
- end
13
- end
14
-
15
-
1
+ module Sapphire
2
+ module DSL
3
+ module Configuration
4
+ def Use(user)
5
+ if(user == ConfiguredUser)
6
+ $user = AppConfig.new().User
7
+ else
8
+ $user = user.new
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+
@@ -1,27 +1,27 @@
1
- module Sapphire
2
- module DSL
3
- module Data
4
- def Exist(value)
5
- Not(Exist.new(value, @page, @browser))
6
- end
7
-
8
- class Exist
9
- def initialize(item, page, browser)
10
- @item = item
11
- @page = page
12
- @browser = browser
13
- end
14
-
15
- def ModifyWith(item)
16
- @modifier = item
17
- end
18
-
19
- def execute
20
- return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page, @browser).Exists(@item), :modifier => @modifier }
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
27
-
1
+ module Sapphire
2
+ module DSL
3
+ module Data
4
+ def Exist(value)
5
+ Not(Exist.new(value, @page))
6
+ end
7
+
8
+ class Exist
9
+ def initialize(item, page)
10
+ @item = item
11
+ @page = page
12
+ @browser = browser
13
+ end
14
+
15
+ def ModifyWith(item)
16
+ @modifier = item
17
+ end
18
+
19
+ def execute
20
+ return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Exists(@item), :modifier => @modifier }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+
@@ -1,10 +1,10 @@
1
- module Sapphire
2
- module DSL
3
- module Data
4
- def Find(query, &block)
5
- query.Execute block
6
- end
7
- end
8
- end
9
- end
10
-
1
+ module Sapphire
2
+ module DSL
3
+ module Data
4
+ def Find(query, &block)
5
+ query.Execute block
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,17 +1,17 @@
1
- module Sapphire
2
- module DSL
3
- module Data
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
13
- end
14
- end
15
- end
16
- end
17
-
1
+ module Sapphire
2
+ module DSL
3
+ module Data
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
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -1,9 +1,9 @@
1
- class String
2
- def underscore
3
- self.gsub(/::/, '/').
4
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
- tr("-", "_").
7
- downcase
8
- end
1
+ class String
2
+ def underscore
3
+ self.gsub(/::/, '/').
4
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
+ tr("-", "_").
7
+ downcase
8
+ end
9
9
  end
@@ -1,26 +1,26 @@
1
- module Sapphire
2
- module DSL
3
- module Data
4
- def Validate(hash)
5
- NullModifier.new(Validate.new(hash, @page, @browser))
6
- end
7
-
8
- class Validate
9
- def initialize(item, page, browser)
10
- @item = item
11
- @page = page
12
- @browser = browser
13
- end
14
-
15
- def ModifyWith(item)
16
- @modifier = item
17
- end
18
-
19
- def execute
20
- return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page, @browser).Validate(@item), :modifier => @modifier }
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
1
+ module Sapphire
2
+ module DSL
3
+ module Data
4
+ def Validate(hash)
5
+ NullModifier.new(Validate.new(hash, @page))
6
+ end
7
+
8
+ class Validate
9
+ def initialize(item, page)
10
+ @item = item
11
+ @page = page
12
+ @browser = browser
13
+ end
14
+
15
+ def ModifyWith(item)
16
+ @modifier = item
17
+ end
18
+
19
+ def execute
20
+ return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Validate(@item), :modifier => @modifier }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -1,10 +1,10 @@
1
- module Sapphire
2
- module DSL
3
- module Data
4
- def Verify(instance)
5
- instance.Verify
6
- end
7
- end
8
- end
9
- end
10
-
1
+ module Sapphire
2
+ module DSL
3
+ module Data
4
+ def Verify(instance)
5
+ instance.Verify
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,9 +1,9 @@
1
- module Sapphire
2
- module DSL
3
- module Scenarios
4
- def Is(item)
5
- item
6
- end
7
- end
8
- end
9
- end
1
+ module Sapphire
2
+ module DSL
3
+ module Scenarios
4
+ def Is(item)
5
+ item
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,29 +1,29 @@
1
- module Sapphire
2
- module DSL
3
- module Scenarios
4
- def Pending(text)
5
- Pending.new text
6
- end
7
-
8
- class Pending
9
-
10
- attr_reader :text
11
- attr_reader :and
12
-
13
- def initialize(text)
14
- @text = text
15
- @and = []
16
- end
17
-
18
- def add_and(text, &block)
19
- self.and << Then.new(text, &block)
20
- end
21
-
22
- def to_s
23
- self.text
24
- end
25
-
26
- end
27
- end
28
- end
1
+ module Sapphire
2
+ module DSL
3
+ module Scenarios
4
+ def Pending(text)
5
+ Pending.new text
6
+ end
7
+
8
+ class Pending
9
+
10
+ attr_reader :text
11
+ attr_reader :and
12
+
13
+ def initialize(text)
14
+ @text = text
15
+ @and = []
16
+ end
17
+
18
+ def add_and(text, &block)
19
+ self.and << Then.new(text, &block)
20
+ end
21
+
22
+ def to_s
23
+ self.text
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
29
  end
@@ -1,26 +1,26 @@
1
- require File.expand_path('../../Testing/Executable', File.dirname(__FILE__))
2
-
3
- class And
4
- include Sapphire::Testing::Executable
5
-
6
- attr_reader :text
7
- attr_reader :block
8
- attr_reader :value
9
- attr_reader :parent
10
- attr_reader :results
11
-
12
- def initialize(parent, text, &block)
13
- @block = block
14
- @text = text.to_s
15
- @value = text
16
- @parent = parent
17
- @results = []
18
- end
19
-
20
- def AddResult(result)
21
- result.item = self
22
- @results << result
23
- self.parent.results.last.AddChild(result)
24
- end
25
-
1
+ require File.expand_path('../../Testing/Executable', File.dirname(__FILE__))
2
+
3
+ class And
4
+ include Sapphire::Testing::Executable
5
+
6
+ attr_reader :text
7
+ attr_reader :block
8
+ attr_reader :value
9
+ attr_reader :parent
10
+ attr_reader :results
11
+
12
+ def initialize(parent, text, &block)
13
+ @block = block
14
+ @text = text.to_s
15
+ @value = text
16
+ @parent = parent
17
+ @results = []
18
+ end
19
+
20
+ def AddResult(result)
21
+ result.item = self
22
+ @results << result
23
+ self.parent.results.last.AddChild(result)
24
+ end
25
+
26
26
  end