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,21 +1,21 @@
1
- module Sapphire
2
- module Plugins
3
-
4
- class Plugin
5
-
6
- attr_reader :object
7
- attr_reader :method
8
-
9
- def observes(hash)
10
- @object = hash[:class]
11
- @method = hash[:method]
12
- end
13
-
14
- def self.observe()
15
-
16
- end
17
-
18
- end
19
-
20
- end
1
+ module Sapphire
2
+ module Plugins
3
+
4
+ class Plugin
5
+
6
+ attr_reader :object
7
+ attr_reader :method
8
+
9
+ def observes(hash)
10
+ @object = hash[:class]
11
+ @method = hash[:method]
12
+ end
13
+
14
+ def self.observe()
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
21
21
  end
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module Testing
3
- module TeamCity
4
- class TeamCityReporter < Reporter
5
-
6
- end
7
- end
8
- end
9
- end
10
-
1
+ module Sapphire
2
+ module Testing
3
+ module TeamCity
4
+ class TeamCityReporter < Reporter
5
+
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
11
  Dir[File.dirname(__FILE__) + '/TeamCity/*.rb'].each {|file| require file } if ENV["TeamCity"] == "1"
@@ -1,3 +1,3 @@
1
- require File.expand_path(File.dirname(__FILE__) +'/Testing/Reporter.rb', __FILE__)
2
- Dir[File.dirname(__FILE__) + '/Testing/*.rb'].each {|file| require file }
3
- Dir[File.dirname(__FILE__) + '/Testing/Coverage/*.rb'].each {|file| require file }
1
+ require File.expand_path(File.dirname(__FILE__) +'/Testing/Reporter.rb', __FILE__)
2
+ Dir[File.dirname(__FILE__) + '/Testing/*.rb'].each {|file| require file }
3
+ Dir[File.dirname(__FILE__) + '/Testing/Coverage/*.rb'].each {|file| require file }
@@ -1,109 +1,109 @@
1
- require 'rake'
2
- require 'json'
3
-
4
- module Sapphire
5
- module Testing
6
- class RakeTask
7
- attr_accessor :pattern
8
- attr_accessor :verbose
9
- attr_accessor :fail_on_error
10
- attr_accessor :name
11
-
12
-
13
- def test_outcome(result)
14
-
15
- result.results.each do |r|
16
-
17
- if(r.type == 'fail')
18
- return 'fail'
19
- end
20
-
21
- if(r.type == 'pending')
22
- return 'pending'
23
- end
24
-
25
- if(!r.results.empty?)
26
- return test_outcome(r)
27
- end
28
-
29
- end
30
-
31
- return 'pass'
32
-
33
- end
34
-
35
- def initialize(*args)
36
-
37
- @name = args.shift || :spec
38
- @pattern = nil
39
- @verbose, @fail_on_error = true, true
40
-
41
- yield self if block_given?
42
-
43
- Rake::Task.define_task name do
44
- RakeFileUtils.send(:verbose, verbose) do
45
- files_to_run = FileList[ pattern ].map { |f|
46
- y = nil
47
- x = nil
48
- x = f.gsub(/"/, '\"') if f != nil
49
- y = x.gsub(/'/, "\\\\'") if x != nil
50
- y
51
- }
52
- if files_to_run.empty?
53
- puts "No examples matching #{pattern} could be found"
54
- else
55
- begin
56
-
57
- files_to_run.each do |f|
58
- next unless f != nil
59
- require File.expand_path("../../" + f.to_s, __FILE__) unless File.directory? f
60
- end
61
-
62
- success_array = []
63
- pending_array = []
64
- failure_array = []
65
-
66
- i = 3
67
-
68
- Runner.instance.scenarios.each do |scenario|
69
- i += 1
70
- scenario.execute i
71
- scenario.result.set_id i
72
- scenario.result.set_type test_outcome(scenario.result)
73
-
74
- success_array << scenario.result if scenario.result.type == "pass"
75
- pending_array << scenario.result if scenario.result.type == "pending"
76
- failure_array << scenario.result if scenario.result.type == "fail"
77
- end
78
-
79
- item_array = []
80
- item_array << ResultsList.new("Passing", success_array, 1)
81
- item_array << ResultsList.new("Pending", pending_array, 2)
82
- item_array << ResultsList.new("Failing", failure_array, 3)
83
-
84
-
85
- File.open(File.dirname(__FILE__) + "/../ReportGenerator/output.json", "w") do |file|
86
- file.puts ActiveSupport::JSON.encode item_array
87
- end
88
-
89
- Runner.instance.scenarios.each do |scenario|
90
- File.open(File.dirname(__FILE__) + "/../ReportGenerator/" + scenario.result.myId.to_s + ".json", "w") do |file|
91
- file.puts ActiveSupport::JSON.encode scenario.result
92
- end
93
- end
94
-
95
- rescue => e
96
- stack = ""
97
- e.backtrace.each do |line|
98
- stack += "\r\n" + line
99
- end
100
-
101
- raise("Some tests have failed: " + e.message + " : " + stack) if fail_on_error
102
- end
103
- end
104
- end
105
- end
106
- end
107
- end
108
- end
1
+ require 'rake'
2
+ require 'json'
3
+
4
+ module Sapphire
5
+ module Testing
6
+ class RakeTask
7
+ attr_accessor :pattern
8
+ attr_accessor :verbose
9
+ attr_accessor :fail_on_error
10
+ attr_accessor :name
11
+
12
+
13
+ def test_outcome(result)
14
+
15
+ result.results.each do |r|
16
+
17
+ if(r.type == 'fail')
18
+ return 'fail'
19
+ end
20
+
21
+ if(r.type == 'pending')
22
+ return 'pending'
23
+ end
24
+
25
+ if(!r.results.empty?)
26
+ return test_outcome(r)
27
+ end
28
+
29
+ end
30
+
31
+ return 'pass'
32
+
33
+ end
34
+
35
+ def initialize(*args)
36
+
37
+ @name = args.shift || :spec
38
+ @pattern = nil
39
+ @verbose, @fail_on_error = true, true
40
+
41
+ yield self if block_given?
42
+
43
+ Rake::Task.define_task name do
44
+ RakeFileUtils.send(:verbose, verbose) do
45
+ files_to_run = FileList[ pattern ].map { |f|
46
+ y = nil
47
+ x = nil
48
+ x = f.gsub(/"/, '\"') if f != nil
49
+ y = x.gsub(/'/, "\\\\'") if x != nil
50
+ y
51
+ }
52
+ if files_to_run.empty?
53
+ puts "No examples matching #{pattern} could be found"
54
+ else
55
+ begin
56
+
57
+ files_to_run.each do |f|
58
+ next unless f != nil
59
+ require File.expand_path("../../" + f.to_s, __FILE__) unless File.directory? f
60
+ end
61
+
62
+ success_array = []
63
+ pending_array = []
64
+ failure_array = []
65
+
66
+ i = 3
67
+
68
+ Runner.instance.scenarios.each do |scenario|
69
+ i += 1
70
+ scenario.execute i
71
+ scenario.result.set_id i
72
+ scenario.result.set_type test_outcome(scenario.result)
73
+
74
+ success_array << scenario.result if scenario.result.type == "pass"
75
+ pending_array << scenario.result if scenario.result.type == "pending"
76
+ failure_array << scenario.result if scenario.result.type == "fail"
77
+ end
78
+
79
+ item_array = []
80
+ item_array << ResultsList.new("Passing", success_array, 1)
81
+ item_array << ResultsList.new("Pending", pending_array, 2)
82
+ item_array << ResultsList.new("Failing", failure_array, 3)
83
+
84
+
85
+ File.open(File.dirname(__FILE__) + "/../ReportGenerator/output.json", "w") do |file|
86
+ file.puts ActiveSupport::JSON.encode item_array
87
+ end
88
+
89
+ Runner.instance.scenarios.each do |scenario|
90
+ File.open(File.dirname(__FILE__) + "/../ReportGenerator/" + scenario.result.myId.to_s + ".json", "w") do |file|
91
+ file.puts ActiveSupport::JSON.encode scenario.result
92
+ end
93
+ end
94
+
95
+ rescue => e
96
+ stack = ""
97
+ e.backtrace.each do |line|
98
+ stack += "\r\n" + line
99
+ end
100
+
101
+ raise("Some tests have failed: " + e.message + " : " + stack) if fail_on_error
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
109
  end
@@ -1,19 +1,19 @@
1
- module Sapphire
2
- module Testing
3
- class ResultsList
4
-
5
- attr_reader :myId
6
- attr_reader :text
7
- attr_reader :children
8
-
9
- def initialize(text, results, id)
10
- @myId = id
11
- @text = text
12
- @children = results
13
- @expanded = true
14
- @count = results.length
15
- end
16
-
17
- end
18
- end
1
+ module Sapphire
2
+ module Testing
3
+ class ResultsList
4
+
5
+ attr_reader :myId
6
+ attr_reader :text
7
+ attr_reader :children
8
+
9
+ def initialize(text, results, id)
10
+ @myId = id
11
+ @text = text
12
+ @children = results
13
+ @expanded = true
14
+ @count = results.length
15
+ end
16
+
17
+ end
18
+ end
19
19
  end
@@ -1,36 +1,36 @@
1
- module Sapphire
2
- module Testing
3
- class ScenarioResult
4
-
5
- attr_reader :results
6
- attr_accessor :myId
7
- attr_reader :type
8
- attr_reader :time
9
- attr_reader :parent
10
-
11
- def initialize(text)
12
- @text = text
13
- @results = []
14
- @leaf = true
15
- @myId = -1
16
- @type = 'pass'
17
- @time = 0
18
- end
19
-
20
- def AddChild(result)
21
- result.parent = self
22
- @results << result
23
- @time += result.time
24
- end
25
-
26
- def set_id(id)
27
- @myId = id
28
- end
29
-
30
- def set_type(type)
31
- @type = type
32
- end
33
-
34
- end
35
- end
36
- end
1
+ module Sapphire
2
+ module Testing
3
+ class ScenarioResult
4
+
5
+ attr_reader :results
6
+ attr_accessor :myId
7
+ attr_reader :type
8
+ attr_reader :time
9
+ attr_reader :parent
10
+
11
+ def initialize(text)
12
+ @text = text
13
+ @results = []
14
+ @leaf = true
15
+ @myId = -1
16
+ @type = 'pass'
17
+ @time = 0
18
+ end
19
+
20
+ def AddChild(result)
21
+ result.parent = self
22
+ @results << result
23
+ @time += result.time
24
+ end
25
+
26
+ def set_id(id)
27
+ @myId = id
28
+ end
29
+
30
+ def set_type(type)
31
+ @type = type
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -1,22 +1,22 @@
1
- module Sapphire
2
- module Testing
3
- class TestResult
4
-
5
- attr_reader :execution_time
6
- attr_reader :message
7
- attr_reader :item
8
- attr_reader :type
9
- attr_reader :stack
10
- attr_reader :messages
11
-
12
- def initialize(type, item, message, stack, execution_time)
13
- @item = item
14
- @execution_time = execution_time
15
- @messages = message
16
- @stack = stack
17
- @type = type
18
- end
19
-
20
- end
21
- end
1
+ module Sapphire
2
+ module Testing
3
+ class TestResult
4
+
5
+ attr_reader :execution_time
6
+ attr_reader :message
7
+ attr_reader :item
8
+ attr_reader :type
9
+ attr_reader :stack
10
+ attr_reader :messages
11
+
12
+ def initialize(type, item, message, stack, execution_time)
13
+ @item = item
14
+ @execution_time = execution_time
15
+ @messages = message
16
+ @stack = stack
17
+ @type = type
18
+ end
19
+
20
+ end
21
+ end
22
22
  end
@@ -1,85 +1,85 @@
1
- module Sapphire
2
- module Testing
3
- module TestRunnerAdapter
4
-
5
- def Report(&block)
6
- $instances.each do |reporter|
7
- block.call reporter
8
- end
9
- end
10
-
11
- def execute()
12
- Report do |reporter| reporter.ScenarioStart(self) end
13
-
14
- self.backgrounds.each do |background|
15
-
16
- background.execute
17
-
18
- background.and.each do |background_and|
19
-
20
- background_and.execute
21
-
22
- end
23
-
24
- end
25
-
26
- self.givens.each do |given|
27
- given.when.each do |when_|
28
-
29
- if when_.value.is_a? Pending
30
- given.pend()
31
-
32
- given.and.each do |given_and|
33
-
34
- given_and.pend()
35
-
36
- end
37
- else
38
- given.execute()
39
-
40
- given.and.each do |given_and|
41
-
42
- given_and.execute()
43
-
44
- end
45
- end
46
-
47
- when_.execute
48
-
49
- when_.and.each do |when_and|
50
-
51
- when_and.execute
52
-
53
- end
54
-
55
- when_.then.each do |then_|
56
-
57
- then_.execute
58
-
59
- then_.and.each do |then_and|
60
-
61
- then_and.execute
62
-
63
- end
64
-
65
- end
66
-
67
- end
68
-
69
- if(given.finally)
70
-
71
- given.finally.execute
72
-
73
- end
74
-
75
- end
76
-
77
- Report do |reporter| reporter.ScenarioComplete(self) end
78
-
79
- end
80
- end
81
- end
82
- end
83
-
84
-
85
-
1
+ module Sapphire
2
+ module Testing
3
+ module TestRunnerAdapter
4
+
5
+ def Report(&block)
6
+ $instances.each do |reporter|
7
+ block.call reporter
8
+ end
9
+ end
10
+
11
+ def execute()
12
+ Report do |reporter| reporter.ScenarioStart(self) end
13
+
14
+ self.backgrounds.each do |background|
15
+
16
+ background.execute
17
+
18
+ background.and.each do |background_and|
19
+
20
+ background_and.execute
21
+
22
+ end
23
+
24
+ end
25
+
26
+ self.givens.each do |given|
27
+ given.when.each do |when_|
28
+
29
+ if when_.value.is_a? Pending
30
+ given.pend()
31
+
32
+ given.and.each do |given_and|
33
+
34
+ given_and.pend()
35
+
36
+ end
37
+ else
38
+ given.execute()
39
+
40
+ given.and.each do |given_and|
41
+
42
+ given_and.execute()
43
+
44
+ end
45
+ end
46
+
47
+ when_.execute
48
+
49
+ when_.and.each do |when_and|
50
+
51
+ when_and.execute
52
+
53
+ end
54
+
55
+ when_.then.each do |then_|
56
+
57
+ then_.execute
58
+
59
+ then_.and.each do |then_and|
60
+
61
+ then_and.execute
62
+
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ if(given.finally)
70
+
71
+ given.finally.execute
72
+
73
+ end
74
+
75
+ end
76
+
77
+ Report do |reporter| reporter.ScenarioComplete(self) end
78
+
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+
85
+