bdd 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a73861eaae60c9c300da0022a697fbdcffc59882
4
- data.tar.gz: d386090a5cdfe7b6bb243a56b87437ce43d30e45
3
+ metadata.gz: 1bbba94ca8816485d96068bc62f9fb67718f7398
4
+ data.tar.gz: 77460d66dffe6fede33b6ac1f6d682845f772a46
5
5
  SHA512:
6
- metadata.gz: d189b18b77943cf11878920d44a191112eb8a73512403a06ce148e54bb96d8f17a0b7deff81370830fc9b62dc12348d07d441599f081ab78754c7a0fbc4088b3
7
- data.tar.gz: 7f48aa1010cb8cbc26bdc3dc132c0acad3faadfce729c451b90a01428584792f01eb87ad40b65c9c4ab8a5d16215860b20a3a44ebbfa9b533920e6b194ec6576
6
+ metadata.gz: 592c999c12b91ac8e6ecfa662671ec2a2db8af1b33401f2ba7413212a12c5df7b72949610c41f72490e712a4ffac165d0d06b79c4fdc69f8e1647b1a47d19e3a
7
+ data.tar.gz: a730d892831dd0074ff7467512dd9efe60e8109f7ccf16e75097e90bdaf4eb54be2942982c2df2e1901290a24b1d495e4f14e9053feb7a39f7bfc83b8b3e9d6a
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.5
6
- - 2.2.1
7
- script: bundle exec rspec spec
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.1
7
+ - ruby-head
8
+ script: bundle exec rspec spec
9
+ cache:
10
+ - bundler
11
+ - apt
data/README.md CHANGED
@@ -1,17 +1,15 @@
1
1
  ## Bdd
2
2
 
3
- Bdd brings cucumber-style Given/When/Then/And/But steps for RSpec examples
3
+ Bdd brings you cucumber-style Given/When/Then/And/But test reports
4
4
 
5
5
  ### Status
6
6
 
