sapphire 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/lib/sapphire.rb +38 -37
  2. data/lib/sapphire/Adapters.rb +1 -0
  3. data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +190 -0
  4. data/lib/sapphire/DSL.rb +6 -6
  5. data/lib/sapphire/DSL/Browser/Accept.rb +9 -9
  6. data/lib/sapphire/DSL/Browser/AlertBox.rb +14 -19
  7. data/lib/sapphire/DSL/Browser/Browser.rb +17 -17
  8. data/lib/sapphire/DSL/Browser/By.rb +10 -10
  9. data/lib/sapphire/DSL/Browser/Check.rb +12 -12
  10. data/lib/sapphire/DSL/Browser/Clear.rb +12 -12
  11. data/lib/sapphire/DSL/Browser/Click.rb +12 -12
  12. data/lib/sapphire/DSL/Browser/Close.rb +12 -12
  13. data/lib/sapphire/DSL/Browser/Compare.rb +18 -18
  14. data/lib/sapphire/DSL/Browser/Complete.rb +15 -15
  15. data/lib/sapphire/DSL/Browser/CurrentUrl.rb +11 -11
  16. data/lib/sapphire/DSL/Browser/Day.rb +24 -24
  17. data/lib/sapphire/DSL/Browser/Differ.rb +18 -18
  18. data/lib/sapphire/DSL/Browser/Error.rb +26 -26
  19. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +45 -45
  20. data/lib/sapphire/DSL/Browser/Exists.rb +22 -22
  21. data/lib/sapphire/DSL/Browser/For.rb +10 -10
  22. data/lib/sapphire/DSL/Browser/Hide.rb +26 -26
  23. data/lib/sapphire/DSL/Browser/IsHidden.rb +10 -10
  24. data/lib/sapphire/DSL/Browser/IsVisible.rb +33 -33
  25. data/lib/sapphire/DSL/Browser/Keys/Enter.rb +10 -10
  26. data/lib/sapphire/DSL/Browser/Month.rb +24 -24
  27. data/lib/sapphire/DSL/Browser/MouseOver.rb +12 -12
  28. data/lib/sapphire/DSL/Browser/Navigate.rb +11 -11
  29. data/lib/sapphire/DSL/Browser/Popup.rb +2 -4
  30. data/lib/sapphire/DSL/Browser/Press.rb +10 -10
  31. data/lib/sapphire/DSL/Browser/Reload.rb +11 -11
  32. data/lib/sapphire/DSL/Browser/Set.rb +18 -18
  33. data/lib/sapphire/DSL/Browser/Should.rb +42 -42
  34. data/lib/sapphire/DSL/Browser/Show.rb +26 -26
  35. data/lib/sapphire/DSL/Browser/Start.rb +16 -16
  36. data/lib/sapphire/DSL/Browser/To.rb +10 -10
  37. data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
  38. data/lib/sapphire/DSL/Browser/Transition.rb +26 -26
  39. data/lib/sapphire/DSL/Browser/Uncheck.rb +12 -12
  40. data/lib/sapphire/DSL/Browser/With.rb +10 -10
  41. data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
  42. data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
  43. data/lib/sapphire/DSL/Configuration/Use.rb +15 -15
  44. data/lib/sapphire/DSL/Data/Exist.rb +27 -27
  45. data/lib/sapphire/DSL/Data/Find.rb +10 -10
  46. data/lib/sapphire/DSL/Data/GetPageField.rb +17 -17
  47. data/lib/sapphire/DSL/Data/Underscore.rb +8 -8
  48. data/lib/sapphire/DSL/Data/Validate.rb +26 -26
  49. data/lib/sapphire/DSL/Data/Verify.rb +10 -10
  50. data/lib/sapphire/DSL/Scenarios/Is.rb +9 -9
  51. data/lib/sapphire/DSL/Scenarios/Pending.rb +28 -28
  52. data/lib/sapphire/DSL/Scenarios/and.rb +25 -25
  53. data/lib/sapphire/DSL/Scenarios/background.rb +33 -33
  54. data/lib/sapphire/DSL/Scenarios/dsl.rb +59 -59
  55. data/lib/sapphire/DSL/Scenarios/finally.rb +33 -33
  56. data/lib/sapphire/DSL/Scenarios/given.rb +57 -57
  57. data/lib/sapphire/DSL/Scenarios/runner.rb +40 -40
  58. data/lib/sapphire/DSL/Scenarios/scenario.rb +53 -53
  59. data/lib/sapphire/DSL/Scenarios/then.rb +34 -34
  60. data/lib/sapphire/DSL/Scenarios/when.rb +47 -47
  61. data/lib/sapphire/Data.rb +1 -1
  62. data/lib/sapphire/DataAbstractions/Database.rb +57 -57
  63. data/lib/sapphire/DataAbstractions/Query.rb +19 -19
  64. data/lib/sapphire/JobAbstractions/Job.rb +32 -32
  65. data/lib/sapphire/Strategies.rb +1 -1
  66. data/lib/sapphire/TeamCity.rb +8 -8
  67. data/lib/sapphire/Testing.rb +2 -2
  68. data/lib/sapphire/Testing/Executable.rb +30 -30
  69. data/lib/sapphire/Testing/RakeTask.rb +108 -108
  70. data/lib/sapphire/Testing/ResultList.rb +18 -18
  71. data/lib/sapphire/Testing/ResultTree.rb +44 -44
  72. data/lib/sapphire/Testing/ScenarioResult.rb +36 -36
  73. data/lib/sapphire/Testing/TestResult.rb +21 -21
  74. data/lib/sapphire/Testing/TestRunnerAdapter.rb +69 -69
  75. data/lib/sapphire/Virtualization.rb +7 -7
  76. data/lib/sapphire/Web.rb +3 -6
  77. data/lib/sapphire/WebAbstractions/{Controls/Browsers → Browsers}/Chrome.rb +21 -21
  78. data/lib/sapphire/WebAbstractions/{Controls/Browsers → Browsers}/FireFox.rb +22 -22
  79. data/lib/sapphire/WebAbstractions/{Controls/Browsers → Browsers}/InternetExplorer.rb +21 -21
  80. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +59 -99
  81. data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +62 -62
  82. data/lib/sapphire/WebAbstractions/Controls/Button.rb +9 -9
  83. data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -28
  84. data/lib/sapphire/WebAbstractions/Controls/Date.rb +11 -11
  85. data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +26 -26
  86. data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
  87. data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -9
  88. data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
  89. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -18
  90. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -31
  91. data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
  92. data/lib/sapphire/version.rb +3 -3
  93. metadata +14 -13
  94. data/lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb +0 -91
