sapphire 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,8 +15,8 @@ module Sapphire
15
15
  @and = []
16
16
  end
17
17
 
18
- def add_and(text, &block)
19
- self.and << Then.new(text, &block)
18
+ def add_and( text, &block)
19
+ self.and << And.new(self, text, &block)
20
20
  end
21
21
 
22
22
  def to_s
@@ -22,7 +22,7 @@ class Given
22
22
 
23
23
  def add_when(pre, text, &block)
24
24
  if(self.value.is_a? Pending)
25
- @when << When.new(self, pre, Pending.new(text), &block)
25
+ @when << When.new(self, pre, Pending.new(text.to_s), &block)
26
26
  elsif(self.value.is_a? Problematic)
27
27
  @when << When.new(self, pre, Problematic.new(text), &block)
28
28
  else
@@ -36,22 +36,16 @@ class Given
36
36
  end
37
37
 
38
38
  def add_finally(finally)
39
- if(self.value.is_a? Pending)
40
- @finally = Finally.new(self, Pending.new(finally.text), &block)
41
- elsif(self.value.is_a? Problematic)
42
- @finally = Finally.new(self, Problematic.new(finally.text), &block)
43
- else
44
- @finally = finally
45
- end
39
+ @finally = finally
46
40
  end
47
41
 
48
42
  def add_and(pre, text, &block)
49
- if(self.value.is_a? Pending)
50
- self.and << And.new(self, Pending.new(pre + text), &block)
43
+ if(self.value.is_a? Pending or text.is_a? Pending)
44
+ self.and << And.new(self, Pending.new(pre + text.to_s), &block)
51
45
  elsif(self.value.is_a? Problematic)
52
- self.and << And.new(self, Problematic.new(pre + text), &block)
46
+ self.and << And.new(self, Problematic.new(pre + text.to_s), &block)
53
47
  else
54
- self.and << And.new(self, pre + text, &block)
48
+ self.and << And.new(self, pre + text.to_s, &block)
55
49
  end
56
50
  end
57
51
 
@@ -18,12 +18,12 @@ class Then
18
18
  end
19
19
 
20
20
  def add_and(pre, text, &block)
21
- if(self.value.instance_of? Pending)
22
- self.and << And.new(self, Pending.new(text), &block)
21
+ if(self.value.instance_of? Pending or text.is_a? Pending)
22
+ self.and << And.new(self, Pending.new(pre + text.to_s), &block)
23
23
  elsif(self.value.instance_of? Problematic)
24
24
  self.and << And.new(self, Problematic.new(pre + text), &block)
25
25
  else
26
- x = And.new(self, text, &block)
26
+ x = And.new(self, pre + text.to_s, &block)
27
27
  self.and << x
28
28
  end
29
29
  end
@@ -20,8 +20,8 @@ class When
20
20
  end
21
21
 
22
22
  def add_then(pre, text, &block)
23
- if(self.value.is_a? Pending)
24
- @then << Then.new(self, pre, Pending.new(text), &block)
23
+ if(self.value.is_a? Pending or text.is_a? Pending)
24
+ @then << Then.new(self, pre, Pending.new(text.to_s), &block)
25
25
  elsif(self.value.is_a? Problematic)
26
26
  @then << Then.new(self, pre, Problematic.new(text), &block)
27
27
  else
@@ -30,12 +30,12 @@ class When
30
30
  end
31
31
 
32
32
  def add_and(pre, text, &block)
33
- if(self.value.is_a? Pending)
34
- self.and << And.new(self, Pending.new(text), &block)
33
+ if(self.value.is_a? Pending or text.is_a? Pending)
34
+ self.and << And.new(self, Pending.new(pre + text.to_s), &block)
35
35
  elsif(self.value.is_a? Problematic)
36
36
  self.and << And.new(self, Problematic.new(pre + text), &block)
37
37
  else
38
- self.and << And.new(self, pre + text, &block)
38
+ self.and << And.new(self, pre + text.to_s, &block)
39
39
  end
40
40
  end
41
41
 
@@ -30,17 +30,17 @@ module Sapphire
30
30
  Indent(depth)
31
31
 
32
32
  if result.type == 'pass'
33
- @output.puts result.text.colorize :green
33
+ @output.puts result.text
34
34
  elsif result.type == 'pending'
35
- @output.puts result.text.colorize :yellow
35
+ @output.puts result.text
36
36
  Indent(depth+1)
37
37
  @output.puts " ## Not Yet Implemented ##"
38
38
  elsif result.type == 'problematic'
39
- @output.puts result.text.colorize :orange
39
+ @output.puts result.text
40
40
  Indent(depth+1)
41
41
  @output.puts " ## Problematic ##"
42
42
  else
43
- @output.puts result.text.colorize :red
43
+ @output.puts result.text
44
44
  if result.messages.is_a? Array
45
45
  result.messages.each do |message|
46
46
  Indent(depth+1)
@@ -72,41 +72,43 @@ module Sapphire
72
72
 
73
73
  def TestPassed(test)
74
74
  @passing_count = @passing_count + 1
75
- @output.print ".".colorize :green
75
+ @output.print "."
76
76
  end
