aruba 0.11.0.pre4 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +11 -3
  3. data/README.md +32 -311
  4. data/aruba.gemspec +1 -1
  5. data/features/api/filesystem/fixtures.feature +104 -0
  6. data/features/{core/cleanup_aruba_directory.feature → getting_started/cleanup.feature} +16 -1
  7. data/features/{usage → getting_started}/install.feature +0 -0
  8. data/features/getting_started/writing_good_feature_tests.feature +38 -0
  9. data/features/hooks/after/command.feature +10 -0
  10. data/features/hooks/before/command.feature +10 -0
  11. data/features/platforms/jruby.feature +14 -0
  12. data/features/{commands/debug_command.feature → steps/command/debug.feature} +0 -0
  13. data/features/steps/command/in_process.feature +11 -0
  14. data/features/{commands → steps/command}/interactive.feature +1 -1
  15. data/features/{commands/output/all_output.feature → steps/command/output.feature} +142 -0
  16. data/features/steps/command/stderr.feature +68 -0
  17. data/features/{commands/output → steps/command}/stdout.feature +45 -2
  18. data/features/{announce.feature → steps/core/announce.feature} +0 -0
  19. data/features/steps/filesystem/append_to_file.feature +45 -0
  20. data/features/steps/filesystem/cd_to_directory.feature +33 -0
  21. data/features/steps/filesystem/check_file_content.feature +61 -0
  22. data/features/steps/filesystem/check_permissions_of_file.feature +39 -0
  23. data/features/steps/filesystem/compare_files.feature +42 -0
  24. data/features/steps/filesystem/create_directory.feature +15 -5
  25. data/features/steps/filesystem/create_file.feature +26 -3
  26. data/features/steps/filesystem/existence_of_directory.feature +57 -0
  27. data/features/steps/filesystem/existence_of_file.feature +43 -0
  28. data/features/steps/filesystem/file_content.feature +22 -0
  29. data/features/steps/filesystem/fixtures.feature +64 -0
  30. data/features/steps/filesystem/non_existence_of_directory.feature +69 -0
  31. data/features/steps/filesystem/non_existence_of_file.feature +80 -0
  32. data/features/steps/filesystem/remove_directory.feature +38 -0
  33. data/features/steps/filesystem/remove_file.feature +38 -0
  34. data/lib/aruba/cucumber/file.rb +17 -15
  35. data/lib/aruba/version.rb +1 -1
  36. metadata +52 -31
  37. data/features/commands/environment_variables.feature +0 -64
  38. data/features/commands/flushing.feature +0 -74
  39. data/features/file_system_commands.feature +0 -220
  40. data/features/output.feature +0 -131
  41. data/features/utf-8.feature +0 -14
  42. data/fixtures/fixtures-app/test.txt +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49dd222803f4cff003379e2972396f9df1cff2e6
4
- data.tar.gz: 498409b90a251f6889a8db0abbc9edb38b2361b4
3
+ metadata.gz: 62427bdbd40bcd56afd8712d52200e7ade0a46a3
4
+ data.tar.gz: 1edaf0abe9e8d71651e9d891fe0f2a9dff81e5e8
5
5
  SHA512:
6
- metadata.gz: 396fa4d9c8122b5b11901f97274bc05faf947b525b4d13df90540634571d2224a34b0f1b85ff298db7dfb4dadcae24781deabb88ec0c53593a69c5cca9b1d762
7
- data.tar.gz: 1d34cc877d8aa44f50e297039e7ecc242682b59cd7bf13c1e27581b99943c537aab1e7d3c39485d9f2bbfabf695ce458f676f41c50765484bbe5bfdd769298b7
6
+ metadata.gz: 1576ea1206c4ab02384f227746e4344fc53a02278772a612e68aa16de5d62ada2f6da4406ff38c785ce84fe0409c8e512e0a20e12c5389fe1cd6ce652cbf7062
7
+ data.tar.gz: d7fc54d5f31c23b02073e6e1ea8879d2a7c7cca254cefc92504c9aac8835160310f36b3c9939c496b2facb99ebc234e51c62c87a424babfc0a89a2a8d6d8c012
data/History.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Latest Release
2
2
 
