sapphire 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire.rb +30 -0
- data/lib/sapphire/DSL/Browser/Browser.rb +13 -0
- data/lib/sapphire/DSL/Browser/Check.rb +12 -0
- data/lib/sapphire/DSL/Browser/Clear.rb +15 -0
- data/lib/sapphire/DSL/Browser/Click.rb +12 -0
- data/lib/sapphire/DSL/Browser/Close.rb +12 -0
- data/lib/sapphire/DSL/Browser/Complete.rb +15 -0
- data/lib/sapphire/DSL/Browser/CurrentUrl.rb +11 -0
- data/lib/sapphire/DSL/Browser/Error.rb +12 -0
- data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +45 -0
- data/lib/sapphire/DSL/Browser/Exists.rb +22 -0
- data/lib/sapphire/DSL/Browser/For.rb +10 -0
- data/lib/sapphire/DSL/Browser/Hide.rb +10 -0
- data/lib/sapphire/DSL/Browser/IsHidden.rb +28 -0
- data/lib/sapphire/DSL/Browser/IsVisible.rb +25 -0
- data/lib/sapphire/DSL/Browser/MouseOver.rb +12 -0
- data/lib/sapphire/DSL/Browser/Navigate.rb +11 -0
- data/lib/sapphire/DSL/Browser/Reload.rb +11 -0
- data/lib/sapphire/DSL/Browser/Set.rb +12 -0
- data/lib/sapphire/DSL/Browser/Should.rb +10 -0
- data/lib/sapphire/DSL/Browser/Show.rb +26 -0
- data/lib/sapphire/DSL/Browser/Start.rb +16 -0
- data/lib/sapphire/DSL/Browser/To.rb +10 -0
- data/lib/sapphire/DSL/Browser/Tracker.rb +15 -0
- data/lib/sapphire/DSL/Browser/Transition.rb +10 -0
- data/lib/sapphire/DSL/Browser/Uncheck.rb +12 -0
- data/lib/sapphire/DSL/Browser/With.rb +10 -0
- data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +13 -0
- data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +11 -0
- data/lib/sapphire/DSL/Configuration/Use.rb +15 -0
- data/lib/sapphire/DSL/Data/Exist.rb +11 -0
- data/lib/sapphire/DSL/Data/Find.rb +10 -0
- data/lib/sapphire/DSL/Data/GetPageField.rb +17 -0
- data/lib/sapphire/DSL/Data/Underscore.rb +9 -0
- data/lib/sapphire/DSL/Data/Validate.rb +16 -0
- data/lib/sapphire/DSL/Data/Verify.rb +10 -0
- data/lib/sapphire/DSL/Scenarios/Is.rb +9 -0
- data/lib/sapphire/DSL/Scenarios/Pending.rb +29 -0
- data/lib/sapphire/DSL/Scenarios/and.rb +25 -0
- data/lib/sapphire/DSL/Scenarios/background.rb +23 -0
- data/lib/sapphire/DSL/Scenarios/dsl.rb +60 -0
- data/lib/sapphire/DSL/Scenarios/finally.rb +32 -0
- data/lib/sapphire/DSL/Scenarios/given.rb +57 -0
- data/lib/sapphire/DSL/Scenarios/runner.rb +30 -0
- data/lib/sapphire/DSL/Scenarios/scenario.rb +51 -0
- data/lib/sapphire/DSL/Scenarios/then.rb +34 -0
- data/lib/sapphire/DSL/Scenarios/when.rb +47 -0
- data/lib/sapphire/DataAbstractions/Database.rb +57 -0
- data/lib/sapphire/DataAbstractions/Query.rb +20 -0
- data/lib/sapphire/Testing/Executable.rb +30 -0
- data/lib/sapphire/Testing/RSpecRunner.rb +85 -0
- data/lib/sapphire/Testing/RakeTask.rb +109 -0
- data/lib/sapphire/Testing/ResultList.rb +19 -0
- data/lib/sapphire/Testing/ResultTree.rb +37 -0
- data/lib/sapphire/Testing/ScenarioResult.rb +31 -0
- data/lib/sapphire/Testing/TestResult.rb +24 -0
- data/lib/sapphire/Testing/TestRunnerAdapter.rb +62 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +74 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +47 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb +74 -0
- data/lib/sapphire/WebAbstractions/Controls/Button.rb +9 -0
- data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -0
- data/lib/sapphire/WebAbstractions/Controls/Chrome.rb +21 -0
- data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +25 -0
- data/lib/sapphire/WebAbstractions/Controls/FireFox.rb +22 -0
- data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -0
- data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -0
- data/lib/sapphire/WebAbstractions/Controls/InternetExplorer.rb +21 -0
- data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -0
- data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -0
- data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -0
- data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -0
- data/lib/sapphire/version.rb +3 -0
- metadata +152 -0
@@ -0,0 +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
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Data
|
4
|
+
def Validate(hash)
|
5
|
+
hash.keys.each do |key|
|
6
|
+
if(hash[key].is_a? Symbol)
|
7
|
+
key.to_s.should == GetPageField(hash[key]).Text
|
8
|
+
else
|
9
|
+
key.to_s.should == hash[key].to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +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
|
29
|
+
end
|
@@ -0,0 +1,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
|
+
@results << result
|
22
|
+
self.parent.results.last.AddChild(result)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Background
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :text
|
6
|
+
attr_reader :block
|
7
|
+
attr_reader :parent
|
8
|
+
attr_reader :results
|
9
|
+
|
10
|
+
def initialize(parent, pre, text, &block)
|
11
|
+
@block = block
|
12
|
+
@value = text
|
13
|
+
@text = pre + text.to_s
|
14
|
+
@parent = parent
|
15
|
+
@results = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def AddResult(result)
|
19
|
+
@results << result
|
20
|
+
self.parent.result.AddChild(result)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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.add_background(Background.new(Runner.instance.last_scenario, "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
|
+
Runner.instance.last_scenario.execute 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Finally
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :block
|
6
|
+
attr_reader :text
|
7
|
+
attr_reader :and
|
8
|
+
attr_reader :parent
|
9
|
+
attr_reader :results
|
10
|
+
|
11
|
+
def initialize(parent, text, &block)
|
12
|
+
@value = text
|
13
|
+
@text = text.to_s
|
14
|
+
@block = block
|
15
|
+
@and = []
|
16
|
+
@parent = parent
|
17
|
+
@results = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_and(pre, text, &block)
|
21
|
+
if(self.value.is_a? Pending)
|
22
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
23
|
+
else
|
24
|
+
self.and << And.new(self, pre + text, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def AddResult(result)
|
29
|
+
@results << result
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Given
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :text
|
6
|
+
attr_reader :block
|
7
|
+
attr_reader :finally
|
8
|
+
attr_reader :when
|
9
|
+
attr_reader :and
|
10
|
+
attr_reader :parent
|
11
|
+
attr_reader :results
|
12
|
+
|
13
|
+
def initialize(parent, pre, text, &block)
|
14
|
+
@value = text
|
15
|
+
@text = pre + text.to_s
|
16
|
+
@block = block
|
17
|
+
@when = []
|
18
|
+
@and = []
|
19
|
+
@parent = parent
|
20
|
+
@results = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_when(pre, text, &block)
|
24
|
+
if(self.value.is_a? Pending)
|
25
|
+
@when << When.new(self, pre, Pending.new(text), &block)
|
26
|
+
else
|
27
|
+
x = When.new(self, pre, text, &block)
|
28
|
+
@when << x
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def last_when()
|
33
|
+
@when.last
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_finally(finally)
|
37
|
+
if(self.value.is_a? Pending)
|
38
|
+
@finally = Finally.new(self, Pending.new(finally.text), &block)
|
39
|
+
else
|
40
|
+
@finally = finally
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_and(pre, text, &block)
|
45
|
+
if(self.value.is_a? Pending)
|
46
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
47
|
+
else
|
48
|
+
self.and << And.new(self, text, &block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def AddResult(result)
|
53
|
+
@results << result
|
54
|
+
self.parent.result.AddChild(result)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Scenarios
|
4
|
+
class Runner
|
5
|
+
attr_accessor :scenarios
|
6
|
+
|
7
|
+
def self.create
|
8
|
+
@@instance ||= Runner.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.instance
|
12
|
+
@@instance ||= self.create
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@scenarios = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_scenario(scenario)
|
20
|
+
@scenarios << scenario
|
21
|
+
end
|
22
|
+
|
23
|
+
def last_scenario
|
24
|
+
@scenarios.last
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Scenarios
|
4
|
+
class Scenario
|
5
|
+
include Sapphire::Testing::RSpecRunner
|
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
|
+
|
14
|
+
def initialize(text, &block)
|
15
|
+
@value = text
|
16
|
+
@text = text.to_s
|
17
|
+
@block = block
|
18
|
+
@givens = []
|
19
|
+
@backgrounds = []
|
20
|
+
@result = Testing::ScenarioResult.new(text)
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_given(given)
|
24
|
+
if(self.value.is_a? Pending)
|
25
|
+
@givens << Given.new(self, "", Pending.new(given.text), &block)
|
26
|
+
else
|
27
|
+
@givens << given
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def last_given
|
32
|
+
@givens.last
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_background(background)
|
36
|
+
if(self.value.is_a? Pending)
|
37
|
+
@backgrounds << Background.new(self, "", Pending.new(background.text), &block)
|
38
|
+
else
|
39
|
+
@backgrounds << background
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def last_background
|
44
|
+
@backgrounds.last
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|