rspec-bash 0.1.0 → 0.1.1

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: 5264f0b8921b472fdb32e393e55004b5e1f3c885
4
- data.tar.gz: bf99d54315422b4e885dfabab09729e39e94053c
3
+ metadata.gz: b8768c8e7a3e2d1a30a82c8a7a4608786d38a619
4
+ data.tar.gz: aa8e860680f978205a989b10f7f141d89f4c9bb3
5
5
  SHA512:
6
- metadata.gz: 3bffee5f454d467b72a797016d1745cc1c5c6aa1743a4b24654394bd762738d953678d42350806e67a0a5c78c976fe99a05c2bc39793715b90a1cafffa811703
7
- data.tar.gz: b9cb113c2ead82843566c750ce0b4fcf7f98e97a63117df42e8a2c603dbacac27243a0bcf2aaabff60b775c39f681f1bdc65910ef3fde1833c1590cd32c116d5
6
+ metadata.gz: 2ad5a2600f1aa8e2e30ff92834aedcbd070d01067f2f9e51683de3624c957ee6bbbd86214dd30bcd4d6816c86714156b2abafeee83791de33757acdaaccf2e4e
7
+ data.tar.gz: 4bd0fa4d49b57f6618c5ba970359d3f6a2472dc21b5d6d0c6c1f30d709f7f0e9e2eff1f50785cb10cfccece5458428c99d4da59340103377d57c9959e5d8adc8
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
+ - 2.4.1
5
+ - 2.3.4
4
6
  - 2.2.0
5
7
  - 2.1.0
6
8
  - 2.0.0
data/README.md CHANGED
@@ -76,7 +76,7 @@ see specs in *spec/integration* folder:
76
76
 
77
77
  it 'is stubbed' do
78
78
  stubbed_env.execute 'my-script.sh'
