rspec-shell-expectations 1.2.0 → 1.3.0
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/CHANGELOG.md +11 -0
- data/lib/rspec/shell/expectations/call_configuration.rb +4 -1
- data/lib/rspec/shell/expectations/stubbed_call.rb +9 -0
- data/lib/rspec/shell/expectations/stubbed_command.rb +6 -2
- data/lib/rspec/shell/expectations/version.rb +1 -1
- data/spec/assert_called_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a7806669b0fcc1293550fff6d714531aaf42a9
|
4
|
+
data.tar.gz: fb7927391372304271df2643126562a5e55c12d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a3b7816d7a00ce952222c6e3c9b28f3b6bd1e0fb00e3664bf6c55cc20e81807e4fcdbca912082ef6417fdd5778c0f43ebbf563911d93322e1bcd70906cc1f27
|
7
|
+
data.tar.gz: 4524a3f60e408ffd8039ca110bc187cf6d9a9b5f065f7ae826ed292a0b71426bac775f5a3f2cf0543e14421a1312a26be63113bd57de75a0c40465268249bd50
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# 1.3.0
|
2
|
+
|
3
|
+
* Improved assertion message
|
4
|
+
|
5
|
+
# 1.2.0
|
6
|
+
|
7
|
+
* Support for output filenames based on input arguments
|
8
|
+
(`.outputs('something', to: [:arg2, '.png'])`
|
9
|
+
* Updates local `ENV['PATH']` to easy test execution from private code
|
10
|
+
* Add `stubbed_env.cleanup` to cleanup `ENV['PATH']` manually
|
11
|
+
|
1
12
|
# 1.1.0
|
2
13
|
|
3
14
|
* Support chaining of arguments in multiple steps
|
@@ -5,9 +5,12 @@ module Rspec
|
|
5
5
|
module Expectations
|
6
6
|
# Configuration of a stubbed command
|
7
7
|
class CallConfiguration
|
8
|
-
|
8
|
+
attr_reader :command
|
9
|
+
|
10
|
+
def initialize(config_path, command)
|
9
11
|
@config_path = config_path
|
10
12
|
@configuration = {}
|
13
|
+
@command = command
|
11
14
|
end
|
12
15
|
|
13
16
|
def set_exitcode(statuscode, args = [])
|
@@ -32,6 +32,15 @@ module Rspec
|
|
32
32
|
return false unless @call_log.exist?
|
33
33
|
@call_log.called_with_args?(*@args)
|
34
34
|
end
|
35
|
+
|
36
|
+
def inspect
|
37
|
+
if @args.any?
|
38
|
+
"<Stubbed #{@config.command.inspect} " \
|
39
|
+
"args: #{@args.join(' ').inspect}>"
|
40
|
+
else
|
41
|
+
"<Stubbed #{@config.command.inspect}>"
|
42
|
+
end
|
43
|
+
end
|
35
44
|
end
|
36
45
|
end
|
37
46
|
end
|
@@ -5,10 +5,10 @@ module Rspec
|
|
5
5
|
# and monitors input
|
6
6
|
class StubbedCommand
|
7
7
|
def initialize(command, dir)
|
8
|
-
@dir, @command = dir, command
|
9
8
|
FileUtils.cp(stub_filepath, File.join(dir, command))
|
10
9
|
@call_configuration = CallConfiguration.new(
|
11
|
-
Pathname.new(dir).join("#{command}_stub.yml")
|
10
|
+
Pathname.new(dir).join("#{command}_stub.yml"),
|
11
|
+
command
|
12
12
|
)
|
13
13
|
@call_log = CallLog.new(
|
14
14
|
Pathname.new(dir).join("#{command}_calls.yml")
|
@@ -39,6 +39,10 @@ module Rspec
|
|
39
39
|
with_args.outputs(contents, to: to)
|
40
40
|
end
|
41
41
|
|
42
|
+
def inspect
|
43
|
+
with_args.inspect
|
44
|
+
end
|
45
|
+
|
42
46
|
private
|
43
47
|
|
44
48
|
def stub_filepath
|
data/spec/assert_called_spec.rb
CHANGED
@@ -39,5 +39,13 @@ describe 'Assert called' do
|
|
39
39
|
expect(command1_stub.with_args('foo')).not_to be_called
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
describe 'assertion message' do
|
44
|
+
it 'provides a helpful message' do
|
45
|
+
expect(command1_stub.inspect).to eql '<Stubbed "command1">'
|
46
|
+
expect(command1_stub.with_args('foo bar').inspect).to \
|
47
|
+
eql '<Stubbed "command1" args: "foo bar">'
|
48
|
+
end
|
49
|
+
end
|
42
50
|
end
|
43
51
|
end
|