context 'given invalid build name' let(:config_file) { ('login.yml') } let(:client) { double(jenkinsapi::client) } let(:logger_mock) { double("logger").as_null_object } let(:exception) { double(jenkinsapi::exceptions::notfound) } before allow(yaml) .to receive(:load_file) .with('login.yml') .and_return(config_file) allow(jenkinsapi::client) .to receive(:new).with(config_file).and_return(client) allow(client).to receive_message_chain(:job, :status) {'build'} allow(client.job).to receive(jenkinsapi::exceptions::notfound).and_return(exception) end 'should throw notfound error' expect{client.job.status('bad_build')}.to raise_error end
for testing, want jenkins api raise jenkinsapi::exceptions::notfound. don't want ping actual server test, use mocking raise exception. have tried numerous variations , unable call it.
any appreciated.
failure/error: allow(client.job).to receive(jenkinsapi::exceptions::notfound).and_return(exception) nomethoderror: undefined method `to_sym' jenkinsapi::exceptions::notfound:class did mean? to_s
this current error receiving. have been getting errors not raising exception.
Comments
Post a Comment