Module: AwesomeSpawn::SpecHelper
- Defined in:
- lib/awesome_spawn/spec_helper.rb
Class Method Summary collapse
-
.disable_spawning(config, file_path: nil) ⇒ Object
Disable spawning for specs.
Instance Method Summary collapse
- #disable_spawning ⇒ Object
- #enable_spawning ⇒ Object
- #stub_bad_run(command, options = {}) ⇒ Object
- #stub_bad_run!(command, options = {}) ⇒ Object
- #stub_good_run(command, options = {}) ⇒ Object
- #stub_good_run!(command, options = {}) ⇒ Object
Class Method Details
.disable_spawning(config, file_path: nil) ⇒ Object
Disable spawning for specs
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/awesome_spawn/spec_helper.rb', line 19 def self.disable_spawning(config, file_path: nil) if file_path config.(:file_path => file_path) do || [:uses_awesome_spawn] = true end config.include AwesomeSpawn::SpecHelper, :uses_awesome_spawn => true config.before(:each, :uses_awesome_spawn) { disable_spawning } else config.include AwesomeSpawn::SpecHelper config.before { disable_spawning } end config end |
Instance Method Details
#disable_spawning ⇒ Object
33 34 35 36 |
# File 'lib/awesome_spawn/spec_helper.rb', line 33 def disable_spawning allow(Open3).to receive(:capture3) .and_raise("Spawning is not permitted in specs. Please change your spec to use expectations/stubs.") end |
#enable_spawning ⇒ Object
38 39 40 |
# File 'lib/awesome_spawn/spec_helper.rb', line 38 def enable_spawning allow(Open3).to receive(:capture3).and_call_original end |
#stub_bad_run(command, options = {}) ⇒ Object
46 47 48 |
# File 'lib/awesome_spawn/spec_helper.rb', line 46 def stub_bad_run(command, = {}) stub_run(:bad, :run, command, ) end |
#stub_bad_run!(command, options = {}) ⇒ Object
54 55 56 |
# File 'lib/awesome_spawn/spec_helper.rb', line 54 def stub_bad_run!(command, = {}) stub_run(:bad, :run!, command, ) end |
#stub_good_run(command, options = {}) ⇒ Object
42 43 44 |
# File 'lib/awesome_spawn/spec_helper.rb', line 42 def stub_good_run(command, = {}) stub_run(:good, :run, command, ) end |
#stub_good_run!(command, options = {}) ⇒ Object
50 51 52 |
# File 'lib/awesome_spawn/spec_helper.rb', line 50 def stub_good_run!(command, = {}) stub_run(:good, :run!, command, ) end |