7
- | Master | Gem Version |
8
- | :----: | :----: |
9
- | [![Master Build Status](https://img.shields.io/travis/thejamespinto/bdd.svg)](https://travis-ci.org/thejamespinto/bdd) | [![Gem Version](https://img.shields.io/gem/v/bdd.svg)](https://rubygems.org/gems/bdd) |
10
-
7
+ | Our Tests | Latest Version | # of Downloads | Contribute |
8
+ | :----: | :----: | :----: | :----: |
9
+ | [![Master Build Status](https://travis-ci.org/thejamespinto/bdd.svg?branch=master)](https://travis-ci.org/thejamespinto/bdd) | [![Gem Version](https://img.shields.io/gem/v/bdd.svg)](https://rubygems.org/gems/bdd) | [![Downloads](http://img.shields.io/gem/dt/bdd.svg)](https://rubygems.org/gems/bdd) | [![GitHub Issues](https://img.shields.io/github/issues/thejamespinto/bdd.svg)](https://rubygems.org/gems/bdd) |
11
10
 
12
11
  [![GitHub License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://rubygems.org/gems/bdd)
13
- [![Gem Downloads](http://img.shields.io/gem/dt/bdd.svg)](https://rubygems.org/gems/bdd)
14
- [![GitHub Issues](https://img.shields.io/github/issues/thejamespinto/bdd.svg)](https://rubygems.org/gems/bdd)
12
+
15
13
 
16
14
 
17
15
 
@@ -24,289 +22,139 @@ This gem brings two major functionality to your tests
24
22
 
25
23
 
26
24
 
25
+
26
+
27
+
28
+
29
+
27
30
  ## Installation
28
31
 
29
32
  Include in your Gemfile:
30
33
 
31
34
  ```ruby
32
35
  group :test do
33
- gem 'bdd'
36
+ # pick one
37
+ gem 'bdd', require: 'bdd/rspec'
38
+ gem 'bdd', require: 'bdd/minitest'
34
39
  end
35
40
  ```
36
41
 
37
- ### RSpec
38
-
39
- Run specs with custom format specified inline:
40
42
 
41
- `
42
- rspec --format Bdd::RSpec::Formatter --color spec
43
- `
44
43
 
45
- Or, if you want to use as your default formatter, simply put the options in your .rspec file:
46
44
 
47
- `.rspec`
48
-
49
- ```yml
50
- --format Bdd::RSpec::Formatter
51
- --color
52
- ```
53
-
54
- ## Output Example
55
-
56
- `spec/features/search_spec.rb`
45
+ ### Installation For RSpec
57
46
 
58
47
  ```ruby
59
- context 'Searching' do
60
- it 'Result is found' do
61
- Given 'I am on the search page' do
62
- visit '/search'
63
- expect(page).to have_content('Search')
64
- end
65
-
66
- When 'I search something' do
67
- fill_in 'Search', with: 'John'
68
- click_button 'Go'
69
- end
70
-
71
- Then 'I should see the word result' do
72
- expect(page).to have_content('Result')
73
- end
74
- end
48
+ group :test do
49
+ gem 'rspec'
50
+ gem 'bdd', require: 'bdd/rspec'
75
51
  end
76
52
  ```
77
53
 
78
-
79
- ### Documentation formatting output:
80
-
81
- `rspec -fd spec/features/search_spec.rb`
82
-
83
- <pre>
84
- <b>Searching</b>
85
- <b>Result is found</b>
86
- <b>Given</b> I am on the search page
87
- <b> When</b> I search something
88
- <b> Then</b> I should see the word result
89
- </pre>
90
-
91
-
92
- ### Shared Steps
93
-
94
- ### Basic Example with shared steps
95
-
96
- You can refactor steps into methods using plain Ruby syntax.
54
+ Add this to your `spec/spec_helper.rb` file.
97
55
 
98
56
  ```ruby
99
- def given_I_log_in
100
- Given "I log in" do
101
- visit '/login'
102
- fill_in 'Login', with: 'jack@example.com'
103
- fill_in 'Password', with: 'password'
104
- click_button "Log in"
105
- expect(page).to have_content('Welcome jack@example.com')
106
- end
57
+ RSpec.configure do |config|
58
+ config.color = true
59
+ config.default_formatter = Bdd::RSpec::Formatter
107
60
  end
108
61
 
109
- def then_I_should_see_a_confirmation_message
110
- Then "I should see a confirmation message" do
111
- expect(page).to have_content('Your profile was updated successfully')
112
- end
113
- end
62
+ # optionally, define methods in your own language
114
63
 
115
- context 'User Flow' do
116
- it 'User updates profile description' do
117
- given_I_log_in
118
- When 'I update profile description' do
119
- ...
120
- end
121
- then_I_should_see_a_confirmation_message
122
- end
123
-
124
- it 'User updates profile avatar' do
125
- given_I_log_in
126
- When 'I update profile avatar' do
127
- ...
128
- end
129
- then_I_should_see_a_confirmation_message
130
- end
131
- end
64
+ Bdd.define(%w[Dado], %w[Quando Entao], %w[E Mas]) # Portuguese
65
+ Bdd.define(%w[Zakładając], %w[Jeśli To], %w[Także Ale]) # Polish
132
66
  ```
133
- Output:
134
- <pre>
135
- <b>User Flow</b>
136
- <b>User updates profile description</b>
137
- <b>Given</b> I log in
138
- <b> When</b> I update profile description
139
- <b> Then</b> I should see a confirmation message
140
- </pre>
141
67
 
142
68
 
143
69
 
144
- ### Nested Example 1
145
70
 
146
- Outside of the scope
147
-
148
- Given is automatically inserted as a before
149
- Then is automatically inserted as an after
71
+ ### Installation For Minitest
150
72
 
151
73
  ```ruby
152
- Given "I log in" do
153
- visit '/login'
154
- fill_in 'Login', with: 'jack@example.com'
155
- fill_in 'Password', with: 'password'
156
- click_button "Log in"
157
- expect(page).to have_content('Welcome jack@example.com')
74
+ group :test do
75
+ gem 'minitest'
76
+ gem 'minitest-reporters'
77
+ gem 'bdd', require: 'bdd/minitest'
158
78
  end
79
+ ```
159
80
 
160
- Then "I should see a confirmation message" do
161
- expect(page).to have_content('Your profile was updated successfully')
162
- end
81
+ Add this to your `test/test_helper.rb` file.
163
82
 
164
- context 'User Flow' do
165
- it 'User updates profile description' do
166
- When 'I update profile description' do
167
- ...
168
- end
169
- end
83
+ ```ruby
84
+ Minitest::Reporters.use!(Bdd::Minitest::Reporter.new)
170
85
 
171
- it 'User updates profile avatar' do
172
- When 'I update profile avatar' do
173
- ...
174
- end
175
- end
176
- end
86
+ # optionally, add methods in your own language
87
+
88
+ Bdd.define(%w[Dado], %w[Quando Entao], %w[E Mas]) # Portuguese
89
+ Bdd.define(%w[Zakładając], %w[Jeśli To], %w[Także Ale]) # Polish
177
90
  ```
178
- Output:
179
- <pre>
180
- <b>User Flow</b>
181
- <b>User updates profile description</b>
182
- <b>Given</b> I log in
183
- <b> When</b> I update profile description
184
- <b> Then</b> I should see a confirmation message
185
- </pre>
186
91
 
187
92
 
188
93
 
189
- ### Nested Example 2
190
94
 
191
- Nesting will silence any output from the internal steps
192
95
 
193
- ```ruby
194
- def given_I_am_on_the_log_in_page
195
- Given 'I am on the login page' do
196
- visit '/login'
197
- end
198
- end
199
96
 
200
- def when_I_submit_the_log_in_form
201
- When 'I put credentials' do
202
- fill_in 'Login', with: 'jack@example.com'
203
- fill_in 'Password', with: 'password'
204
- click_button "Log in"
205
- end
206
- end
97
+ ## Usage
207
98
 
208
- def then_I_should_be_logged_in
209
- Then 'I should be logged in' do
210
- expect(page).to have_content('Welcome jack@example.com')
211
- end
212
- end
99
+ File `spec/features/search_spec.rb`
213
100
 
214
- def given_I_log_in
215
- Given "I log in" do
216
- given_I_am_on_the_log_in_page
217
- when_I_submit_the_log_in_form
218
- then_I_should_be_logged_in
219
- end
220
- end
101
+ ```ruby
102
+ context 'Searching' do
103
+ it 'Result is found' do
104
+ Given 'I am on the search page' do
105
+ visit '/search'
106
+ expect(page).to have_content('Search')
107
+ end
221
108
 
222
- context 'User Flow' do
223
- it 'User updates profile description' do
224
- given_I_log_in
225
- When 'I update profile description' do
226
- ...
109
+ When 'I search something' do
110
+ fill_in 'Search', with: 'John'
111
+ click_button 'Go'
227
112
  end
228
- then_I_should_see_a_confirmation_message
229
- end
230
113
 
231
- it 'User updates profile avatar' do
232
- given_I_log_in
233
- When 'I update profile avatar' do
234
- ...
114
+ Then 'I should see the word result' do
115
+ expect(page).to have_content('Result')
235
116
  end
236
- then_I_should_see_a_confirmation_message
237
117
  end
238
118
  end
239
119
  ```
240
- Output:
241
- <pre>
242
- <b>User Flow</b>
243
- <b>User updates profile description</b>
244
- <b>Given</b> I log in
245
- <b> When</b> I update profile description
246
- <b> Then</b> I should see a confirmation message
247
- </pre>
248
-
249
120
 
250
- ### Renaming
121
+ Run tests
251
122
 
252
- Useful for refactored nesting, you can change a step's name
123
+ `rspec -fd spec/features/search_spec.rb`
253
124
 
254
- ```ruby
255
- def when_I_log_in
256
- When "I log in" do
257
- visit '/login'
258
- fill_in 'Login', with: 'jack@example.com'
259
- fill_in 'Password', with: 'password'
260
- click_button "Log in"
261
- expect(page).to have_content('Welcome jack@example.com')
262
- end
263
- end
125
+ Output
264
126
 
127
+ <pre>
128
+ <b>Searching</b>
129
+ <b>Result is found</b>
130
+ <b>Given</b> I am on the search page
131
+ <b> When</b> I search something
132
+ <b> Then</b> I should see the word result
133
+ </pre>
265
134
 
266
- def given_I_log_in
267
- Given when_I_log_in
268
- end
269
135
 
270
- context 'User Flow'
271
- it 'User updates profile description' do
272
- given_I_log_in
273
- When 'I update profile description' do
274
- ...
275
- end
276
- then_I_should_see_a_confirmation_message
277
- end
136
+ ### More Examples
278
137
 
279
- it 'User updates profile avatar' do
280
- given_I_log_in
281
- When 'I update profile avatar' do
282
- ...
283
- end
284
- then_I_should_see_a_confirmation_message
285
- end
286
- end
287
- ```
288
- Output:
289
- <pre>
290
- <b>User Flow</b>
291
- <b>User updates profile description</b>
292
- <b>Given</b> I log in
293
- <b> When</b> I update profile description
294
- <b> Then</b> I should see a confirmation message
295
- </pre>
138
+ * [READ ALL EXAMPLES](http://github.com/thejamespinto/bdd/tree/master/examples)
296
139
 
140
+ <br><br><br><br>
297
141
 
298
142
 
299
143
 
300
144
 
145
+ ## Defining custom steps
301
146
 
147
+ In case your flow is different and you would like to define your own wording.
302
148
 
303
- ## Development
149
+ You can add more English words, or add an entirely new language:
304
150
 
305
- Currently we only support __RSpec__
151
+ ```ruby
152
+ Bdd.define(%w[Given], %w[When Then], %w[And But]) # English
153
+ Bdd.define(%w[Dado], %w[Quando Entao], %w[E Mas]) # Portuguese
154
+ Bdd.define(%w[Zakładając], %w[Jeśli To], %w[Także Ale]) # Polish
155
+ ```
306
156
 
307
- __minitest__ and __test_unit__ pull requests are wanted.
308
157
 
309
- __internationalization__ pull requests are wanted.
310
158
 
311
159
 
312
160
  ## Authors
@@ -9,24 +9,18 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["James Pinto"]
10
10
  spec.email = ["thejamespinto@gmail.com"]
11
11
 
12
- spec.summary = %q{Cucumber style in your RSpec tests}
12
+ spec.summary =
13
13
  spec.description = %q{Cucumber style in your RSpec tests}
14
14
  spec.homepage = "https://github.com/thejamespinto/bdd"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.bindir = "bin"
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- # if spec.respond_to?(:metadata)
22
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
23
- # end
24
-
25
- spec.add_runtime_dependency 'rspec'
26
- spec.add_runtime_dependency 'colorize'
27
-
28
-
29
21
  # spec.add_development_dependency "bundler", "~> 1.9"
30
22
  # spec.add_development_dependency "rake", "~> 10.0"
31
- # spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'minitest'
25
+ spec.add_development_dependency 'minitest-reporters', '1.1.9'
32
26
  end
@@ -0,0 +1,244 @@
1
+ [Back to README](https://github.com/thejamespinto/bdd)
2
+
3
+ ## Output Example
4
+
5
+ `spec/features/search_spec.rb`
6
+
7
+ ```ruby
8
+ context 'Searching' do
9
+ it 'Result is found' do
10
+ Given 'I am on the search page' do
11
+ visit '/search'
12
+ expect(page).to have_content('Search')
13
+ end
14
+
15
+ When 'I search something' do
16
+ fill_in 'Search', with: 'John'
17
+ click_button 'Go'
18
+ end
19
+
20
+ Then 'I should see the word result' do
21
+ expect(page).to have_content('Result')
22
+ end
23
+ end
24
+ end
25
+ ```
26
+
27
+
28
+ ### Documentation formatting output:
29
+
30
+ `rspec -fd spec/features/search_spec.rb`
31
+
32
+ <pre>
33
+ <b>Searching</b>
34
+ <b>Result is found</b>
35
+ <b>Given</b> I am on the search page
36
+ <b> When</b> I search something
37
+ <b> Then</b> I should see the word result
38
+ </pre>
39
+
40
+
41
+ ### Shared Steps
42
+
43
+ ### Basic Example with shared steps
44
+
45
+ You can refactor steps into methods using plain Ruby syntax.
46
+
47
+ ```ruby
48
+ def given_I_log_in
49
+ Given "I log in" do
50
+ visit '/login'
51
+ fill_in 'Login', with: 'jack@example.com'
52
+ fill_in 'Password', with: 'password'
53
+ click_button "Log in"
54
+ expect(page).to have_content('Welcome jack@example.com')
55
+ end
56
+ end
57
+
58
+ def then_I_should_see_a_confirmation_message
59
+ Then "I should see a confirmation message" do
60
+ expect(page).to have_content('Your profile was updated successfully')
61
+ end
62
+ end
63
+
64
+ context 'User Flow' do
65
+ it 'User updates profile description' do
66
+ given_I_log_in
67
+ When 'I update profile description' do
68
+ ...
69
+ end
70
+ then_I_should_see_a_confirmation_message
71
+ end
72
+
73
+ it 'User updates profile avatar' do
74
+ given_I_log_in
75
+ When 'I update profile avatar' do
76
+ ...
77
+ end
78
+ then_I_should_see_a_confirmation_message
79
+ end
80
+ end
81
+ ```
82
+ Output:
83
+ <pre>
84
+ <b>User Flow</b>
85
+ <b>User updates profile description</b>
86
+ <b>Given</b> I log in
87
+ <b> When</b> I update profile description
88
+ <b> Then</b> I should see a confirmation message
89
+ </pre>
90
+
91
+
92
+
93
+ ### Nested Example 1
94
+
95
+ Outside of the scope
96
+
97
+ Given is automatically inserted as a before
98
+ Then is automatically inserted as an after
99
+
100
+ ```ruby
101
+ Given "I log in" do
102
+ visit '/login'
103
+ fill_in 'Login', with: 'jack@example.com'
104
+ fill_in 'Password', with: 'password'
105
+ click_button "Log in"
106
+ expect(page).to have_content('Welcome jack@example.com')
107
+ end
108
+
109
+ Then "I should see a confirmation message" do
110
+ expect(page).to have_content('Your profile was updated successfully')
111
+ end
112
+
113
+ context 'User Flow' do
114
+ it 'User updates profile description' do
115
+ When 'I update profile description' do
116
+ ...
117
+ end
118
+ end
119
+
120
+ it 'User updates profile avatar' do
121
+ When 'I update profile avatar' do
122
+ ...
123
+ end
124
+ end
125
+ end
126
+ ```
127
+ Output:
128
+ <pre>
129
+ <b>User Flow</b>
130
+ <b>User updates profile description</b>
131
+ <b>Given</b> I log in
132
+ <b> When</b> I update profile description
133
+ <b> Then</b> I should see a confirmation message
134
+ </pre>
135
+
136
+
137
+
138
+ ### Nested Example 2
139
+
140
+ Nesting will silence any output from the internal steps
141
+
142
+ ```ruby
143
+ def given_I_am_on_the_log_in_page
144
+ Given 'I am on the login page' do
145
+ visit '/login'
146
+ end
147
+ end
148
+
149
+ def when_I_submit_the_log_in_form
150
+ When 'I put credentials' do
151
+ fill_in 'Login', with: 'jack@example.com'
152
+ fill_in 'Password', with: 'password'
153
+ click_button "Log in"
154
+ end
155
+ end
156
+
157
+ def then_I_should_be_logged_in
158
+ Then 'I should be logged in' do
159
+ expect(page).to have_content('Welcome jack@example.com')
160
+ end
161
+ end
162
+
163
+ def given_I_log_in
164
+ Given "I log in" do
165
+ given_I_am_on_the_log_in_page
166
+ when_I_submit_the_log_in_form
167
+ then_I_should_be_logged_in
168
+ end
169
+ end
170
+
171
+ context 'User Flow' do
172
+ it 'User updates profile description' do
173
+ given_I_log_in
174
+ When 'I update profile description' do
175
+ ...
176
+ end
177
+ then_I_should_see_a_confirmation_message
178
+ end
179
+
180
+ it 'User updates profile avatar' do
181
+ given_I_log_in
182
+ When 'I update profile avatar' do
183
+ ...
184
+ end
185
+ then_I_should_see_a_confirmation_message
186
+ end
187
+ end
188
+ ```
189
+ Output:
190
+ <pre>
191
+ <b>User Flow</b>
192
+ <b>User updates profile description</b>
193
+ <b>Given</b> I log in
194
+ <b> When</b> I update profile description
195
+ <b> Then</b> I should see a confirmation message
196
+ </pre>
197
+
198
+
199
+ ### Renaming
200
+
201
+ Useful for refactored nesting, you can change a step's name
202
+
203
+ ```ruby
204
+ def when_I_log_in
205
+ When "I log in" do
206
+ visit '/login'
207
+ fill_in 'Login', with: 'jack@example.com'
208
+ fill_in 'Password', with: 'password'
209
+ click_button "Log in"
210
+ expect(page).to have_content('Welcome jack@example.com')
211
+ end
212
+ end
213
+
214
+
215
+ def given_I_log_in
216
+ Given when_I_log_in
217
+ end
218
+
219
+ context 'User Flow'
220
+ it 'User updates profile description' do
221
+ given_I_log_in
222
+ When 'I update profile description' do
223
+ ...
224
+ end
225
+ then_I_should_see_a_confirmation_message
226
+ end
227
+
228
+ it 'User updates profile avatar' do
229
+ given_I_log_in
230
+ When 'I update profile avatar' do
231
+ ...
232
+ end
233
+ then_I_should_see_a_confirmation_message
234
+ end
235
+ end
236
+ ```
237
+ Output:
238
+ <pre>
239
+ <b>User Flow</b>
240
+ <b>User updates profile description</b>
241
+ <b>Given</b> I log in
242
+ <b> When</b> I update profile description
243
+ <b> Then</b> I should see a confirmation message
244
+ </pre>