rspec-bash 0.1.1 → 0.2.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/Gemfile +1 -0
  4. data/README.md +23 -0
  5. data/Rakefile +15 -4
  6. data/bin/bash_stub.sh +92 -0
  7. data/bin/bash_wrapper.sh.erb +12 -0
  8. data/bin/ruby_stub.rb +33 -0
  9. data/lib/rspec/bash.rb +5 -4
  10. data/lib/rspec/bash/command.rb +5 -0
  11. data/lib/rspec/bash/command/call_configuration.rb +76 -0
  12. data/lib/rspec/bash/command/call_configuration_manager.rb +24 -0
  13. data/lib/rspec/bash/command/call_log.rb +48 -0
  14. data/lib/rspec/bash/command/call_log_manager.rb +38 -0
  15. data/lib/rspec/bash/command/stubbed_command.rb +64 -0
  16. data/lib/rspec/bash/server.rb +3 -0
  17. data/lib/rspec/bash/server/bash_stub_marshaller.rb +19 -0
  18. data/lib/rspec/bash/server/ruby_stub_marshaller.rb +13 -0
  19. data/lib/rspec/bash/server/stub_server.rb +47 -0
  20. data/lib/rspec/bash/stubbed_env.rb +75 -54
  21. data/lib/rspec/bash/util/call_conf_argument_list_matcher.rb +5 -5
  22. data/lib/rspec/bash/util/call_log_argument_list_matcher.rb +1 -1
  23. data/lib/rspec/bash/wrapper.rb +4 -0
  24. data/lib/rspec/bash/wrapper/bash_stub_script.rb +15 -0
  25. data/lib/rspec/bash/wrapper/bash_wrapper.rb +54 -0
  26. data/lib/rspec/bash/wrapper/ruby_stub_script.rb +15 -0
  27. data/lib/rspec/bash/wrapper/stub_function.rb +36 -0
  28. data/rspec-bash.gemspec +2 -1
  29. data/spec/classes/command/call_configuration_manager_spec.rb +68 -0
  30. data/spec/classes/{call_configuration_spec.rb → command/call_configuration_spec.rb} +51 -114
  31. data/spec/classes/command/call_log_manager_spec.rb +83 -0
  32. data/spec/classes/{call_log_spec.rb → command/call_log_spec.rb} +23 -82
  33. data/spec/classes/command/stubbed_command_spec.rb +118 -0
  34. data/spec/classes/server/bash_stub_marshaller_spec.rb +38 -0
  35. data/spec/classes/server/ruby_stub_marshaller_spec.rb +31 -0
  36. data/spec/classes/server/stub_server_spec.rb +121 -0
  37. data/spec/classes/stubbed_env_spec.rb +141 -280
  38. data/spec/classes/util/call_conf_argument_list_matcher_spec.rb +17 -17
  39. data/spec/classes/util/call_log_argument_list_matcher_spec.rb +24 -18
  40. data/spec/classes/wrapper/bash_wrapper_spec.rb +37 -0
  41. data/spec/classes/wrapper/ruby_stub_script_spec.rb +204 -0
  42. data/spec/helper/string_file_io.rb +1 -1
  43. data/spec/integration/call_log/called_with_args_spec.rb +8 -4
  44. data/spec/integration/call_log/called_with_no_args_spec.rb +1 -1
  45. data/spec/integration/call_log/stdin_spec.rb +10 -4
  46. data/spec/integration/edge_cases_spec.rb +34 -0
  47. data/spec/integration/matchers/be_called_with_arguments_spec.rb +12 -13
  48. data/spec/integration/matchers/be_called_with_no_arguments_spec.rb +6 -7
  49. data/spec/integration/stubbed_command/outputs_spec.rb +111 -91
  50. data/spec/integration/stubbed_command/returns_exitstatus_spec.rb +46 -37
  51. data/spec/integration/stubbed_env/execute_with_env_vars_spec.rb +3 -4
  52. data/spec/integration/stubbed_env/execute_with_path_spec.rb +6 -7
  53. data/spec/integration/stubbed_env/execute_with_stub_wrapper_spec.rb +4 -12
  54. data/spec/integration/stubbed_env/override_spec.rb +354 -0
  55. data/spec/integration/wrapper/bash_stub_script_spec.rb +383 -0
  56. data/spec/integration/wrapper/bash_wrapper_spec.rb +48 -0
  57. data/spec/scripts/function_library.sh +9 -1
  58. data/spec/spec_helper.rb +2 -0
  59. metadata +65 -21
  60. data/bin/function_override.sh.erb +0 -7
  61. data/bin/function_override_wrapper.sh.erb +0 -19
  62. data/bin/stub.rb.erb +0 -56
  63. data/lib/rspec/bash/call_configuration.rb +0 -62
  64. data/lib/rspec/bash/call_log.rb +0 -71
  65. data/lib/rspec/bash/stubbed_command.rb +0 -88
  66. data/spec/classes/stub_spec.rb +0 -510
  67. data/spec/classes/stubbed_command_spec.rb +0 -134
  68. data/spec/integration/assert_called_spec.rb +0 -0
