rspec-example_steps 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -43,6 +43,11 @@ module RSpec
|
|
43
43
|
|
44
44
|
output.puts yellow(full_message)
|
45
45
|
end
|
46
|
+
|
47
|
+
def example_step_failed(example_group, type, message, options)
|
48
|
+
full_message = "#{current_indentation} #{type.to_s.capitalize} #{message} (FAILED)"
|
49
|
+
output.puts red(full_message)
|
50
|
+
end
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
@@ -11,7 +11,12 @@ module RSpec
|
|
11
11
|
def Given(message, options = {})
|
12
12
|
RSpec.world.reporter.example_step_started(self, :given, message, options)
|
13
13
|
if block_given? && !options[:pending]
|
14
|
-
|
14
|
+
begin
|
15
|
+
yield
|
16
|
+
rescue Exception => e
|
17
|
+
RSpec.world.reporter.example_step_failed(self, :given, message, options)
|
18
|
+
raise e
|
19
|
+
end
|
15
20
|
RSpec.world.reporter.example_step_passed(self, :given, message, options)
|
16
21
|
else
|
17
22
|
RSpec.world.reporter.example_step_pending(self, :given, message, options)
|
@@ -21,7 +26,12 @@ module RSpec
|
|
21
26
|
def When(message, options = {})
|
22
27
|
RSpec.world.reporter.example_step_started(self, :when, message, options)
|
23
28
|
if block_given? && !options[:pending]
|
24
|
-
|
29
|
+
begin
|
30
|
+
yield
|
31
|
+
rescue Exception => e
|
32
|
+
RSpec.world.reporter.example_step_failed(self, :when, message, options)
|
33
|
+
raise e
|
34
|
+
end
|
25
35
|
RSpec.world.reporter.example_step_passed(self, :when, message, options)
|
26
36
|
else
|
27
37
|
RSpec.world.reporter.example_step_pending(self, :when, message, options)
|
@@ -31,7 +41,12 @@ module RSpec
|
|
31
41
|
def Then(message, options = {})
|
32
42
|
RSpec.world.reporter.example_step_started(self, :then, message, options)
|
33
43
|
if block_given? && !options[:pending]
|
34
|
-
|
44
|
+
begin
|
45
|
+
yield
|
46
|
+
rescue Exception => e
|
47
|
+
RSpec.world.reporter.example_step_failed(self, :then, message, options)
|
48
|
+
raise e
|
49
|
+
end
|
35
50
|
RSpec.world.reporter.example_step_passed(self, :then, message, options)
|
36
51
|
else
|
37
52
|
RSpec.world.reporter.example_step_pending(self, :then, message, options)
|
@@ -41,7 +56,12 @@ module RSpec
|
|
41
56
|
def And(message, options = {})
|
42
57
|
RSpec.world.reporter.example_step_started(self, :and, message, options)
|
43
58
|
if block_given? && !options[:pending]
|
44
|
-
|
59
|
+
begin
|
60
|
+
yield
|
61
|
+
rescue Exception => e
|
62
|
+
RSpec.world.reporter.example_step_failed(self, :and, message, options)
|
63
|
+
raise e
|
64
|
+
end
|
45
65
|
RSpec.world.reporter.example_step_passed(self, :and, message, options)
|
46
66
|
else
|
47
67
|
RSpec.world.reporter.example_step_pending(self, :and, message, options)
|
@@ -51,12 +71,18 @@ module RSpec
|
|
51
71
|
def But(message, options = {})
|
52
72
|
RSpec.world.reporter.example_step_started(self, :but, message, options)
|
53
73
|
if block_given? && !options[:pending]
|
54
|
-
|
74
|
+
begin
|
75
|
+
yield
|
76
|
+
rescue Exception => e
|
77
|
+
RSpec.world.reporter.example_step_failed(self, :but, message, options)
|
78
|
+
raise e
|
79
|
+
end
|
55
80
|
RSpec.world.reporter.example_step_passed(self, :but, message, options)
|
56
81
|
else
|
57
82
|
RSpec.world.reporter.example_step_pending(self, :but, message, options)
|
58
83
|
end
|
59
84
|
end
|
85
|
+
|
60
86
|
end
|
61
87
|
end
|
62
88
|
end
|
data/rspec-example_steps.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rspec-example_steps"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
s.authors = ["Andriy Yanko"]
|
8
8
|
s.email = ["andriy.yanko@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/railsware/rspec-example_steps"
|
data/spec/example_steps_spec.rb
CHANGED
@@ -36,23 +36,23 @@ describe "example steps" do
|
|
36
36
|
|
37
37
|
describe "Steps without blocks" do
|
38
38
|
Steps "they should be pending" do
|
39
|
-
Given "
|
40
|
-
Then "
|
41
|
-
When "
|
39
|
+
Given "step without block"
|
40
|
+
Then "step without block"
|
41
|
+
When "step without block"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "Steps with :pending option" do
|
46
46
|
Steps "they should be pending when :pending => true" do
|
47
|
-
Given "
|
47
|
+
Given "step with :pending option", :pending => true do
|
48
48
|
raise "Should not be evaluated"
|
49
49
|
end
|
50
50
|
|
51
|
-
When "
|
51
|
+
When "step with :pending option", :pending => true do
|
52
52
|
raise "Should not be evaluated"
|
53
53
|
end
|
54
54
|
|
55
|
-
Then "
|
55
|
+
Then "step with :pending option", :pending => true do
|
56
56
|
raise "Should not be evaluated"
|
57
57
|
end
|
58
58
|
|
@@ -66,34 +66,68 @@ describe "example steps" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
Steps "they should be pending when :pending => STRING" do
|
69
|
-
Given "
|
69
|
+
Given "step with :pending option", :pending => "WIP" do
|
70
70
|
raise "Should not be evaluated"
|
71
71
|
end
|
72
72
|
|
73
|
-
When "
|
73
|
+
When "step with :pending option", :pending => "POSTPONED" do
|
74
74
|
raise "Should not be evaluated"
|
75
75
|
end
|
76
76
|
|
77
|
-
Then "
|
77
|
+
Then "step with :pending option", :pending => "DELAYED" do
|
78
78
|
raise "Should not be evaluated"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
Steps "they should NOT be pending when :pending => false" do
|
83
|
-
Given "
|
83
|
+
Given "step with :pending option", :pending => false do
|
84
84
|
end
|
85
85
|
|
86
|
-
When "
|
86
|
+
When "step with :pending option", :pending => false do
|
87
87
|
end
|
88
88
|
|
89
|
-
Then "
|
89
|
+
Then "step with :pending option", :pending => false do
|
90
90
|
end
|
91
91
|
|
92
|
-
And "
|
92
|
+
And "step with :pending option", :pending => false do
|
93
93
|
end
|
94
94
|
|
95
|
-
But "
|
95
|
+
But "step with :pending option", :pending => false do
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
describe "Failed steps" do
|
103
|
+
|
104
|
+
Steps "Given fails" do
|
105
|
+
Given "thing" do
|
106
|
+
1/0
|
107
|
+
end
|
108
|
+
|
109
|
+
Then "I should see error" do
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
Steps "When fails" do
|
115
|
+
When "action" do
|
116
|
+
(2*2).should == 5
|
117
|
+
end
|
118
|
+
|
119
|
+
Then "I should see error" do
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
Steps "Then fails" do
|
124
|
+
Then "result" do
|
125
|
+
raise Exception
|
126
|
+
end
|
127
|
+
|
128
|
+
Then "I should see error" do
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
99
133
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-example_steps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andriy Yanko
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-05 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|