aruba-rspec 0.0.1 → 0.0.2

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: a0263867302d80bead092e5bb3dfc3158697125a
4
- data.tar.gz: be51547f565e2bfc4561c9b8dd4dd87e9604dff6
3
+ metadata.gz: ad4d4ae4e068e08a82846cb71d3f0f18d4bc4b78
4
+ data.tar.gz: 144ca0a998ecb3cad58dbcfa5fe56ca63f93dbc4
5
5
  SHA512:
6
- metadata.gz: 7ca019ded0d113fb6d1b332f4cf0f60015fdc0ba08d3604261548428407a28a0bebfcf17cd25c4dbd5597ef10cfb5b0c19680969abaeafd92115b9ce3899e8c7
7
- data.tar.gz: 3a89b8cab8043b2a84dddbb3672f490dc0e9402e18f7f9498d9b94ee9303d20cd5c78959a6e4b3f7da9098e8858354b691fc937516475bd7ef4671650463963f
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 Aruba::RSpec
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
- @ruby = ruby.call
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 #{@ruby} would run command #{cmd}\nfound: #{Aruba::RSpec.history.map(&:shelljoin)}"
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 #{@ruby} would NOT run command #{cmd}"
13
+ "expected that code would NOT run command #{cmd}"
14
14
  end
15
15
 
16
16
  description do
@@ -1,5 +1,5 @@
1
1
  module Aruba
2
2
  module RSpec
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
data/lib/aruba/rspec.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'aruba/rspec/version'
2
2
 
3
+ require 'aruba'
3
4
  require 'aruba-doubles'
4
5
  require 'aruba/rspec/matchers'
5
6
 
@@ -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
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
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.1
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