@@ -1,134 +0,0 @@
1
- require 'spec_helper'
2
- include Rspec::Bash
3
-
4
- describe 'StubbedCommand' do
5
- include_examples 'manage a :temp_directory'
6
-
7
- before(:each) do
8
- allow(FileUtils).to receive(:cp)
9
- end
10
-
11
- context '#called_with_args?' do
12
- before(:each) do
13
- @call_log = double(Rspec::Bash::CallLog)
14
- allow(Rspec::Bash::CallLog).to receive(:new).and_return(@call_log)
15
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
16
- end
17
- context 'with only a series of arguments' do
18
- it 'passes the check to its CallLog\'s #called_with_args? method' do
19
- expect(@call_log).to receive(:called_with_args?)
20
- .with('first_argument', 'second_argument')
21
- .and_return(true)
22
- @subject.called_with_args?('first_argument', 'second_argument')
23
- end
24
- end
25
- end
26
-
27
- context '#with_args' do
28
- before(:each) do
29
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
30
- @subject.with_args('argument_one', 'argument_two')
31
- end
32
- it 'sets the arguments array on the StubbedCommand to the arguments that were passed in' do
33
- expect(@subject.arguments).to eql %w(argument_one argument_two)
34
- end
35
- end
36
-
37
- context '#call_count' do
38
- before(:each) do
39
- @call_log = double(Rspec::Bash::CallLog)
40
- allow(Rspec::Bash::CallLog).to receive(:new).and_return(@call_log)
41
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
42
- end
43
- it 'returns value returned from call_log argument count when there are no arguments' do
44
- expect(@call_log).to receive(:call_count).with([]).and_return('arbitrary return value')
45
- expect(@subject.call_count([])).to eql 'arbitrary return value'
46
- end
47
- it 'returns value returned from call_log argument count when there is only one argument' do
48
- expect(@call_log).to receive(:call_count)
49
- .with(['only arg'])
50
- .and_return('arbitrary return value')
51
- expect(@subject.call_count(['only arg'])).to eql 'arbitrary return value'
52
- end
53
- it 'returns value returned from call_log argument count when there are multiple arguments' do
54
- expect(@call_log).to receive(:call_count).with(['first arg', 'second arg'])
55
- .and_return('arbitrary return value')
56
- expect(@subject.call_count(['first arg', 'second arg'])).to eql 'arbitrary return value'
57
- end
58
- end
59
-
60
- context '#called?' do
61
- before(:each) do
62
- @call_log = double(Rspec::Bash::CallLog)
63
- allow(Rspec::Bash::CallLog).to receive(:new).and_return(@call_log)
64
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
65
- end
66
- it 'returns false when there is no call_log' do
67
- expect(@call_log).to receive(:exist?).and_return(false)
68
- expect(@subject.called?).to be_falsey
69
- end
70
- it 'returns false when call_log is not called with args' do
71
- expect(@call_log).to receive(:exist?).and_return(true)
72
- expect(@call_log).to receive(:called_with_args?).and_return(false)
73
- expect(@subject.called?).to be_falsey
74
- end
75
- it 'returns true when call_log is called with args' do
76
- expect(@call_log).to receive(:exist?).and_return(true)
77
- expect(@call_log).to receive(:called_with_args?).and_return(true)
78
- expect(@subject.called?).to be_truthy
79
- end
80
- end
81
-
82
- context '#stdin' do
83
- before(:each) do
84
- @call_log = double(Rspec::Bash::CallLog)
85
- allow(Rspec::Bash::CallLog).to receive(:new).and_return(@call_log)
86
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
87
- end
88
- it 'returns nil when there is no call_log' do
89
- expect(@call_log).to receive(:exist?).and_return(false)
90
- expect(@subject.stdin).to be_nil
91
- end
92
- it 'returns stdin from call log when call_log exists' do
93
- expect(@call_log).to receive(:exist?).and_return(true)
94
- expect(@call_log).to receive(:stdin_for_args).and_return('arbitrary stdin')
95
- expect(@subject.stdin).to eql 'arbitrary stdin'
96
- end
97
- end
98
-
99
- context '#returns_exitstatus' do
100
- before(:each) do
101
- @call_configuration = double(Rspec::Bash::CallConfiguration)
102
- allow(Rspec::Bash::CallConfiguration).to receive(:new).and_return(@call_configuration)
103
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
104
- end
105
- it 'sets the exitcode on call_configuration' do
106
- expect(@call_configuration).to receive(:set_exitcode).with('exit code', anything)
107
- @subject.returns_exitstatus 'exit code'
108
- end
109
- it 'returns itself' do
110
- expect(@call_configuration).to receive(:set_exitcode)
111
- expect(@subject.returns_exitstatus(anything)).to eql @subject
112
- end
113
- end
114
-
115
- context '#outputs' do
116
- before(:each) do
117
- @call_configuration = double(Rspec::Bash::CallConfiguration)
118
- allow(Rspec::Bash::CallConfiguration).to receive(:new).and_return(@call_configuration)
119
- @subject = Rspec::Bash::StubbedCommand.new('command', temp_directory)
120
- end
121
- it 'sets the output on the call_configuration' do
122
- expect(@call_configuration).to receive(:add_output).with('contents', 'stderr', anything)
123
- @subject.outputs('contents', to: 'stderr')
124
- end
125
- it 'sets the "to" value for the output to stdout by default' do
126
- expect(@call_configuration).to receive(:add_output).with('contents', :stdout, anything)
127
- @subject.outputs('contents')
128
- end
129
- it 'returns itself' do
130
- expect(@call_configuration).to receive(:add_output)
131
- expect(@subject.outputs(anything)).to eql @subject
132
- end
133
- end
134
- end
File without changes