rspec-example_steps 0.1.0 → 0.1.1
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.
- data/README.md +20 -0
- data/lib/rspec/example_steps/base_formatter.rb +4 -4
- data/lib/rspec/example_steps/documentation_formatter.rb +13 -1
- data/lib/rspec/example_steps/example_group.rb +25 -12
- data/lib/rspec/example_steps/reporter.rb +8 -8
- data/rspec-example_steps.gemspec +1 -1
- data/spec/example_steps_spec.rb +49 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -110,6 +110,26 @@ It's possible to customize shared steps. See example
|
|
110
110
|
include_steps "invalid login"
|
111
111
|
end
|
112
112
|
|
113
|
+
|
114
|
+
### Pending steps
|
115
|
+
|
116
|
+
Simular to Example :pending behavior:
|
117
|
+
|
118
|
+
Steps "User login" do
|
119
|
+
# just skip block
|
120
|
+
When "I go to login"
|
121
|
+
|
122
|
+
# pass :pending => true option
|
123
|
+
Then "I should see welcome", :pending => true do
|
124
|
+
...
|
125
|
+
end
|
126
|
+
|
127
|
+
# pass :pending => "some pending message"
|
128
|
+
Then "I should see last login IP", :pending => "WIP" do
|
129
|
+
...
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
113
133
|
## Alternatives
|
114
134
|
|
115
135
|
* [rspec-steps](https://github.com/LRDesign/rspec-steps)
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module RSpec
|
2
2
|
module ExampleSteps
|
3
3
|
module BaseFormatter
|
4
|
-
def example_step_started(example, type, message)
|
4
|
+
def example_step_started(example, type, message, options)
|
5
5
|
end
|
6
6
|
|
7
|
-
def example_step_passed(example, type, message)
|
7
|
+
def example_step_passed(example, type, message, options)
|
8
8
|
end
|
9
9
|
|
10
|
-
def example_step_pending(example, type, message)
|
10
|
+
def example_step_pending(example, type, message, options)
|
11
11
|
end
|
12
12
|
|
13
|
-
def example_step_failed(example, type, message)
|
13
|
+
def example_step_failed(example, type, message, options)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -27,10 +27,22 @@ module RSpec
|
|
27
27
|
example_passed_without_steps(example) unless example.options[:with_steps]
|
28
28
|
end
|
29
29
|
|
30
|
-
def example_step_passed(example_group, type, message)
|
30
|
+
def example_step_passed(example_group, type, message, options)
|
31
31
|
full_message = "#{current_indentation} #{type.to_s.capitalize} #{message}"
|
32
32
|
output.puts green(full_message)
|
33
33
|
end
|
34
|
+
|
35
|
+
def example_step_pending(example_group, type, message, options)
|
36
|
+
full_message = "#{current_indentation} #{type.to_s.capitalize} #{message}"
|
37
|
+
|
38
|
+
if options[:pending] && options[:pending] != true
|
39
|
+
full_message << " (PENDING: #{options[:pending]})"
|
40
|
+
else
|
41
|
+
full_message << " (PENDING)"
|
42
|
+
end
|
43
|
+
|
44
|
+
output.puts yellow(full_message)
|
45
|
+
end
|
34
46
|
end
|
35
47
|
end
|
36
48
|
end
|
@@ -8,23 +8,36 @@ module RSpec
|
|
8
8
|
instance_eval_with_args(*args, &shared_block)
|
9
9
|
end
|
10
10
|
|
11
|
-
def Given(message)
|
12
|
-
RSpec.world.reporter.example_step_started(self, :given, message)
|
13
|
-
|
14
|
-
|
11
|
+
def Given(message, options = {})
|
12
|
+
RSpec.world.reporter.example_step_started(self, :given, message, options)
|
13
|
+
if block_given? && !options[:pending]
|
14
|
+
yield
|
15
|
+
RSpec.world.reporter.example_step_passed(self, :given, message, options)
|
16
|
+
else
|
17
|
+
RSpec.world.reporter.example_step_pending(self, :given, message, options)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
|
-
def When(message)
|
18
|
-
RSpec.world.reporter.example_step_started(self, :when, message)
|
19
|
-
|
20
|
-
|
21
|
+
def When(message, options = {})
|
22
|
+
RSpec.world.reporter.example_step_started(self, :when, message, options)
|
23
|
+
if block_given? && !options[:pending]
|
24
|
+
yield
|
25
|
+
RSpec.world.reporter.example_step_passed(self, :when, message, options)
|
26
|
+
else
|
27
|
+
RSpec.world.reporter.example_step_pending(self, :when, message, options)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
|
-
def Then(message)
|
24
|
-
RSpec.world.reporter.example_step_started(self, :then, message)
|
25
|
-
|
26
|
-
|
31
|
+
def Then(message, options = {})
|
32
|
+
RSpec.world.reporter.example_step_started(self, :then, message, options)
|
33
|
+
if block_given? && !options[:pending]
|
34
|
+
yield
|
35
|
+
RSpec.world.reporter.example_step_passed(self, :then, message, options)
|
36
|
+
else
|
37
|
+
RSpec.world.reporter.example_step_pending(self, :then, message, options)
|
38
|
+
end
|
27
39
|
end
|
40
|
+
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module RSpec
|
2
2
|
module ExampleSteps
|
3
3
|
module Reporter
|
4
|
-
def example_step_started(example, type, message)
|
5
|
-
notify :example_step_started, example, type, message
|
4
|
+
def example_step_started(example, type, message, options)
|
5
|
+
notify :example_step_started, example, type, message, options
|
6
6
|
end
|
7
7
|
|
8
|
-
def example_step_passed(example, type, message)
|
9
|
-
notify :example_step_passed, example, type, message
|
8
|
+
def example_step_passed(example, type, message, options)
|
9
|
+
notify :example_step_passed, example, type, message, options
|
10
10
|
end
|
11
11
|
|
12
|
-
def example_step_pending(example, type, message)
|
13
|
-
notify :example_step_pending, example, type, message
|
12
|
+
def example_step_pending(example, type, message, options)
|
13
|
+
notify :example_step_pending, example, type, message, options
|
14
14
|
end
|
15
15
|
|
16
|
-
def example_step_failed(example, type, message)
|
17
|
-
notify :example_step_failed, example, type, message
|
16
|
+
def example_step_failed(example, type, message, options)
|
17
|
+
notify :example_step_failed, example, type, message, options
|
18
18
|
end
|
19
19
|
end
|
20
20
|
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.1.
|
6
|
+
s.version = "0.1.1"
|
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
@@ -23,4 +23,53 @@ describe "example steps" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
|
27
|
+
describe "Steps without blocks" do
|
28
|
+
Steps "they should be pending" do
|
29
|
+
Given "given step without block"
|
30
|
+
Then "then step without block"
|
31
|
+
When "when step without block"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Steps with :pending option" do
|
36
|
+
Steps "they should be pending when :pending => true" do
|
37
|
+
Given "given step with :pending option", :pending => true do
|
38
|
+
raise "Should not be evaluated"
|
39
|
+
end
|
40
|
+
|
41
|
+
When "when step with :pending option", :pending => true do
|
42
|
+
raise "Should not be evaluated"
|
43
|
+
end
|
44
|
+
|
45
|
+
Then "then step with :pending option", :pending => true do
|
46
|
+
raise "Should not be evaluated"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Steps "they should be pending when :pending => STRING" do
|
51
|
+
Given "given step with :pending option", :pending => "WIP" do
|
52
|
+
raise "Should not be evaluated"
|
53
|
+
end
|
54
|
+
|
55
|
+
When "when step with :pending option", :pending => "POSTPONED" do
|
56
|
+
raise "Should not be evaluated"
|
57
|
+
end
|
58
|
+
|
59
|
+
Then "then step with :pending option", :pending => "DELAYED" do
|
60
|
+
raise "Should not be evaluated"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
Steps "they should NOT be pending when :pending => false" do
|
65
|
+
Given "given step with :pending option", :pending => false do
|
66
|
+
end
|
67
|
+
|
68
|
+
When "when step with :pending option", :pending => false do
|
69
|
+
end
|
70
|
+
|
71
|
+
Then "then step with :pending option", :pending => false do
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
26
75
|
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: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andriy Yanko
|