@@ -1,40 +1,40 @@
1
- module Sapphire
2
- module DSL
3
- module Scenarios
4
- class Runner
5
- attr_accessor :scenarios
6
- attr_accessor :test_plans
7
-
8
- def self.create
9
- @@instance ||= Runner.new
10
- end
11
-
12
- def self.instance
13
- @@instance ||= self.create
14
- end
15
-
16
- def initialize
17
- @scenarios = []
18
- @test_plans = []
19
- end
20
-
21
- def add_scenario(scenario)
22
- @scenarios << scenario
23
- end
24
-
25
- def last_scenario
26
- @scenarios.last
27
- end
28
-
29
- def add_test_plan(test_plan)
30
- @test_plans << test_plan
31
- end
32
-
33
- def last_test_plan
34
- @test_plans.last
35
- end
36
- end
37
- end
38
- end
39
- end
40
-
1
+ module Sapphire
2
+ module DSL
3
+ module Scenarios
4
+ class Runner
5
+ attr_accessor :scenarios
6
+ attr_accessor :test_plans
7
+
8
+ def self.create
9
+ @@instance ||= Runner.new
10
+ end
11
+
12
+ def self.instance
13
+ @@instance ||= self.create
14
+ end
15
+
16
+ def initialize
17
+ @scenarios = []
18
+ @test_plans = []
19
+ end
20
+
21
+ def add_scenario(scenario)
22
+ @scenarios << scenario
23
+ end
24
+
25
+ def last_scenario
26
+ @scenarios.last
27
+ end
28
+
29
+ def add_test_plan(test_plan)
30
+ @test_plans << test_plan
31
+ end
32
+
33
+ def last_test_plan
34
+ @test_plans.last
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -1,53 +1,53 @@
1
- module Sapphire
2
- module DSL
3
- module Scenarios
4
- class Scenario
5
- include Sapphire::Testing::TestRunnerAdapter
6
-
7
- attr_reader :block
8
- attr_reader :value
9
- attr_reader :text
10
- attr_reader :givens
11
- attr_reader :backgrounds
12
- attr_reader :result
13
- attr_accessor :file_name
14
-
15
- def initialize(text, &block)
16
- @value = text
17
- @text = text.to_s
18
- @block = block
19
- @givens = []
20
- @backgrounds = []
21
- @result = Testing::ScenarioResult.new(text)
22
- @file_name = ""
23
- end
24
-
25
- def add_given(given)
26
- if(self.value.is_a? Pending)
27
- @givens << Given.new(self, "", Pending.new(given.text), &block)
28
- else
29
- @givens << given
30
- end
31
- end
32
-
33
- def last_given
34
- @givens.last
35
- end
36
-
37
- def add_background(background)
38
- if(self.value.is_a? Pending)
39
- @backgrounds << Background.new(self, "", Pending.new(background.text), &block)
40
- else
41
- @backgrounds << background
42
- end
43
- end
44
-
45
- def last_background
46
- @backgrounds.last
47
- end
48
-
49
- end
50
- end
51
- end
52
- end
53
-
1
+ module Sapphire
2
+ module DSL
3
+ module Scenarios
4
+ class Scenario
5
+ include Sapphire::Testing::TestRunnerAdapter
6
+
7
+ attr_reader :block
8
+ attr_reader :value
9
+ attr_reader :text
10
+ attr_reader :givens
11
+ attr_reader :backgrounds
12
+ attr_reader :result
13
+ attr_accessor :file_name
14
+
15
+ def initialize(text, &block)
16
+ @value = text
17
+ @text = text.to_s
18
+ @block = block
19
+ @givens = []
20
+ @backgrounds = []
21
+ @result = Testing::ScenarioResult.new(text)
22
+ @file_name = ""
23
+ end
24
+
25
+ def add_given(given)
26
+ if(self.value.is_a? Pending)
27
+ @givens << Given.new(self, "", Pending.new(given.text), &block)
28
+ else
29
+ @givens << given
30
+ end
31
+ end
32
+
33
+ def last_given
34
+ @givens.last
35
+ end
36
+
37
+ def add_background(background)
38
+ if(self.value.is_a? Pending)
39
+ @backgrounds << Background.new(self, "", Pending.new(background.text), &block)
40
+ else
41
+ @backgrounds << background
42
+ end
43
+ end
44
+
45
+ def last_background
46
+ @backgrounds.last
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
53
+
@@ -1,35 +1,35 @@
1
- class Then
2
- include Sapphire::Testing::Executable
3
-
4
- attr_reader :value
5
- attr_accessor :text
6
- attr_reader :block
7
- attr_reader :and
8
- attr_reader :parent
9
- attr_reader :results
10
-
11
- def initialize(parent, pre, text, &block)
12
- @block = block
13
- @value = text
14
- @text = pre + text.to_s
15
- @and = []
16
- @parent = parent
17
- @results = []
18
- end
19
-
20
- def add_and(pre, text, &block)
21
- if(!self.value.instance_of? Pending)
22
- x = And.new(self, text, &block)
23
- self.and << x
24
- else
25
- self.and << And.new(self, Pending.new(pre + text), &block)
26
- end
27
- end
28
-
29
- def AddResult(result)
30
- result.item = self
31
- @results << result
32
- self.parent.results.last.AddChild(result)
33
- end
34
-
1
+ class Then
2
+ include Sapphire::Testing::Executable
3
+
4
+ attr_reader :value
5
+ attr_accessor :text
6
+ attr_reader :block
7
+ attr_reader :and
8
+ attr_reader :parent
9
+ attr_reader :results
10
+
11
+ def initialize(parent, pre, text, &block)
12
+ @block = block
13
+ @value = text
14
+ @text = pre + text.to_s
15
+ @and = []
16
+ @parent = parent
17
+ @results = []
18
+ end
19
+
20
+ def add_and(pre, text, &block)
21
+ if(!self.value.instance_of? Pending)
22
+ x = And.new(self, text, &block)
23
+ self.and << x
24
+ else
25
+ self.and << And.new(self, Pending.new(pre + text), &block)
26
+ end
27
+ end
28
+
29
+ def AddResult(result)
30
+ result.item = self
31
+ @results << result
32
+ self.parent.results.last.AddChild(result)
33
+ end
34
+
35
35
  end