3
+ ## [v0.11.1](https://github.com/cucumber/aruba/compare/v0.11.pre4...v0.11.1)
4
+
5
+ * Use fixed version of event-bus
6
+ * Refactored and improved documentation (feature tests) in PR #309
7
+
8
+ # Old releases
9
+
10
+ ## [v0.11.0](https://github.com/cucumber/aruba/compare/v0.11.pre4...v0.11.0)
11
+
12
+ * Accidently pushed to rubygems.org - yanked it afterwards
13
+
3
14
  ## [v0.11.0.pre4](https://github.com/cucumber/aruba/compare/v0.11.pre3...v0.11.0.pre4)
4
15
 
5
16
  * Fixed syntax for Hash on ruby 1.8.7
6
17
  * Reorder rubies in .travis.yml
7
18
 
8
- # Old releases
9
-
10
19
  ## [v0.11.0.pre3](https://github.com/cucumber/aruba/compare/v0.11.pre2...v0.11.0.pre3)
11
20
 
12
21
  * Fixed syntax for proc on ruby 1.8.7
13
22
 
14
-
15
23
  ## [v0.11.0.pre2](https://github.com/cucumber/aruba/compare/v0.11.pre...v0.11.0.pre2)
16
24
 
17
25
  * Integrate `EventBus` to decouple announcers from starting, stopping commands
data/README.md CHANGED
@@ -82,325 +82,46 @@ well. One might want to use it together with `rspec`.
82
82
  end