79
- expect(bundle).to be_called_with_arguments('install)
79
+ expect(bundle).to be_called_with_arguments('install')
80
80
  end
81
81
  ```
82
82
 
@@ -55,6 +55,10 @@ module Rspec
55
55
  write new_log
56
56
  end
57
57
 
58
+ def call_log_arguments
59
+ call_log.map { |call_log| call_log[:args] || [] }.compact
60
+ end
61
+
58
62
  private
59
63
 
60
64
  def write(call_log_to_write)
@@ -7,6 +7,7 @@ RSpec::Matchers.define :be_called_with_arguments do |*expected_argument_list|
7
7
 
8
8
  match do |actual_command|
9
9
  called_with_correct_args = actual_command.called_with_args?(*expected_argument_list)
10
+
10
11
  if @expected_invocations
11
12
  called_correct_number_of_times =
12
13
  actual_command.call_count(*expected_argument_list) == @expected_invocations
@@ -16,4 +17,33 @@ RSpec::Matchers.define :be_called_with_arguments do |*expected_argument_list|
16
17
 
17
18
  called_with_correct_args && called_correct_number_of_times
18
19
  end
20
+
21
+ failure_message do |actual_command|
22
+ formatted_actual_calls, formatted_expected_call =
23
+ get_expected_and_actual_call_strings(actual_command, expected_argument_list)
24
+
25
+ "Expected #{actual_command.command} to be called with args #{expected_argument_list}\n\n" \
26
+ "Expected Calls:\n#{formatted_expected_call}\n\n" \
27
+ "Actual Calls:\n#{formatted_actual_calls}\n"
28
+ end
29
+
30
+ failure_message_when_negated do |actual_command|
31
+ formatted_actual_calls, formatted_expected_call =
32
+ get_expected_and_actual_call_strings(actual_command, expected_argument_list)
33
+
34
+ "Expected #{actual_command.command} to not be called with args #{expected_argument_list}\n\n" \
35
+ "Expected Omissions:\n#{formatted_expected_call}\n\n" \
36
+ "Actual Calls:\n#{formatted_actual_calls}\n"
37
+ end
38
+ end
39
+
40
+ def get_expected_and_actual_call_strings(actual_command, expected_argument_list)
41
+ command_name = actual_command.command
42
+
43
+ formatted_expected_call = "#{command_name} #{expected_argument_list.join(' ')}"
44
+ formatted_actual_calls = actual_command.call_log.call_log_arguments.map do |arg_array|
45
+ "#{command_name} #{arg_array.join(' ')}"
46
+ end.join("\n")
47
+
48
+ [formatted_actual_calls, formatted_expected_call]
19
49
  end
@@ -36,6 +36,10 @@ module Rspec
36
36
  @call_log.call_count(*arg)
37
37
  end
38
38
 
39
+ def command
40
+ @call_configuration.command
41
+ end
42
+
39
43
  def returns_exitstatus(exitcode)
40
44
  @call_configuration.set_exitcode(exitcode, @arguments)
41
45
  self
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'rspec-bash'
7
- spec.version = '0.1.0'
7
+ spec.version = '0.1.1'
8
8
  spec.authors = ['Ben Brewer', 'Mike Urban', 'Matthijs Groen']
9
9
  spec.email = ['ben@benbrewer.me', 'mike.david.urban@gmail.com']
10
10
  spec.summary = 'Test Bash with RSpec'
File without changes
@@ -43,6 +43,41 @@ describe 'CallLog' do
43
43
  it 'matches for regex matches' do
44
44
  expect(first_command).to be_called_with_arguments(/f..st_argument/, /se..nd_argument/)
45
45
  end
46
+
47
+ it 'displays the diff between what was called and what was expected' do
48
+ begin
49
+ expect(first_command).to be_called_with_arguments('not_first_argument', 'second_argument')
50
+ rescue RSpec::Expectations::ExpectationNotMetError => rex
51
+ expected_error_string = <<-multiline_string
52
+ Expected first_command to be called with args ["not_first_argument", "second_argument"]
53
+
54
+ Expected Calls:
55
+ first_command not_first_argument second_argument
56
+
57
+ Actual Calls:
58
+ first_command first_argument second_argument
59
+ first_command first_argument second_argument third_argument
60
+ multiline_string
61
+ expect(rex.message).to eql expected_error_string
62
+ end
63
+ end
64
+ it 'displays the diff between what was called and what was not expected' do
65
+ begin
66
+ expect(first_command).to_not be_called_with_arguments('first_argument', 'second_argument')
67
+ rescue RSpec::Expectations::ExpectationNotMetError => rex
68
+ expected_error_string = <<-multiline_string
69
+ Expected first_command to not be called with args ["first_argument", "second_argument"]
70
+
71
+ Expected Omissions:
72
+ first_command first_argument second_argument
73
+
74
+ Actual Calls:
75
+ first_command first_argument second_argument
76
+ first_command first_argument second_argument third_argument
77
+ multiline_string
78
+ expect(rex.message).to eql expected_error_string
79
+ end
80
+ end
46
81
  end
47
82
  end
48
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-bash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Brewer
@@ -10,34 +10,34 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-04-10 00:00:00.000000000 Z
13
+ date: 2017-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.6'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.6'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ~>
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
35
  version: '10.0'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '10.0'
43
43
  description: |2
@@ -52,11 +52,11 @@ executables:
52
52
  extensions: []
53
53
  extra_rdoc_files: []
54
54
  files:
55
- - .gitignore
56
- - .rspec
57
- - .rubocop.yml
58
- - .ruby-version
59
- - .travis.yml
55
+ - ".gitignore"
56
+ - ".rspec"
57
+ - ".rubocop.yml"
58
+ - ".ruby-version"
59
+ - ".travis.yml"
60
60
  - CHANGELOG.md
61
61
  - Gemfile
62
62
  - LICENSE.txt
@@ -76,7 +76,6 @@ files:
76
76
  - lib/rspec/bash/util.rb
77
77
  - lib/rspec/bash/util/call_conf_argument_list_matcher.rb
78
78
  - lib/rspec/bash/util/call_log_argument_list_matcher.rb
79
- - return_exitstatus_spec.rb
80
79
  - rspec-bash.gemspec
81
80
  - spec/classes/call_configuration_spec.rb
82
81
  - spec/classes/call_log_spec.rb
@@ -87,6 +86,7 @@ files:
87
86
  - spec/classes/util/call_log_argument_list_matcher_spec.rb
88
87
  - spec/helper/shared_tmpdir.rb
89
88
  - spec/helper/string_file_io.rb
89
+ - spec/integration/assert_called_spec.rb
90
90
  - spec/integration/call_log/called_with_args_spec.rb
91
91
  - spec/integration/call_log/called_with_no_args_spec.rb
92
92
  - spec/integration/call_log/stdin_spec.rb
@@ -109,17 +109,17 @@ require_paths:
109
109
  - lib
110
110
  required_ruby_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - '>='
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.0.14
122
+ rubygems_version: 2.2.2
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Test Bash with RSpec
@@ -133,6 +133,7 @@ test_files:
133
133
  - spec/classes/util/call_log_argument_list_matcher_spec.rb
134
134
  - spec/helper/shared_tmpdir.rb
135
135
  - spec/helper/string_file_io.rb
136
+ - spec/integration/assert_called_spec.rb
136
137
  - spec/integration/call_log/called_with_args_spec.rb
137
138
  - spec/integration/call_log/called_with_no_args_spec.rb
138
139
  - spec/integration/call_log/stdin_spec.rb
@@ -1,14 +0,0 @@
1
- require 'English'
2
- require 'rspec/bash'
3
-
4
- describe 'very simple script that just exits' do
5
- include Rspec::Bash
6
- let(:stubbed_env) { create_stubbed_env }
7
- it 'returns an exit status of 0' do
8
- out, err, rv = stubbed_env.execute_inline('exit 0')
9
-
10
- expect(out).to eql ''
11
- expect(err).to eql ''
12
- expect(rv.exitstatus).to eql 0
13
- end
14
- end