@@ -1,48 +1,48 @@
1
- class When
2
- include Sapphire::Testing::Executable
3
-
4
- attr_reader :value
5
- attr_accessor :text
6
- attr_reader :block
7
- attr_reader :then
8
- attr_reader :and
9
- attr_reader :parent
10
- attr_reader :results
11
-
12
- def initialize(parent, pre, text, &block)
13
- @block = block
14
- @value = text
15
- @text = pre + text.to_s
16
- @then = []
17
- @and = []
18
- @parent = parent
19
- @results = []
20
- end
21
-
22
- def add_then(pre, text, &block)
23
- if(self.value.is_a? Pending)
24
- @then << Then.new(self, pre, Pending.new(text), &block)
25
- else
26
- @then << Then.new(self, pre, text, &block)
27
- end
28
- end
29
-
30
- def add_and(pre, text, &block)
31
- if(self.value.is_a? Pending)
32
- self.and << And.new(self, Pending.new(pre + text), &block)
33
- else
34
- self.and << And.new(self, pre + text, &block)
35
- end
36
- end
37
-
38
- def last_then
39
- @then.last
40
- end
41
-
42
- def AddResult(result)
43
- result.item = self
44
- @results << result
45
- self.parent.results.last.AddChild(result)
46
- end
47
-
1
+ class When
2
+ include Sapphire::Testing::Executable
3
+
4
+ attr_reader :value
5
+ attr_accessor :text
6
+ attr_reader :block
7
+ attr_reader :then
8
+ attr_reader :and
9
+ attr_reader :parent
10
+ attr_reader :results
11
+
12
+ def initialize(parent, pre, text, &block)
13
+ @block = block
14
+ @value = text
15
+ @text = pre + text.to_s
16
+ @then = []
17
+ @and = []
18
+ @parent = parent
19
+ @results = []
20
+ end
21
+
22
+ def add_then(pre, text, &block)
23
+ if(self.value.is_a? Pending)
24
+ @then << Then.new(self, pre, Pending.new(text), &block)
25
+ else
26
+ @then << Then.new(self, pre, text, &block)
27
+ end
28
+ end
29
+
30
+ def add_and(pre, text, &block)
31
+ if(self.value.is_a? Pending)
32
+ self.and << And.new(self, Pending.new(pre + text), &block)
33
+ else
34
+ self.and << And.new(self, pre + text, &block)
35
+ end
36
+ end
37
+
38
+ def last_then
39
+ @then.last
40
+ end
41
+
42
+ def AddResult(result)
43
+ result.item = self
44
+ @results << result
45
+ self.parent.results.last.AddChild(result)
46
+ end
47
+
48
48
  end
