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,10 +1,10 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Show(*item)
5
- Evaluator.new(item) do |item, comparator| item.first.Show(item, comparator) end
6
- end
7
- end
8
- end
9
- end
10
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Show(*item)
5
+ Evaluator.new(item) do |item, comparator| item.first.Show(item, comparator) end
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,10 +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
-
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
+
@@ -1,8 +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
-
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
+
@@ -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 << And.new(self, 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 << And.new(self, 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
@@ -1,59 +1,59 @@
1
- module Sapphire
2
- module DSL
3
- module Scenarios
4
- def Background(text, &block)
5
- Runner.instance.last_scenario.add_background(Background.new(Runner.instance.last_scenario, "Assuming that ", text, &block))
6
- end
7
-
8
- def Given(text, &block)
9
- Runner.instance.last_scenario.add_given(Given.new(Runner.instance.last_scenario, "Given ", text, &block))
10
- end
11
-
12
- def When(text, &block)
13
- Runner.instance.last_scenario.last_given.add_when("When ", text, &block)
14
- end
15
-
16
- def Then(text, &block)
17
- Runner.instance.last_scenario.last_given.last_when.add_then("Then ", text, &block)
18
- end
19
-
20
- def And(text, &block)
21
-
22
- if(Runner.instance.last_scenario.last_given == nil && Runner.instance.last_scenario.last_background != nil)
23
- Runner.instance.last_scenario.last_background.add_and("And ", text, &block)
24
- return
25
- end
26
-
27
- if(Runner.instance.last_scenario.last_given.finally != nil)
28
- Runner.instance.last_scenario.last_given.finally.add_and("And ", text, &block)
29
- return
30
- end
31
-
32
- if(Runner.instance.last_scenario.last_given.last_when == nil)
33
- Runner.instance.last_scenario.last_given.add_and("And ", text, &block)
34
- return
35
- end
36
-
37
- if(Runner.instance.last_scenario.last_given.last_when.last_then == nil)
38
- Runner.instance.last_scenario.last_given.last_when.add_and("And ", text, &block)
39
- return
40
- end
41
-
42
- if (Runner.instance.last_scenario.last_given.last_when.last_then != nil)
43
- Runner.instance.last_scenario.last_given.last_when.last_then.add_and("And ", text, &block)
44
- end
45
- end
46
-
47
- def Finally(text, &block)
48
- Runner.instance.last_scenario.last_given.add_finally(Finally.new(Runner.instance.last_scenario.last_given, text, &block))
49
- end
50
-
51
- def Scenario(text, &block)
52
- Runner.instance.add_scenario(Scenario.new(text, &block))
53
- Runner.instance.last_scenario.block.call
54
- end
55
- end
56
- end
57
- end
58
-
59
-
1
+ module Sapphire
2
+ module DSL
3
+ module Scenarios
4
+ def Background(text, &block)
5
+ Runner.instance.last_scenario.add_background(Background.new(Runner.instance.last_scenario, "Assuming that ", text, &block))
6
+ end
7
+
8
+ def Given(text, &block)
9
+ Runner.instance.last_scenario.add_given(Given.new(Runner.instance.last_scenario, "Given ", text, &block))
10
+ end
11
+
12
+ def When(text, &block)
13
+ Runner.instance.last_scenario.last_given.add_when("When ", text, &block)
14
+ end
15
+
16
+ def Then(text, &block)
17
+ Runner.instance.last_scenario.last_given.last_when.add_then("Then ", text, &block)
18
+ end
19
+
20
+ def And(text, &block)
21
+
22
+ if(Runner.instance.last_scenario.last_given == nil && Runner.instance.last_scenario.last_background != nil)
23
+ Runner.instance.last_scenario.last_background.add_and("And ", text, &block)
24
+ return
25
+ end
26
+
27
+ if(Runner.instance.last_scenario.last_given.finally != nil)
28
+ Runner.instance.last_scenario.last_given.finally.add_and("And ", text, &block)
29
+ return
30
+ end
31
+
32
+ if(Runner.instance.last_scenario.last_given.last_when == nil)
33
+ Runner.instance.last_scenario.last_given.add_and("And ", text, &block)
34
+ return
35
+ end
36
+
37
+ if(Runner.instance.last_scenario.last_given.last_when.last_then == nil)
38
+ Runner.instance.last_scenario.last_given.last_when.add_and("And ", text, &block)
39
+ return
40
+ end
41
+
42
+ if (Runner.instance.last_scenario.last_given.last_when.last_then != nil)
43
+ Runner.instance.last_scenario.last_given.last_when.last_then.add_and("And ", text, &block)
44
+ end
45
+ end
46
+
47
+ def Finally(text, &block)
48
+ Runner.instance.last_scenario.last_given.add_finally(Finally.new(Runner.instance.last_scenario.last_given, text, &block))
49
+ end
50
+
51
+ def Scenario(text, &block)
52
+ Runner.instance.add_scenario(Scenario.new(text, &block))
53
+ Runner.instance.last_scenario.block.call
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+
@@ -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,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
+