require 'spec_helper' describe RubyEcommError do before do @result_code = -1 @request_result = -2 @error = RubyEcommError.new(@result_code, @request_result) end context "#initialize" do it "require result_code non-nil" do expect { RubyEcommError.new(nil) }.to raise_error(ArgumentError) end it "require result_code non-blank" do expect { RubyEcommError.new('') }.to raise_error(ArgumentError) end it "honor result_code" do @error.result_code.should eq(@result_code) end it "put result_code in message" do @error.message.should include(@result_code.to_s) end it "require request_result non-blank" do expect { RubyEcommError.new('-100', '') }.to raise_error(ArgumentError) end it "honor request_result" do @error.request_result.should eq(@request_result) end it "put request_result in message" do @error.message.should include(@request_result.to_s) end end end