aruba-rspec 0.0.2 → 0.0.3
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/Gemfile +4 -1
- data/Guardfile +14 -0
- data/README.md +10 -0
- data/lib/aruba/rspec/matchers.rb +1 -0
- data/lib/aruba/rspec/matchers/have_exit_status.rb +19 -0
- data/lib/aruba/rspec/version.rb +1 -1
- data/spec/aruba/rspec/matchers/have_exit_status_spec.rb +30 -0
- data/spec/aruba/rspec/matchers/shellout_spec.rb +1 -1
- data/spec/aruba/rspec_spec.rb +29 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 923609312c5295afcd0dfe8225f4584b74a7742a
|
4
|
+
data.tar.gz: 4d854607fbfde128363436f7013669d711e59ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba391b19a6c0ddae026fe758ca5cc4c1cec3d026e4ca2eed7668daec6663841d78549a6aa88b60151d24c5048a88292ba9f62847b8ddc883a5706a933b71708f
|
7
|
+
data.tar.gz: 6c386cd7f82932ead728d67f577c40a93a440d4738586dac62b7b70d064c0a1bf7dc8ca87de13644d27665bfb9e83ebd57df4399c52426fb425b53a8b8f4d22b
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :bundler do
|
5
|
+
watch('Gemfile')
|
6
|
+
watch(/^.+\.gemspec/)
|
7
|
+
end
|
8
|
+
|
9
|
+
guard :rspec do
|
10
|
+
watch(%r{^spec/.+_spec\.rb$})
|
11
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
12
|
+
watch('spec/spec_helper.rb') { "spec" }
|
13
|
+
end
|
14
|
+
|
data/README.md
CHANGED
@@ -77,6 +77,16 @@ describe MyThing do
|
|
77
77
|
end
|
78
78
|
```
|
79
79
|
|
80
|
+
### :have_exit_status
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
it 'exits 50' do
|
84
|
+
double_cmd('thing', exit: 50)
|
85
|
+
expect {
|
86
|
+
`thing 1 2 3`
|
87
|
+
}.to have_exit_status(50)
|
88
|
+
```
|
89
|
+
|
80
90
|
## References
|
81
91
|
|
82
92
|
* `https://github.com/cucumber/aruba`
|
data/lib/aruba/rspec/matchers.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
RSpec::Matchers.define :have_exit_status do |status|
|
2
|
+
match do |ruby|
|
3
|
+
raise ArgumentError, "expected should be a Proc" unless ruby.respond_to?(:call)
|
4
|
+
ruby.call
|
5
|
+
$?.exitstatus == status
|
6
|
+
end
|
7
|
+
|
8
|
+
failure_message_for_should do |ruby|
|
9
|
+
"expected that code would exit #{status}"
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message_for_should_not do |ruby|
|
13
|
+
"expected that code would NOT exit #{status}"
|
14
|
+
end
|
15
|
+
|
16
|
+
description do
|
17
|
+
"exit #{status}"
|
18
|
+
end
|
19
|
+
end
|
data/lib/aruba/rspec/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'have_exit_status matcher' do
|
4
|
+
before { Aruba::RSpec.setup }
|
5
|
+
after { Aruba::RSpec.teardown }
|
6
|
+
|
7
|
+
describe 'validations' do
|
8
|
+
it 'raises unless given 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 command exit status matches expectations' do
|
16
|
+
it 'succeeds' do
|
17
|
+
double_cmd('thing', exit: 100)
|
18
|
+
expect { `thing` }.to have_exit_status(100)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when command exit status fails expectations' do
|
23
|
+
it 'fails' do
|
24
|
+
double_cmd('thing', exit: 101)
|
25
|
+
expect {
|
26
|
+
expect { `thing` }.to have_exit_status(100)
|
27
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected that code would exit 100/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/aruba/rspec_spec.rb
CHANGED
@@ -1,4 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Aruba::RSpec do
|
4
|
-
|
4
|
+
describe '::history' do
|
5
|
+
it 'should be an ArubaDoubles::History' do
|
6
|
+
expect(Aruba::RSpec.history).to be_an(ArubaDoubles::History)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '::setup' do
|
11
|
+
it 'sets up ArubaDoubles' do
|
12
|
+
ArubaDoubles::Double.stub(:setup)
|
13
|
+
Aruba::RSpec.setup
|
14
|
+
expect(ArubaDoubles::Double).to have_received(:setup)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '::teardown' do
|
19
|
+
before { ArubaDoubles::Double.stub(:teardown) }
|
20
|
+
|
21
|
+
it 'tears down ArubaDoubles' do
|
22
|
+
Aruba::RSpec.teardown
|
23
|
+
expect(ArubaDoubles::Double).to have_received(:teardown)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'clears the history' do
|
27
|
+
Aruba::RSpec.history.stub(:clear)
|
28
|
+
Aruba::RSpec.teardown
|
29
|
+
expect(Aruba::RSpec.history).to have_received(:clear)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Saxby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -91,14 +91,17 @@ files:
|
|
91
91
|
- ".gitignore"
|
92
92
|
- ".rspec"
|
93
93
|
- Gemfile
|
94
|
+
- Guardfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- aruba-rspec.gemspec
|
98
99
|
- lib/aruba/rspec.rb
|
99
100
|
- lib/aruba/rspec/matchers.rb
|
101
|
+
- lib/aruba/rspec/matchers/have_exit_status.rb
|
100
102
|
- lib/aruba/rspec/matchers/shellout.rb
|
101
103
|
- lib/aruba/rspec/version.rb
|
104
|
+
- spec/aruba/rspec/matchers/have_exit_status_spec.rb
|
102
105
|
- spec/aruba/rspec/matchers/shellout_spec.rb
|
103
106
|
- spec/aruba/rspec_spec.rb
|
104
107
|
- spec/spec_helper.rb
|
@@ -127,6 +130,8 @@ signing_key:
|
|
127
130
|
specification_version: 4
|
128
131
|
summary: Bridge RSpec and Aruba to test command-line tools
|
129
132
|
test_files:
|
133
|
+
- spec/aruba/rspec/matchers/have_exit_status_spec.rb
|
130
134
|
- spec/aruba/rspec/matchers/shellout_spec.rb
|
131
135
|
- spec/aruba/rspec_spec.rb
|
132
136
|
- spec/spec_helper.rb
|
137
|
+
has_rdoc:
|