Skip to content

Instantly share code, notes, and snippets.

@universal
Forked from marzdgzmn/output
Last active September 27, 2018 07:26
Show Gist options
  • Save universal/e7ea2cf10d1932895c4d55ae767fe19f to your computer and use it in GitHub Desktop.
Save universal/e7ea2cf10d1932895c4d55ae767fe19f to your computer and use it in GitHub Desktop.
1) MirrorSync#execute_custom_script when the custom script succesfully runs should not raise any errors
Failure/Error: expect { mirror_sync.execute_custom_script('false') }.to_not raise_error
expected no Exception, got #<NameError: undefined local variable or method `e' for #<MirrorSync:0x00005601c08bce60>> with backtrace:
# ./spec/models/mirror_sync_spec.rb:9:in `execute_custom_script'
# ./spec/models/mirror_sync_spec.rb:20:in `block (5 levels) in <top (required)>'
# ./spec/models/mirror_sync_spec.rb:20:in `block (4 levels) in <top (required)>'
class MirrorSync
def execute_custom_script(cmd)
begin
output = %x(#{cmd})
unless $?.exitstatus == 0
raise Exception.new(e.message)
end
end
end
end
require 'rails_helper'
RSpec.describe MirrorSync, type: :model do
describe '#execute_custom_script' do
context 'when the custom script succesfully runs' do
it 'should not raise any errors' do
mirror_sync = MirrorSync.new
expect { mirror_sync.execute_custom_script('false') }.to_not raise_error
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment