rspec-example_steps 3.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/README.md +1 -81
- data/lib/rspec/example_steps.rb +0 -3
- data/rspec-example_steps.gemspec +1 -1
- metadata +8 -11
- data/lib/rspec/example_steps/shared_steps.rb +0 -20
- data/spec/shared_steps_spec.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8172abd39b0b7013b32df9b0975101cf9f40928b02b3be3a88e4abbcbe3b4f2
|
4
|
+
data.tar.gz: d69aa231297cefa1b45ee6fbbe7bbccc16572117f9bf066f20ad3eed50aaedd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dc7552ba3b6cc78140942dec817cb323a5721ebf920e344b9f61405bd4ea6e99e380ca4e68665a56a1a9672446150482790f60437d20efc5fe31b9a46c6829b
|
7
|
+
data.tar.gz: a06829b9fb3749a89c50abbd335f13ba3c7c1ff0d555a7bbc78aa980e43fc5cd81d50340fc1f3b0d4cde820636873a69d83b4384d5b65a8dcfbb9ab75335c542
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ This gem brings two major functionality to your `spec/features`
|
|
12
12
|
### Installation
|
13
13
|
|
14
14
|
* For rspec v2 use gem **v0.2.x** or rspec2 branch
|
15
|
-
* For rspec v3
|
15
|
+
* For rspec v3 use gem **v3.x.x** or master branch
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
gem 'rspec-example_steps'
|
@@ -60,86 +60,6 @@ Searching
|
|
60
60
|
Then I should see result
|
61
61
|
</pre>
|
62
62
|
|
63
|
-
### Shared steps
|
64
|
-
|
65
|
-
Use _shared_steps_ do define block that will be evaluated in the context of example using _include_steps_.
|
66
|
-
|
67
|
-
Shared _steps_ behavior is simular to shared _example_ but context is example nor example_group.
|
68
|
-
|
69
|
-
### Example with shared steps
|
70
|
-
|
71
|
-
```ruby
|
72
|
-
shared_steps 'login' do
|
73
|
-
When 'I go to login page' do
|
74
|
-
visit '/login'
|
75
|
-
end
|
76
|
-
When 'I put credentials' do
|
77
|
-
fill_in 'Login', with: 'jack@example.com'
|
78
|
-
fill_in 'Password', with: 'password'
|
79
|
-
end
|
80
|
-
Then 'I should be logged in' do
|
81
|
-
expect(page).to have_content('Welcome jack@example.com')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
shared_steps 'logout' do
|
86
|
-
visit '/logout'
|
87
|
-
expect(page.status_code).to eq(200)
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'user flow'
|
91
|
-
Steps 'User updates profile description' do
|
92
|
-
include_steps 'login'
|
93
|
-
When 'I update profile description' do
|
94
|
-
...
|
95
|
-
end
|
96
|
-
include_steps 'logout'
|
97
|
-
end
|
98
|
-
|
99
|
-
Steps 'User updates profile avatar' do
|
100
|
-
include_steps 'login'
|
101
|
-
When 'I update profile avatar' do
|
102
|
-
...
|
103
|
-
end
|
104
|
-
include_steps 'logout'
|
105
|
-
end
|
106
|
-
end
|
107
|
-
```
|
108
|
-
|
109
|
-
### Passing arguments to shared steps
|
110
|
-
|
111
|
-
It's possible to customize shared steps. See example
|
112
|
-
|
113
|
-
### Example with shared steps with arguments
|
114
|
-
|
115
|
-
```ruby
|
116
|
-
shared_steps 'login' do |email, password|
|
117
|
-
When 'I go to login page' do
|
118
|
-
page.visit '/login'
|
119
|
-
end
|
120
|
-
When 'I put credentials' do
|
121
|
-
fill_in 'Login', with: email
|
122
|
-
fill_in 'Password', with: password
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
shared_steps 'invalid login' do
|
127
|
-
Then 'I should see login error' do
|
128
|
-
...
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
Steps 'User provides wrong email' do
|
133
|
-
include_steps 'login', 'jack', 'qwerty'
|
134
|
-
include_steps 'invalid login'
|
135
|
-
end
|
136
|
-
|
137
|
-
Steps 'User provides wrong password' do
|
138
|
-
include_steps 'login', 'jack@example.com', 'bla'
|
139
|
-
include_steps 'invalid login'
|
140
|
-
end
|
141
|
-
```
|
142
|
-
|
143
63
|
### Pending steps
|
144
64
|
|
145
65
|
Simular to Example :pending behavior:
|
data/lib/rspec/example_steps.rb
CHANGED
@@ -23,6 +23,3 @@ if formatter = RSpec.world.reporter.find_registered_formatter(RSpec::Core::Forma
|
|
23
23
|
RSpec.world.reporter.register_listener formatter,
|
24
24
|
:example_started, :example_step_passed, :example_step_pending, :example_step_failed
|
25
25
|
end
|
26
|
-
|
27
|
-
require 'rspec/example_steps/shared_steps'
|
28
|
-
include RSpec::ExampleSteps::SharedSteps
|
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 = '3.0
|
6
|
+
s.version = '3.1.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'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-example_steps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andriy Yanko
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- andriy.yanko@gmail.com
|
30
30
|
executables: []
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- CHANGELOG.md
|
35
36
|
- Gemfile
|
36
37
|
- LICENSE
|
37
38
|
- README.md
|
@@ -41,18 +42,16 @@ files:
|
|
41
42
|
- lib/rspec/example_steps/example_group.rb
|
42
43
|
- lib/rspec/example_steps/notification.rb
|
43
44
|
- lib/rspec/example_steps/reporter.rb
|
44
|
-
- lib/rspec/example_steps/shared_steps.rb
|
45
45
|
- lib/rspec/example_steps/world.rb
|
46
46
|
- rspec-example_steps.gemspec
|
47
47
|
- spec/example_steps_spec.rb
|
48
48
|
- spec/regression_spec.rb
|
49
|
-
- spec/shared_steps_spec.rb
|
50
49
|
- spec/spec_helper.rb
|
51
50
|
homepage: https://github.com/railsware/rspec-example_steps
|
52
51
|
licenses:
|
53
52
|
- MIT
|
54
53
|
metadata: {}
|
55
|
-
post_install_message:
|
54
|
+
post_install_message:
|
56
55
|
rdoc_options: []
|
57
56
|
require_paths:
|
58
57
|
- lib
|
@@ -67,13 +66,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
66
|
- !ruby/object:Gem::Version
|
68
67
|
version: '0'
|
69
68
|
requirements: []
|
70
|
-
|
71
|
-
|
72
|
-
signing_key:
|
69
|
+
rubygems_version: 3.1.4
|
70
|
+
signing_key:
|
73
71
|
specification_version: 4
|
74
72
|
summary: Given/When/Then steps for RSpec examples
|
75
73
|
test_files:
|
76
74
|
- spec/example_steps_spec.rb
|
77
75
|
- spec/regression_spec.rb
|
78
|
-
- spec/shared_steps_spec.rb
|
79
76
|
- spec/spec_helper.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module ExampleSteps
|
3
|
-
module SharedSteps
|
4
|
-
|
5
|
-
def shared_steps(name, &block)
|
6
|
-
ensure_shared_example_steps_name_not_taken(name)
|
7
|
-
RSpec.world.shared_example_steps[name] = block
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def ensure_shared_example_steps_name_not_taken(name)
|
13
|
-
if RSpec.world.shared_example_steps.has_key?(name)
|
14
|
-
raise ArgumentError.new("Shared example steps '#{name}' already exists")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/spec/shared_steps_spec.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_steps "push steps" do
|
4
|
-
Given "empty pipe" do
|
5
|
-
pipe.clear
|
6
|
-
end
|
7
|
-
|
8
|
-
When "push data" do
|
9
|
-
pipe.push "hello"
|
10
|
-
end
|
11
|
-
|
12
|
-
Then "pipe should have data" do
|
13
|
-
expect(pipe.items).to eq(["hello"])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
shared_steps "push with arguments steps" do |value|
|
18
|
-
When "push data" do
|
19
|
-
pipe.push value
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
shared_steps "pull steps" do
|
24
|
-
When "pull data" do
|
25
|
-
pipe.pull
|
26
|
-
end
|
27
|
-
|
28
|
-
Then "pipe should be empty" do
|
29
|
-
expect(pipe.items).to eq([])
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "shared steps" do
|
34
|
-
|
35
|
-
let(:pipe) do
|
36
|
-
Class.new do
|
37
|
-
def initialize
|
38
|
-
@values = []
|
39
|
-
end
|
40
|
-
|
41
|
-
def items
|
42
|
-
@values
|
43
|
-
end
|
44
|
-
|
45
|
-
def clear
|
46
|
-
@values = []
|
47
|
-
end
|
48
|
-
|
49
|
-
def push(value)
|
50
|
-
@values << value
|
51
|
-
end
|
52
|
-
|
53
|
-
def pull
|
54
|
-
@values.shift
|
55
|
-
end
|
56
|
-
|
57
|
-
end.new
|
58
|
-
end
|
59
|
-
|
60
|
-
Steps "push and pull steps" do
|
61
|
-
include_steps "push steps"
|
62
|
-
include_steps "pull steps"
|
63
|
-
end
|
64
|
-
|
65
|
-
Steps "push, count and pull" do
|
66
|
-
include_steps "push steps"
|
67
|
-
Then "pipe should have 1 item" do
|
68
|
-
expect(pipe.items.size).to eq(1)
|
69
|
-
end
|
70
|
-
include_steps "pull steps"
|
71
|
-
end
|
72
|
-
|
73
|
-
Steps "push with arguments and pull" do
|
74
|
-
include_steps "push with arguments steps", "hi"
|
75
|
-
expect(pipe.items).to eq(["hi"])
|
76
|
-
include_steps "pull steps"
|
77
|
-
end
|
78
|
-
end
|