77
77
 
78
78
  def TestFailed(test)
79
79
  @failing_count = @failing_count + 1
80
80
  Add test
81
- @output.print "F".colorize :red
81
+ @output.print "F"
82
82
  end
83
83
 
84
84
  def TestPending(test)
85
85
  @pending_count = @pending_count + 1
86
86
  Add test
87
- @output.print "*".colorize :yellow
87
+ @output.print "*"
88
88
  end
89
89
 
90
90
  def TestProblematic(test)
91
91
  @problematic_count = @problematic_count + 1
92
92
  Add test
93
93
  #look of disapproval
94
- @output.print "\u0CA0_\u0CA0".colorize :orange
94
+ @output.print "\u0CA0_\u0CA0"
95
95
  end
96
96
 
97
97
  def Add(r)
98
98
  result_passes = r.type == "pass"
99
99
 
100
- if !result_passes and (r.item.is_a? Given or r.item.is_a? When or r.item.is_a? Background)
101
- @not_passing = @not_passing.merge({ r => r })
102
- elsif !result_passes and (r.item.is_a? And or r.item.parent.is_a? Given)
103
- @not_passing = @not_passing.merge({ r.parent => r.parent })
100
+ if !result_passes and (r.item.is_a? Given or r.item.is_a? Background)
101
+ @not_passing = @not_passing.merge!({ r => r })
102
+ elsif !result_passes and (r.item.is_a? When)
103
+ @not_passing = @not_passing.merge!({ r.parent => r.parent })
104
+ elsif !result_passes and (r.item.is_a? And and r.item.parent.is_a? Given)
105
+ @not_passing = @not_passing.merge!({ r.parent => r.parent })
104
106
  elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? When)
105
- @not_passing = @not_passing.merge({ r.parent => r.parent })
107
+ @not_passing = @not_passing.merge!({ r.parent.parent => r.parent.parent })
106
108
  elsif !result_passes and (r.item.is_a? Then)
107
- @not_passing = @not_passing.merge({ r.parent => r.parent })
109
+ @not_passing = @not_passing.merge!({ r.parent.parent => r.parent.parent })
108
110
  elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? Then)
109
- @not_passing = @not_passing.merge({ r.parent.parent => r.parent.parent })
111
+ @not_passing = @not_passing.merge!({ r.parent.parent.parent => r.parent.parent.parent })
110
112
  end
111
113
 
112
114
  end
@@ -114,6 +116,7 @@ module Sapphire
114
116
  def OutputResults()
115
117
  @output.puts ""
116
118
 
119
+
117
120
  @not_passing.keys.each do |key|
118
121
  self.PrintResult @not_passing[key]
119
122
  end
@@ -121,10 +124,10 @@ module Sapphire
121
124
  @output.puts ""
122
125
  @output.puts "Finished in " + (@end - @start).round().to_s + " seconds."
123
126
  @output.puts "Test Count: " + @test_count.to_s
124
- @output.puts "Passing: " + @passing_count.to_s.colorize(:green)
125
- @output.puts "Failing: " + @failing_count.to_s.colorize(:red)
126
- @output.puts "Pending: " + @pending_count.to_s.colorize(:yellow)
127
- @output.puts "Problematic: " + @problematic_count.to_s.colorize(:orange)
127
+ @output.puts "Passing: " + @passing_count.to_s
128
+ @output.puts "Failing: " + @failing_count.to_s
129
+ @output.puts "Pending: " + @pending_count.to_s
130
+ @output.puts "Problematic: " + @problematic_count.to_s
128
131
  end
129
132
 
130
133
  def Output(result, depth)
@@ -1,6 +1,16 @@
1
1
  module Sapphire
2
2
  module Testing
3
3
  module Executable
4
+
5
+ def pend()
6
+ start = Time.now
7
+ Report do |x| x.TestStarted(self) end
8
+
9
+ result = ResultTree.new(self.text, TestResult.new("pending", self, "Pending", "", Time.now - start))
10
+ self.AddResult(result)
11
+ Report do |x| x.TestPending(result) end
12
+ end
13
+
4
14
  def execute()
5
15
  start = Time.now
6
16
  Report do |x| x.TestStarted(self) end
@@ -18,10 +18,6 @@ module Sapphire
18
18
 
19
19
  if(result != nil)
20
20
  self.type = result.type
21
- @iconCls = "accept" if result.type == "pass"
22
- @iconCls = "delete" if result.type == "fail"
23
- @iconCls = "error" if result.type == "pending"
24
- @iconCls = "error" if result.type == "problematic"
25
21
  @time = result.execution_time
26
22
  @expanded = true
27
23
  @messages = result.messages
@@ -9,46 +9,56 @@ module Sapphire
9
9
  end
10
10
 
11
11
  def execute()
12
- Report do |x| x.ScenarioStart(self) end
12
+ Report do |reporter| reporter.ScenarioStart(self) end
13
13
 
14
- self.backgrounds.each do |b|
14
+ self.backgrounds.each do |background|
15
15
 
16
- b.execute
16
+ background.execute
17
17
 
18
- b.and.each do |g_a|
18
+ background.and.each do |background_and|
19
19
 