83
83
  ```
84
84
 
85
- ## API
85
+ ### Minitest
86
86
 
87
- `aruba` provides a wonderful API to be used in your tests:
88
-
89
- * Creating files/directories
90
- * Deleting files/directories
91
- * Checking file size
92
- * Checking file existence/absence
93
- * ...
94
-
95
- A full documentation of the API can be found [here](http://www.rubydoc.info/github/cucumber/aruba/master/frames).
96
-
97
- ## Configuration
98
-
99
- Aruba has some default behaviour that you can change if you need to.
100
-
101
- ### Use a different working directory
102
-
103
- Per default Aruba will create a directory `tmp/aruba` where it performs its file operations.
104
- If you want to change this behaviour put this into your `features/support/env.rb`:
105
-
106
- ```ruby
107
- Before do
108
- @dirs = ["somewhere/else"]
109
- end
110
- ```
111
-
112
- ### Modify the PATH
113
-
114
- Aruba will automatically add the `bin` directory of your project to the `PATH` environment variable for
115
- the duration of each Cucumber scenario. So if you're developing a Ruby gem with a binary command, you
116
- can test those commands as though the gem were already installed.
117
-
118
- If you need other directories to be added to the `PATH`, you can put the following in `features/support/env.rb`:
119
-
120
- ```ruby
121
- Aruba.configure do |config|
122
- config.command_search_paths = config.command_search_paths << '/my/special/bin/path'
123
- end
124
- ```
125
-
126
- ### Increasing timeouts
127
-
128
- A process sometimes takes longer than expected to terminate, and Aruba will kill them off (and fail your scenario) if it is still alive after 3 seconds. If you need more time you can modify the timeout by assigning a different value to `#exit_timeout` in a `Aruba.configure` block:
129
-
130
- ```ruby
131
- Aruba.configure do |config|
132
- config.exit_timeout = 5
133
- end
134
- ```
135
-
136
- ### Increasing IO wait time
137
-
138
- Running processes interactively can result in race conditions when Aruba executes an IO-related step
139
- but the interactive process has not yet flushed or read some content. To help prevent this Aruba waits
140
- before reading or writing to the process if it is still running. You can control the wait by setting
141
- `aruba.config.io_wait_timeout` to an appropriate value. This is particularly useful with tags:
142
-
143
- ```ruby
144
- Before('@slow_process') do
145
- aruba.config.io_wait_timeout = 5
146
- end
147
- ```
148
-
149
- ### Tags
150
-
151
- Aruba defines several tags that you can put on on individual scenarios, or on a feature.
152
-
153
- #### Seeing more output with `@announce-*`
154
-
155
- To get more information on what Aruba is doing, use these tags:
156
-
157
- * `@announce-command` - See what command is run
158
- * `@announce-stdout` - See the stdout
159
- * `@announce-stderr` - See the stderr
160
- * `@announce-output` - See the output of stdout and stderr
161
- * `@announce-directory` - See the current directory
162
- * `@announce-environment` - See environment variables set by Aruba
163
- * `@announce` - Does all of the above
164
-
165
- ### Adding Hooks
166
-
167
- You can hook into Aruba's lifecycle just before it runs a command and after it has run the command:
168
-
169
- ```ruby
170
- Aruba.configure do |config|
171
- config.before :command do |cmd|
172
- puts "About to run '#{cmd}'"
173
- end
174
-
175
- config.after :command do |cmd|
176
- puts "After the run of '#{cmd}'"
177
- end
178
- end
179
- ```
180
-
181
- #### Keep files around with `@no-clobber`
182
-
183
- Aruba clobbers all files in its working directory before each scenario. -Unless you tag it with `@no-clobber`
184
-
185
- #### Making assertions about ANSI escapes with `@ansi`
186
-
187
- Aruba strips away ANSI escapes from the stdout and stderr of spawned child processes by default. It's usually rather cumbersome to
188
- make assertions about coloured output. Still, there might be cases where you want to leave the ANSI escapes intact. Just tag your
189
- scenario with `@ansi`. Alternatively you can add your own Before
190
- hook that sets `@aruba_keep_ansi = true`.
191
-
192
- ### Testing Ruby CLI programs without spawning a new Ruby process.
193
-
194
- If your CLI program is written in Ruby you can speed up your suite of scenarios by running
195
- your CLI in the same process as Cucumber/Aruba itself. In order to be able to do this, the
196
- entry point for your CLI application must be a class that has a constructor with a particular
197
- signature and an `execute!` method:
198
-
199
- ```ruby
200
- class MyMain
201
- def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
202
- @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
203
- end
204
-
205
- def execute!
206
- # your code here, assign a value to exitstatus
207
- @kernel.exit(exitstatus)
208
- end
209
- end
210
- ```
211
-
212
- Your `bin/something` executable would look something like the following:
213
-
214
- ```ruby
215
- require 'my_main'
216
- MyMain.new(ARGV.dup).execute!
217
- ```
218
-
219
- Then wire it all up in your `features/support/env.rb` file:
220
-
221
- ```ruby
222
- require 'aruba'
223
- require 'aruba/in_process'
87
+ TBD :-)
224
88
 
225
- Aruba.process = Aruba::Processes::InProcess
226
- Aruba.process.main_class = MyMain
227
- ```
228
-
229
- That's it! Everything will now run inside the same ruby process, making your suite
230
- a lot faster. Cucumber itself uses this approach to test itself, so check out the
231
- Cucumber source code for an example.
232
-
233
- *Pros*:
234
-
235
- * Very fast compared to spawning processes
236
- * You can use libraries like
237
- [simplecov](https://github.com/colszowka/simplecov) more easily, because
238
- there is only one "process" which adds data to `simplecov`'s database
239
-
240
- *Cons*:
241
- * You might oversee some bugs: You might forget to require libraries in your
242
- "production" code, because you have required them in your testing code
243
-
244
- ### JRuby Tips
245
-
246
- Improve startup time by disabling JIT and forcing client JVM mode. This can be accomplished by adding
247
-
248
- ```ruby
249
- require 'aruba/jruby'
250
- ```
251
-
252
- or setting a hook like this example:
253
-
254
- ```ruby
255
- Aruba.configure do |config|
256
- config.before :command do |cmd|
257
- set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
258
- set_env('JAVA_OPTS', "-d32 #{ENV['JAVA_OPTS']}") # force jRuby to use client JVM for faster startup times
259
- end
260
- end if RUBY_PLATFORM == 'java'
261
- ```
262
-
263
- *Note* - no conflict resolution on the JAVA/JRuby environment options is
264
- done; only merging. For more complex settings please manually set the
265
- environment variables in the hook or externally.
89
+ ## Documentation
266
90
 
267
- A larger process timeout for java may be needed
91
+ ### User Documentation
268
92
 
269
- ```ruby
270
- Before do
271
- @aruba_timeout_seconds = RUBY_PLATFORM == 'java' ? 60 : 10
272
- end
273
- ```
274
-
275
- Refer to http://blog.headius.com/2010/03/jruby-startup-time-tips.html for other tips on startup time.
276
-
277
- ## Fixtures
278
-
279
- Sometimes your tests need existing files to work - e.g binary data files you
280
- cannot create programmatically. Since `aruba` >= 0.6.3 includes some basic
281
- support for fixtures. All you need to do is the following:
282
-
283
- 1. Create a `fixtures`-directory
284
- 2. Create fixture files in this directory
285
-
286
- The `expand_path`-helper will expand `%` to the path of your fixtures
287
- directory:
288
-
289
- ```ruby
290
- expand_path('%/song.mp3')
291
- # => /home/user/projects/my_project/fixtures/song.mp3
292
- ```
293
-
294
- *Example*
295
-
296
- 1. Create fixtures directory
93
+ If you're interested in our steps and API, please browser our [feature
94
+ files](https://github.com/cucumber/aruba/tree/master/features). You can find a
95
+ lot of examples there. A good starting point are [Getting
96
+ Started](https://github.com/cucumber/aruba/tree/master/features/getting_started)
97
+ and [Step
98
+ Overview](https://github.com/cucumber/aruba/blob/master/features/steps/overview.feature).
99
+ A more or less full list of our steps can be found
100
+ [here](https://github.com/cucumber/aruba/tree/master/features/steps). Our API
101
+ is documentated
102
+ [here](https://github.com/cucumber/aruba/tree/master/features/api) and some
103
+ more information about how to configure `aruba`, can be found
104
+ [here](https://github.com/cucumber/aruba/tree/master/features/configuration).
105
+ The "RSpec" matchers provided by `aruba`, are documented
106
+ [here](https://github.com/cucumber/aruba/tree/master/features/matchers).
297
107
 
298
- ```bash
299
- cd project
300
-
301
- mkdir -p fixtures/
302
- # or
303
- mkdir -p test/fixtures/
304
- # or
305
- mkdir -p spec/fixtures/
306
- # or
307
- mkdir -p features/fixtures/
308
- ```
309
-
310
- 2. Store `song.mp3` in `fixtures`-directory
311
-
312
- ```bash
313
- cp song.mp3 fixtures/
314
- ```
108
+ You can find our documentation on
109
+ [Relish](http://www.relishapp.com/cucumber/aruba/docs) as well. Unfortunately
110
+ "Relish" does not like the way we structered our feature tests. So this
111
+ documentation found there may be not complete.
315
112
 
316
- 3. Add fixture to vcs-repository - e.g. `git`, `mercurial`
113
+ ### Developer Documentation
317
114
 
318
- 4. Create test
319
-
320
- ```ruby
321
- RSpec.describe 'My Feature' do
322
- describe '#read_music_file' do
323
- context 'when the file exists' do
324
- let(:path) { expand_path('%/song.mp3') }
325
-
326
- before :each do
327
- cd('.') { FileUtils.cp path, 'file.mp3' }
328
- end
329
-
330
- before :each do
331
- run 'my_command'
332
- end
333
-
334
- it { expect(all_stdout).to include('Rate is 128 KB') }
335
- end
336
- end
337
- end
338
- ```
339
-
340
- ## Reporting
341
-
342
- *Important* - you need [Pygments](http://pygments.org/) installed to use this feature.
343
-
344
- Aruba can generate a HTML page for each scenario that contains:
345
-
346
- * The title of the scenario
347
- * The description from the scenario (You can use Markdown here)
348
- * The command(s) that were run
349
- * The output from those commands (in colour if the output uses ANSI escapes)
350
- * The files that were created (syntax highlighted in colour)
351
-
352
- In addition to this, it creates an `index.html` file with links to all individual report files.
353
- Reporting is off by default, but you can enable it by defining the `ARUBA_REPORT_DIR` environment variable, giving it the value
354
- where reports should be written:
355
-
356
- ARUBA_REPORT_DIR=doc cucumber features
357
-
358
- This will use Aruba's built-in template by default (See the `templates` folder). If you want to use your own template you can override its location:
359
-
360
- ARUBA_REPORT_TEMPLATES=templates ARUBA_REPORT_DIR=doc cucumber features
361
-
362
- The templates directory must contain a `main.erb` and `files.erb` template. It can also contain other assets such
363
- as css, javascript and images. All of these files will be copied over to the report dir well.
364
-
365
- ### Escaping Markdown
366
-
367
- There are some edge cases where Gherkin and Markdown don't agree. Bullet lists using `*` is one example. The `*` is also an alias for
368
- step keywords in Gherkin. Markdown headers (the kind starting with a `#`) is another example. They are parsed as comments by Gherkin. To use either of these, just escape them with a backslash. So instead of writing:
369
-
370
- ```gherkin
371
- Scenario: Make tea
372
- ## Making tea
373
- * Get a pot
374
- * And some hot water
375
-
376
- Given...
377
- ```
378
-
379
- You'd write:
380
-
381
- ```gherkin
382
- Scenario: Make tea
383
- \## Making tea
384
- \* Get a pot
385
- \* And some hot water
386
-
387
- Given...
388
- ```
389
-
390
- This way Gherkin won't recognize these lines as special tokens, and the reporter will render them as Markdown. (The reporter strips
391
- away any leading the backslashes before handing it off to the Markdown parser).
392
-
393
- Another option is to use alternative Markdown syntax and omit conflicts and escaping altogether:
115
+ `aruba` provides a wonderful API to be used in your tests:
394
116
 
395
- ```gherkin
396
- Scenario: Make tea
397
- Making tea
398
- ----------
399
- - Get a pot
400
- - And some hot water
117
+ * Creating files/directories
118
+ * Deleting files/directories
119
+ * Checking file size
120
+ * Checking file existence/absence
121
+ * ...
401
122
 
402
- Given...
403
- ```
123
+ A full documentation of the API can be found
124
+ [here](http://www.rubydoc.info/github/cucumber/aruba/master/frames).
404
125
 
405
126
  ## Contributing
406
127
 
@@ -408,4 +129,4 @@ Please see the `CONTRIBUTING.md`.
408
129
 
409
130
  ## Copyright
410
131
 
411
- Copyright (c) 2010,2011,2012,2013,2014 Aslak Hellesøy, David Chelimsky and Mike Sassak. See LICENSE for details.
132
+ Copyright (c) 2010-2015 Aslak Hellesøy et al. See LICENSE for details.
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'rspec-expectations', '>= 2.99'
20
20
  s.add_runtime_dependency 'contracts', '~> 0.9'
21
21
  s.add_runtime_dependency 'thor', '~> 0.19'
22
- s.add_runtime_dependency 'event-bus', '~> 0.2.0'
22
+ s.add_runtime_dependency 'event-bus', '~> 0.2'
23
23
 
24
24
  s.add_development_dependency 'bundler', '~> 1.10.2'
25
25
 
@@ -0,0 +1,104 @@
1
+ Feature: Use fixtures in your tests
2
+
3
+ Sometimes your tests need existing files to work - e.g binary data files you
4
+ cannot create programmatically. Since `aruba` >= 0.6.3 includes some basic
5
+ support for fixtures. All you need to do is the following:
6
+
7
+ 1. Create a `fixtures`-directory
8
+ 2. Create fixture files in this directory
9
+
10
+
11
+ Background:
12
+ Given I use a fixture named "cli-app"
13
+
14
+ Scenario: Use a fixture for your tests
15
+ Given a file named "features/fixtures.feature" with:
16
+ """
17
+ Feature: Fixture
18
+ Scenario: Fixture
19
+ Given a file named "fixtures_spec.rb" with:
20
+ \"\"\"
21
+ RSpec.describe 'My Feature' do
22
+ describe '#read_music_file' do
23
+ context 'when the file exists' do
24
+ before :each { copy '%/song.mp3', 'file.mp3' }
25
+
26
+ it { expect('file.mp3').to be_an_existing_file }
27
+ end
28
+ end
29
+ end
30
+ \"\"\"
31
+ """
32
+ And a directory named "fixtures"
33
+ And an empty file named "fixtures/fixtures-app/test.txt"
34
+ When I run `rspec`
35
+ Then the specs should all pass
36
+
37
+ Scenario: Use a fixture for your tests in test/
38
+ Given a file named "features/fixtures.feature" with:
39
+ """
40
+ Feature: Fixture
41
+ Scenario: Fixture
42
+ Given a file named "fixtures_spec.rb" with:
43
+ \"\"\"
44
+ RSpec.describe 'My Feature' do
45
+ describe '#read_music_file' do
46
+ context 'when the file exists' do
47
+ before :each { copy '%/song.mp3', 'file.mp3' }
48
+
49
+ it { expect('file.mp3').to be_an_existing_file }
50
+ end
51
+ end
52
+ end
53
+ \"\"\"
54
+ """
55
+ And a directory named "test/fixtures"
56
+ And an empty file named "test/fixtures/fixtures-app/test.txt"
57
+ When I run `rspec`
58
+ Then the specs should all pass
59
+
60
+ Scenario: Use a fixture for your tests in spec/
61
+ Given a file named "features/fixtures.feature" with:
62
+ """
63
+ Feature: Fixture
64
+ Scenario: Fixture
65
+ Given a file named "fixtures_spec.rb" with:
66
+ \"\"\"
67
+ RSpec.describe 'My Feature' do
68
+ describe '#read_music_file' do
69
+ context 'when the file exists' do
70
+ before :each { copy '%/song.mp3', 'file.mp3' }
71
+
72
+ it { expect('file.mp3').to be_an_existing_file }
73
+ end
74
+ end
75
+ end
76
+ \"\"\"
77
+ """
78
+ And a directory named "spec/fixtures"
79
+ And an empty file named "spec/fixtures/fixtures-app/test.txt"
80
+ When I run `rspec`
81
+ Then the specs should all pass
82
+
83
+ Scenario: Use a fixture for your tests in features/
84
+ Given a file named "features/fixtures.feature" with:
85
+ """
86
+ Feature: Fixture
87
+ Scenario: Fixture
88
+ Given a file named "fixtures_spec.rb" with:
89
+ \"\"\"
90
+ RSpec.describe 'My Feature' do
91
+ describe '#read_music_file' do
92
+ context 'when the file exists' do
93
+ before :each { copy '%/song.mp3', 'file.mp3' }
94
+
95
+ it { expect('file.mp3').to be_an_existing_file }
96
+ end
97
+ end
98
+ end
99
+ \"\"\"
100
+ """
101
+ And a directory named "features/fixtures"
102
+ And an empty file named "features/fixtures/fixtures-app/test.txt"
103
+ When I run `rspec`
104
+ Then the specs should all pass