cli_tester 0.0.3 → 0.0.4
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 +4 -0
- data/lib/cli_tester.rb +11 -9
- data/lib/version.rb +1 -1
- data/spec/cli_tester_spec.rb +6 -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: dcbcdfed58c37e9a043d8003691821a7a71f62c6
|
4
|
+
data.tar.gz: f44be5dfb8584e52c1c562aa0e228b881d28f9c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7b2ce02707de913aed72644af2b82cf18027fa7d08097955e172fe5e921b30649b97fb8b414663b3e150102805dbd8b5ffe7b41cb0a847543591b619cc0e0e
|
7
|
+
data.tar.gz: a94d7947063ff90a97713da6e7a6824ae4af0ffc8530d2410cbd4b4af7990e2445339ca63e685daa56b77e12b1faad1c12de739259b931c20ae17b828fa8401e
|
data/CHANGELOG.md
CHANGED
data/lib/cli_tester.rb
CHANGED
@@ -122,16 +122,18 @@ RSpec::Matchers.define :exit_with_success do |expected_stdout, expected_stderr|
|
|
122
122
|
message += " (was '#{Regexp.escape(result.stderr)}')\n"
|
123
123
|
end
|
124
124
|
end
|
125
|
-
if expected_stdout
|
126
|
-
|
127
|
-
|
128
|
-
else
|
129
|
-
if result.stdout != expected_stdout
|
130
|
-
message += "expected stdout to be '#{Regexp.escape(expected_stdout)}'"
|
125
|
+
if expected_stdout
|
126
|
+
if expected_stdout.is_a?(Regexp)
|
127
|
+
message += "stdout didn't match #{expected_stdout.inspect}"
|
131
128
|
message += " (was '#{Regexp.escape(result.stdout)}')"
|
132
|
-
|
133
|
-
|
134
|
-
|
129
|
+
else
|
130
|
+
if result.stdout != expected_stdout
|
131
|
+
message += "expected stdout to be '#{Regexp.escape(expected_stdout)}'"
|
132
|
+
message += " (was '#{Regexp.escape(result.stdout)}')"
|
133
|
+
message += "\n\nDiff of stdout:"
|
134
|
+
differ = RSpec::Support::Differ.new(color: true)
|
135
|
+
message += differ.diff(result.stdout, expected_stdout)
|
136
|
+
end
|
135
137
|
end
|
136
138
|
end
|
137
139
|
message
|
data/lib/version.rb
CHANGED
data/spec/cli_tester_spec.rb
CHANGED
@@ -65,6 +65,12 @@ describe "matchers" do
|
|
65
65
|
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
66
66
|
end
|
67
67
|
|
68
|
+
it "fails when program exits with non 0 and no stdout is given for comparison" do
|
69
|
+
expect {
|
70
|
+
expect(run_command(args: ["fail"])).to exit_with_success
|
71
|
+
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
72
|
+
end
|
73
|
+
|
68
74
|
it "succeeds when program exists with 0 and no stdout is given for comparison" do
|
69
75
|
expect {
|
70
76
|
expect(run_command(args: ["list"])).to exit_with_success
|