20
- g_a.execute
20
+ background_and.execute
21
21
 
22
22
  end
23
23
 
24
24
  end
25
25
 
26
- self.givens.each do |g|
27
- g.when.each do |w|
26
+ self.givens.each do |given|
27
+ given.when.each do |when_|
28
28
 
29
- g.execute
29
+ if when_.value.is_a? Pending
30
+ given.pend()
30
31
 
31
- g.and.each do |g_a|
32
+ given.and.each do |given_and|
32
33
 
33
- g_a.execute
34
+ given_and.pend()
34
35
 
36
+ end
37
+ else
38
+ given.execute()
39
+
40
+ given.and.each do |given_and|
41
+
42
+ given_and.execute()
43
+
44
+ end
35
45
  end
36
46
 
37
- w.execute
47
+ when_.execute
38
48
 
39
- w.and.each do |w_a|
49
+ when_.and.each do |when_and|
40
50
 
41
- w_a.execute
51
+ when_and.execute
42
52
 
43
53
  end
44
54
 
45
- w.then.each do |t|
55
+ when_.then.each do |then_|
46
56
 
47
- t.execute
57
+ then_.execute
48
58
 
49
- t.and.each do |t_a|
59
+ then_.and.each do |then_and|
50
60
 
51
- t_a.execute
61
+ then_and.execute
52
62
 
53
63
  end
54
64
 
@@ -56,15 +66,15 @@ module Sapphire
56
66
 
57
67
  end
58
68
 
59
- if(g.finally)
69
+ if(given.finally)
60
70
 
61
- g.finally.execute
71
+ given.finally.execute
62
72
 
63
73
  end
64
74
 
65
75
  end
66
76
 
67
- Report do |x| x.ScenarioComplete(self) end
77
+ Report do |reporter| reporter.ScenarioComplete(self) end
68
78
 
69
79
  end
70
80
  end
@@ -40,7 +40,7 @@ module Sapphire
40
40
  x = self.FindAll
41
41
  x.each do |item|
42
42
  if item.text.include? value
43
- return Evaluation.new(item.text, value)
43
+ return ContainsComparison.new(Evaluation.new(value, item.text))
44
44
  end
45
45
  end
46
46
 
@@ -1,3 +1,3 @@
1
1
  module Sapphire
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.2"
3
3
  end
data/lib/sapphire.rb CHANGED
@@ -6,7 +6,6 @@ require 'yaml'
6
6
  require 'selenium-webdriver'
7
7
  require 'delegate'
8
8
  require 'Forwardable'
9
- require 'colorize'
10
9
 
11
10
  require 'sapphire/Adapters'
12
11
  require 'sapphire/Testing'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapphire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-25 00:00:00.000000000Z
12
+ date: 2012-02-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: selenium-webdriver
16
- requirement: &9901632 !ruby/object:Gem::Requirement
16
+ requirement: &9963168 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9901632
24
+ version_requirements: *9963168
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: colorize
27
- requirement: &9901380 !ruby/object:Gem::Requirement
27
+ requirement: &9962916 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9901380
35
+ version_requirements: *9962916
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: Platform
38
- requirement: &9901128 !ruby/object:Gem::Requirement
38
+ requirement: &9962664 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *9901128
46
+ version_requirements: *9962664
47
47
  description: An automated web acceptance test framework for non-technical resources
48
48
  using selenium-wedriver.
49
49
  email:
@@ -163,8 +163,6 @@ files:
163
163
  - lib/sapphire/Extensions/Symbol.rb
164
164
  - lib/sapphire/Extensions.rb
165
165
  - lib/sapphire/JobAbstractions/Job.rb
166
- - lib/sapphire/Sessions/Parameter.rb
167
- - lib/sapphire/Sessions/Storage.rb
168
166
  - lib/sapphire/TeamCity/TeamCityReporter.rb
169
167
  - lib/sapphire/TeamCity.rb
170
168
  - lib/sapphire/Testing/ConsoleReporter.rb
@@ -1,36 +0,0 @@
1
- module Sapphire
2
- module Sessions
3
-
4
- def Parameter(item)
5
- Parameters.instance.Add(item) if item.is_a? Hash
6
- return Parameters.instance.Get(item) if item.is_a? Symbol
7
- end
8
-
9
- class Parameters
10
- def self.create
11
- @@instance ||= Parameters.new
12
- end
13
-
14
- def self.instance
15
- @@instance ||= self.create
16
- end
17
-
18
- def initialize()
19
- $parameters ||= {}
20
- end
21
-
22
- def Add(item)
23
- $parameters.merge! item
24
- end
25
-
26
- def Contains(item)
27
- $parameters.has_key? item
28
- end
29
-
30
- def Get(item)
31
- $parameters[item]
32
- end
33
- end
34
-
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- module Sapphire
2
- module Sessions
3
- class Storage
4
- def self.create
5
- @@instance ||= Storage.new
6
- end
7
-
8
- def self.instance
9
- @@instance ||= self.create
10
- end
11
-
12
- def initialize()
13
- $storage ||= {}
14
- end
15
- end
16
- end
17
- end