@@ -1,2 +1,2 @@
1
- require 'win32ole' if Platform::OS == :win32
1
+ require 'win32ole' if Platform::OS == :win32
2
2
  Dir[File.dirname(__FILE__) + '/DataAbstractions/*.rb'].each {|file| require file }
@@ -1,57 +1,57 @@
1
-
2
-
3
- module Sapphire
4
- module DataAbstractions
5
- class Database
6
-
7
- def Open(connection_string)
8
- @connection = WIN32OLE.new('ADODB.Connection')
9
- @connection.Open(connection_string)
10
- end
11
-
12
- def query(sql)
13
- recordset = WIN32OLE.new('ADODB.Recordset')
14
- recordset.Open(sql, @connection, 0 , 1)
15
-
16
- fields = []
17
-
18
- recordset.Fields.each do |field|
19
- fields << field.Name
20
- end
21
- begin
22
- recordset.MoveFirst
23
- data = recordset.GetRows
24
- rescue
25
- data = []
26
- end
27
-
28
- if(recordset.State != 0)
29
- recordset.Close
30
- end
31
-
32
- data = data.transpose
33
- records = []
34
-
35
- data.each do |row|
36
- y = 0
37
- record = Hash.new
38
- row.each do |column|
39
- if(column != nil)
40
- record.store fields[y].underscore.intern, column.to_s
41
- else
42
- record.store fields[y].underscore.intern, column
43
- end
44
- y += 1
45
- end
46
- records << record
47
- end
48
- records
49
- end
50
-
51
- def close
52
- @connection.Close
53
- end
54
- end
55
- end
56
- end
57
-
1
+
2
+
3
+ module Sapphire
4
+ module DataAbstractions
5
+ class Database
6
+
7
+ def Open(connection_string)
8
+ @connection = WIN32OLE.new('ADODB.Connection')
9
+ @connection.Open(connection_string)
10
+ end
11
+
12
+ def query(sql)
13
+ recordset = WIN32OLE.new('ADODB.Recordset')
14
+ recordset.Open(sql, @connection, 0 , 1)
15
+
16
+ fields = []
17
+
18
+ recordset.Fields.each do |field|
19
+ fields << field.Name
20
+ end
21
+ begin
22
+ recordset.MoveFirst
23
+ data = recordset.GetRows
24
+ rescue
25
+ data = []
26
+ end
27
+
28
+ if(recordset.State != 0)
29
+ recordset.Close
30
+ end
31
+
32
+ data = data.transpose
33
+ records = []
34
+
35
+ data.each do |row|
36
+ y = 0
37
+ record = Hash.new
38
+ row.each do |column|
39
+ if(column != nil)
40
+ record.store fields[y].underscore.intern, column.to_s
41
+ else
42
+ record.store fields[y].underscore.intern, column
43
+ end
44
+ y += 1
45
+ end
46
+ records << record
47
+ end
48
+ records
49
+ end
50
+
51
+ def close
52
+ @connection.Close
53
+ end
54
+ end
55
+ end
56
+ end
57
+