sapphire 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +190 -190
- data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +34 -45
- data/lib/sapphire/DSL/Browser/Extensions/Class.rb +29 -0
- data/lib/sapphire/DSL/Browser/Extensions/Hash.rb +11 -0
- data/lib/sapphire/DSL/Browser/Extensions/Numeric.rb +7 -0
- data/lib/sapphire/DSL/Browser/Extensions/Symbol.rb +37 -0
- data/lib/sapphire/DSL/Browser/{By.rb → Fluff/By.rb} +10 -10
- data/lib/sapphire/DSL/Browser/{To.rb → Fluff/To.rb} +10 -10
- data/lib/sapphire/DSL/Browser/{With.rb → Fluff/With.rb} +10 -10
- data/lib/sapphire/DSL/Browser/For.rb +10 -10
- data/lib/sapphire/DSL/Browser/{AlertBox.rb → Nouns/AlertBox.rb} +14 -14
- data/lib/sapphire/DSL/Browser/{Browser.rb → Nouns/Browser.rb} +17 -17
- data/lib/sapphire/DSL/Browser/{Day.rb → Nouns/Day.rb} +24 -24
- data/lib/sapphire/DSL/Browser/{Keys → Nouns}/Enter.rb +10 -10
- data/lib/sapphire/DSL/Browser/{Month.rb → Nouns/Month.rb} +24 -24
- data/lib/sapphire/DSL/Browser/{Popup.rb → Nouns/Popup.rb} +0 -0
- data/lib/sapphire/DSL/Browser/Should.rb +42 -42
- data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
- data/lib/sapphire/DSL/Browser/{Accept.rb → Verbs/Accept.rb} +9 -9
- data/lib/sapphire/DSL/Browser/Verbs/Check.rb +11 -0
- data/lib/sapphire/DSL/Browser/{IsHidden.rb → Verbs/Clear.rb} +9 -10
- data/lib/sapphire/DSL/Browser/Verbs/Click.rb +11 -0
- data/lib/sapphire/DSL/Browser/{Close.rb → Verbs/Close.rb} +11 -12
- data/lib/sapphire/DSL/Browser/{Compare.rb → Verbs/Compare.rb} +18 -18
- data/lib/sapphire/DSL/Browser/Verbs/Complete.rb +10 -0
- data/lib/sapphire/DSL/Browser/{Differ.rb → Verbs/Differ.rb} +18 -18
- data/lib/sapphire/DSL/Browser/{Disable.rb → Verbs/Disable.rb} +0 -0
- data/lib/sapphire/DSL/Browser/{Error.rb → Verbs/Error.rb} +25 -26
- data/lib/sapphire/DSL/Browser/{Exists.rb → Verbs/Exists.rb} +22 -22
- data/lib/sapphire/DSL/Browser/{Hide.rb → Verbs/Hide.rb} +25 -26
- data/lib/sapphire/DSL/Browser/Verbs/MouseOver.rb +11 -0
- data/lib/sapphire/DSL/Browser/{Navigate.rb → Verbs/Navigate.rb} +11 -11
- data/lib/sapphire/DSL/Browser/{Press.rb → Verbs/Press.rb} +8 -10
- data/lib/sapphire/DSL/Browser/{Reload.rb → Verbs/Reload.rb} +11 -11
- data/lib/sapphire/DSL/Browser/Verbs/Set.rb +10 -0
- data/lib/sapphire/DSL/Browser/{Show.rb → Verbs/Show.rb} +25 -26
- data/lib/sapphire/DSL/Browser/{Start.rb → Verbs/Start.rb} +16 -16
- data/lib/sapphire/DSL/Browser/{Switch.rb → Verbs/Switch.rb} +0 -0
- data/lib/sapphire/DSL/Browser/{Transition.rb → Verbs/Transition.rb} +25 -26
- data/lib/sapphire/DSL/Browser/Verbs/Uncheck.rb +11 -0
- data/lib/sapphire/DSL/Browser/{Virtually.rb → Verbs/Virtually.rb} +0 -0
- data/lib/sapphire/DSL/Browser/{Wait.rb → Verbs/Wait.rb} +2 -2
- data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
- data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
- data/lib/sapphire/DSL/Configuration/Use.rb +15 -15
- data/lib/sapphire/DSL/Data/Exist.rb +27 -27
- data/lib/sapphire/DSL/Data/Find.rb +10 -10
- data/lib/sapphire/DSL/Data/GetPageField.rb +17 -17
- data/lib/sapphire/DSL/Data/Underscore.rb +8 -8
- data/lib/sapphire/DSL/Data/Validate.rb +26 -26
- data/lib/sapphire/DSL/Data/Verify.rb +10 -10
- data/lib/sapphire/DSL/Scenarios/Is.rb +9 -9
- data/lib/sapphire/DSL/Scenarios/Pending.rb +28 -28
- data/lib/sapphire/DSL/Scenarios/and.rb +25 -25
- data/lib/sapphire/DSL/Scenarios/background.rb +33 -33
- data/lib/sapphire/DSL/Scenarios/dsl.rb +59 -59
- data/lib/sapphire/DSL/Scenarios/finally.rb +33 -33
- data/lib/sapphire/DSL/Scenarios/given.rb +57 -57
- data/lib/sapphire/DSL/Scenarios/runner.rb +40 -40
- data/lib/sapphire/DSL/Scenarios/scenario.rb +53 -53
- data/lib/sapphire/DSL/Scenarios/then.rb +34 -34
- data/lib/sapphire/DSL/Scenarios/when.rb +47 -47
- data/lib/sapphire/DSL.rb +10 -6
- data/lib/sapphire/Data.rb +1 -1
- data/lib/sapphire/DataAbstractions/Database.rb +57 -57
- data/lib/sapphire/DataAbstractions/Query.rb +19 -19
- data/lib/sapphire/JobAbstractions/Job.rb +32 -32
- data/lib/sapphire/Strategies/ClassStrategy.rb +1 -1
- data/lib/sapphire/Strategies/Strategy.rb +1 -2
- data/lib/sapphire/Strategies.rb +1 -1
- data/lib/sapphire/TeamCity.rb +8 -8
- data/lib/sapphire/Testing/Executable.rb +30 -30
- data/lib/sapphire/Testing/RakeTask.rb +108 -108
- data/lib/sapphire/Testing/ResultList.rb +18 -18
- data/lib/sapphire/Testing/ResultTree.rb +44 -44
- data/lib/sapphire/Testing/ScenarioResult.rb +36 -36
- data/lib/sapphire/Testing/TestResult.rb +21 -21
- data/lib/sapphire/Testing/TestRunnerAdapter.rb +69 -69
- data/lib/sapphire/Testing.rb +2 -2
- data/lib/sapphire/Virtualization.rb +7 -7
- data/lib/sapphire/Web.rb +2 -2
- data/lib/sapphire/WebAbstractions/Browsers/Chrome.rb +21 -21
- data/lib/sapphire/WebAbstractions/Browsers/FireFox.rb +22 -22
- data/lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb +21 -21
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +58 -59
- data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +61 -62
- data/lib/sapphire/WebAbstractions/Controls/Button.rb +7 -9
- data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -28
- data/lib/sapphire/WebAbstractions/Controls/Date.rb +11 -11
- data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +26 -26
- data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
- data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -9
- data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
- data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -18
- data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -31
- data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
- data/lib/sapphire/version.rb +3 -3
- data/lib/sapphire.rb +38 -38
- metadata +46 -45
- data/lib/sapphire/DSL/Browser/Check.rb +0 -12
- data/lib/sapphire/DSL/Browser/Clear.rb +0 -13
- data/lib/sapphire/DSL/Browser/Click.rb +0 -12
- data/lib/sapphire/DSL/Browser/Complete.rb +0 -15
- data/lib/sapphire/DSL/Browser/CurrentUrl.rb +0 -11
- data/lib/sapphire/DSL/Browser/IsVisible.rb +0 -33
- data/lib/sapphire/DSL/Browser/MouseOver.rb +0 -12
- data/lib/sapphire/DSL/Browser/Set.rb +0 -18
- data/lib/sapphire/DSL/Browser/Uncheck.rb +0 -12
@@ -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
|
data/lib/sapphire/DSL.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
Dir[File.dirname(__FILE__) + '/DSL/Browser/*.rb'].each {|file| require file }
|
2
|
-
Dir[File.dirname(__FILE__) + '/DSL/Browser/
|
3
|
-
Dir[File.dirname(__FILE__) + '/DSL/
|
4
|
-
Dir[File.dirname(__FILE__) + '/DSL/
|
5
|
-
Dir[File.dirname(__FILE__) + '/DSL/
|
6
|
-
Dir[File.dirname(__FILE__) + '/DSL/
|
1
|
+
Dir[File.dirname(__FILE__) + '/DSL/Browser/*.rb'].each {|file| require file }
|
2
|
+
Dir[File.dirname(__FILE__) + '/DSL/Browser/Fluff/*.rb'].each {|file| require file }
|
3
|
+
Dir[File.dirname(__FILE__) + '/DSL/Browser/Extensions/*.rb'].each {|file| require file }
|
4
|
+
Dir[File.dirname(__FILE__) + '/DSL/Browser/Nouns/*.rb'].each {|file| require file }
|
5
|
+
Dir[File.dirname(__FILE__) + '/DSL/Browser/Verbs/*.rb'].each {|file| require file }
|
6
|
+
Dir[File.dirname(__FILE__) + '/DSL/Browser/Keys/*.rb'].each {|file| require file }
|
7
|
+
Dir[File.dirname(__FILE__) + '/DSL/Configuration/*.rb'].each {|file| require file }
|
8
|
+
Dir[File.dirname(__FILE__) + '/DSL/Data/*.rb'].each {|file| require file }
|
9
|
+
Dir[File.dirname(__FILE__) + '/DSL/Scenarios/*.rb'].each {|file| require file }
|
10
|
+
Dir[File.dirname(__FILE__) + '/DSL/TestPlans/*.rb'].each {|file| require file }
|
data/lib/sapphire/Data.rb
CHANGED
@@ -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
|
+
|
@@ -1,20 +1,20 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DataAbstractions
|
3
|
-
module Query
|
4
|
-
def Execute(block)
|
5
|
-
x = self.Database.new
|
6
|
-
|
7
|
-
x.Open $config[x.Connection]
|
8
|
-
y = AppConfig.Current.SqlPath || ""
|
9
|
-
path = File.expand_path(y + self.Script, __FILE__)
|
10
|
-
file = File.open(path)
|
11
|
-
contents = file.read
|
12
|
-
self.Tokenize(contents)
|
13
|
-
|
14
|
-
results = x.query(contents)
|
15
|
-
block.call results
|
16
|
-
x.close
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
module Sapphire
|
2
|
+
module DataAbstractions
|
3
|
+
module Query
|
4
|
+
def Execute(block)
|
5
|
+
x = self.Database.new
|
6
|
+
|
7
|
+
x.Open $config[x.Connection]
|
8
|
+
y = AppConfig.Current.SqlPath || ""
|
9
|
+
path = File.expand_path(y + self.Script, __FILE__)
|
10
|
+
file = File.open(path)
|
11
|
+
contents = file.read
|
12
|
+
self.Tokenize(contents)
|
13
|
+
|
14
|
+
results = x.query(contents)
|
15
|
+
block.call results
|
16
|
+
x.close
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module JobAbstractions
|
3
|
-
class Job
|
4
|
-
|
5
|
-
def Server
|
6
|
-
return ""
|
7
|
-
end
|
8
|
-
|
9
|
-
def User
|
10
|
-
return ""
|
11
|
-
end
|
12
|
-
|
13
|
-
def Password
|
14
|
-
return ""
|
15
|
-
end
|
16
|
-
|
17
|
-
def Path
|
18
|
-
return ""
|
19
|
-
end
|
20
|
-
|
21
|
-
def PsExecPath
|
22
|
-
return ""
|
23
|
-
end
|
24
|
-
|
25
|
-
def Arg
|
26
|
-
return nil
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
1
|
+
module Sapphire
|
2
|
+
module JobAbstractions
|
3
|
+
class Job
|
4
|
+
|
5
|
+
def Server
|
6
|
+
return ""
|
7
|
+
end
|
8
|
+
|
9
|
+
def User
|
10
|
+
return ""
|
11
|
+
end
|
12
|
+
|
13
|
+
def Password
|
14
|
+
return ""
|
15
|
+
end
|
16
|
+
|
17
|
+
def Path
|
18
|
+
return ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def PsExecPath
|
22
|
+
return ""
|
23
|
+
end
|
24
|
+
|
25
|
+
def Arg
|
26
|
+
return nil
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/lib/sapphire/Strategies.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +'/Strategies/Strategy.rb', __FILE__)
|
1
|
+
require File.expand_path(File.dirname(__FILE__) +'/Strategies/Strategy.rb', __FILE__)
|
2
2
|
Dir[File.dirname(__FILE__) + '/Strategies/*.rb'].each {|file| require file }
|
data/lib/sapphire/TeamCity.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
Dir[File.dirname(__FILE__) + '/TeamCity/*.rb'].each {|file| require file } if ENV["TeamCity"] == 1
|
2
|
-
|
3
|
-
module Sapphire
|
4
|
-
module Testing
|
5
|
-
module TeamCity
|
6
|
-
|
7
|
-
end
|
8
|
-
end
|
1
|
+
Dir[File.dirname(__FILE__) + '/TeamCity/*.rb'].each {|file| require file } if ENV["TeamCity"] == 1
|
2
|
+
|
3
|
+
module Sapphire
|
4
|
+
module Testing
|
5
|
+
module TeamCity
|
6
|
+
|
7
|
+
end
|
8
|
+
end
|
9
9
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module Testing
|
3
|
-
module Executable
|
4
|
-
def execute(reporter)
|
5
|
-
start = Time.now
|
6
|
-
reporter.TestStarted(self)
|
7
|
-
begin
|
8
|
-
if(self.value.is_a? Pending)
|
9
|
-
result = ResultTree.new(self.text, TestResult.new("pending", self, "Pending", "", Time.now - start))
|
10
|
-
self.AddResult(result)
|
11
|
-
reporter.TestPending result
|
12
|
-
return
|
13
|
-
end
|
14
|
-
self.block.call
|
15
|
-
result = ResultTree.new(self.text, TestResult.new("pass", self, "Success", "", Time.now - start))
|
16
|
-
self.AddResult(result)
|
17
|
-
reporter.TestPassed result
|
18
|
-
rescue => msg
|
19
|
-
stack = msg.backtrace
|
20
|
-
message = msg.messages if (msg.is_a? ExpectationException)
|
21
|
-
message ||= msg.message
|
22
|
-
result = ResultTree.new(self.text, TestResult.new("fail", self, message, stack, Time.now - start))
|
23
|
-
self.AddResult(result)
|
24
|
-
reporter.TestFailed result
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
1
|
+
module Sapphire
|
2
|
+
module Testing
|
3
|
+
module Executable
|
4
|
+
def execute(reporter)
|
5
|
+
start = Time.now
|
6
|
+
reporter.TestStarted(self)
|
7
|
+
begin
|
8
|
+
if(self.value.is_a? Pending)
|
9
|
+
result = ResultTree.new(self.text, TestResult.new("pending", self, "Pending", "", Time.now - start))
|
10
|
+
self.AddResult(result)
|
11
|
+
reporter.TestPending result
|
12
|
+
return
|
13
|
+
end
|
14
|
+
self.block.call
|
15
|
+
result = ResultTree.new(self.text, TestResult.new("pass", self, "Success", "", Time.now - start))
|
16
|
+
self.AddResult(result)
|
17
|
+
reporter.TestPassed result
|
18
|
+
rescue => msg
|
19
|
+
stack = msg.backtrace
|
20
|
+
message = msg.messages if (msg.is_a? ExpectationException)
|
21
|
+
message ||= msg.message
|
22
|
+
result = ResultTree.new(self.text, TestResult.new("fail", self, message, stack, Time.now - start))
|
23
|
+
self.AddResult(result)
|
24
|
+
reporter.TestFailed result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -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
|