aruba-rspec 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/aruba/rspec/matchers/shellout.rb +3 -3
- data/lib/aruba/rspec/version.rb +1 -1
- data/lib/aruba/rspec.rb +1 -0
- data/spec/aruba/rspec/matchers/shellout_spec.rb +52 -0
- data/spec/spec_helper.rb +4 -10
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4d4ae4e068e08a82846cb71d3f0f18d4bc4b78
|
4
|
+
data.tar.gz: 144ca0a998ecb3cad58dbcfa5fe56ca63f93dbc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd2c31da70965e40e13f3296699e1e68b204cdd5ff53c6757dda7d8258098580db353212441a8c135e35bc465c232b6068ba0361093b6dbc6ffac9a2304ca29
|
7
|
+
data.tar.gz: fff22a8d67e9651104cb87b5e68cb0bbe3414439578b1ad720db244efde2c798140617e76279eb37968df3cacd6457fe1def8f7628d65303ad2c5cad518f6f56
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Add `aruba-rspec` to your `spec_helper.rb` file as follows:
|
|
24
24
|
require 'aruba/rspec'
|
25
25
|
|
26
26
|
RSpec.configure do |config|
|
27
|
-
config.include
|
27
|
+
config.include ArubaDoubles
|
28
28
|
|
29
29
|
config.before :each do
|
30
30
|
Aruba::RSpec.setup
|
@@ -36,6 +36,9 @@ RSpec.configure do |config|
|
|
36
36
|
end
|
37
37
|
```
|
38
38
|
|
39
|
+
Note that ArubaDoubles needs to be included into your RSpec
|
40
|
+
configuration. This allows command doubles to be used.
|
41
|
+
|
39
42
|
## Command doubles
|
40
43
|
|
41
44
|
This comes out of ArubaDoubles:
|
@@ -1,16 +1,16 @@
|
|
1
1
|
RSpec::Matchers.define :shellout do |cmd|
|
2
2
|
match do |ruby|
|
3
3
|
raise ArgumentError, "expected should be a Proc" unless ruby.is_a?(Proc)
|
4
|
-
|
4
|
+
ruby.call
|
5
5
|
Aruba::RSpec.history.include?(cmd.shellsplit)
|
6
6
|
end
|
7
7
|
|
8
8
|
failure_message_for_should do |ruby|
|
9
|
-
"expected that
|
9
|
+
"expected that code would run command #{cmd}\nfound: #{Aruba::RSpec.history.map(&:shelljoin)}"
|
10
10
|
end
|
11
11
|
|
12
12
|
failure_message_for_should_not do |ruby|
|
13
|
-
"expected that
|
13
|
+
"expected that code would NOT run command #{cmd}"
|
14
14
|
end
|
15
15
|
|
16
16
|
description do
|
data/lib/aruba/rspec/version.rb
CHANGED
data/lib/aruba/rspec.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'shellout matcher' do
|
4
|
+
before { Aruba::RSpec.setup }
|
5
|
+
after { Aruba::RSpec.teardown }
|
6
|
+
|
7
|
+
describe 'validations' do
|
8
|
+
it 'raises if given something other than a proc' do
|
9
|
+
expect {
|
10
|
+
expect(nil).to shellout('thing')
|
11
|
+
}.to raise_error(ArgumentError, 'expected should be a Proc')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when code calls out to a doubled command' do
|
16
|
+
it 'succeeds' do
|
17
|
+
double_cmd('thing')
|
18
|
+
expect { `thing` }.to shellout('thing')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'matches arguments' do
|
22
|
+
double_cmd('thing')
|
23
|
+
expect { `thing --with --stuff` }.to shellout('thing --with --stuff')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'fails on unexpected arguments' do
|
27
|
+
double_cmd('thing')
|
28
|
+
expect {
|
29
|
+
expect { `thing --with --stuff` }.to shellout('thing')
|
30
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected that code would run command thing/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when code does not shell out' do
|
35
|
+
it 'fails with error message' do
|
36
|
+
expect {
|
37
|
+
expect { "stuff" }.to shellout('thing')
|
38
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected that code would run command thing/)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when another command has run' do
|
43
|
+
it 'fails with error message including ran command' do
|
44
|
+
double_cmd('stuff')
|
45
|
+
double_cmd('thing')
|
46
|
+
|
47
|
+
expect {
|
48
|
+
expect { `stuff` }.to shellout('thing')
|
49
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected that code would run command thing\n\s*found: \["stuff"\]/)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
1
|
+
require 'aruba/rspec'
|
2
|
+
|
7
3
|
RSpec.configure do |config|
|
8
4
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
5
|
config.run_all_when_everything_filtered = true
|
10
6
|
config.filter_run :focus
|
11
7
|
|
12
|
-
# Run specs in random order to surface order dependencies. If you find an
|
13
|
-
# order dependency and want to debug it, you can fix the order by providing
|
14
|
-
# the seed, which is printed after each run.
|
15
|
-
# --seed 1234
|
16
8
|
config.order = 'random'
|
9
|
+
|
10
|
+
config.include ArubaDoubles
|
17
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aruba-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Saxby
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/aruba/rspec/matchers.rb
|
100
100
|
- lib/aruba/rspec/matchers/shellout.rb
|
101
101
|
- lib/aruba/rspec/version.rb
|
102
|
+
- spec/aruba/rspec/matchers/shellout_spec.rb
|
102
103
|
- spec/aruba/rspec_spec.rb
|
103
104
|
- spec/spec_helper.rb
|
104
105
|
homepage: https://github.com/livinginthepast/aruba-rspec
|
@@ -126,5 +127,6 @@ signing_key:
|
|
126
127
|
specification_version: 4
|
127
128
|
summary: Bridge RSpec and Aruba to test command-line tools
|
128
129
|
test_files:
|
130
|
+
- spec/aruba/rspec/matchers/shellout_spec.rb
|
129
131
|
- spec/aruba/rspec_spec.rb
|
130
132
|
- spec/spec_helper.rb
|