spec/util_error_spec.lua
changeset 11105 2288d206b14b
parent 11104 3aa06cdd2dc8
child 11106 5a0ff475ecfd
equal deleted inserted replaced
11104:3aa06cdd2dc8 11105:2288d206b14b
   113 			assert.equal("not-authorized", nope.condition);
   113 			assert.equal("not-authorized", nope.condition);
   114 			assert.equal("Can't let you do that Dave", nope.text);
   114 			assert.equal("Can't let you do that Dave", nope.text);
   115 			assert.equal("spec", nope.extra.namespace);
   115 			assert.equal("spec", nope.extra.namespace);
   116 			assert.equal("sorry-dave", nope.extra.condition);
   116 			assert.equal("sorry-dave", nope.extra.condition);
   117 		end);
   117 		end);
       
   118 
       
   119 		it("registry looks the same regardless of syntax", function()
       
   120 			local normal = errors.init("test", {
       
   121 				broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("};
       
   122 				nope = {
       
   123 					type = "auth";
       
   124 					condition = "not-authorized";
       
   125 					text = "Can't let you do that Dave";
       
   126 					extra = {namespace = "spec"; condition = "sorry-dave"};
       
   127 				};
       
   128 			});
       
   129 			local compact1 = errors.init("test", {
       
   130 				namespace = "spec";
       
   131 				broke = {"cancel"; "internal-server-error"; "It broke :("};
       
   132 				nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-dave"};
       
   133 			});
       
   134 			local compact2 = errors.init("test", "spec", {
       
   135 				broke = {"cancel"; "internal-server-error"; "It broke :("};
       
   136 				nope = {"auth"; "not-authorized"; "Can't let you do that Dave"; "sorry-dave"};
       
   137 			});
       
   138 			local compact3 = errors.init("test", {
       
   139 				broke = {"cancel"; "internal-server-error"; "It broke :("};
       
   140 				nope = {"auth"; "not-authorized"; "Can't let you do that Dave"};
       
   141 			});
       
   142 			assert.same(normal.registry, compact1.registry);
       
   143 			assert.same(normal.registry, compact2.registry);
       
   144 
       
   145 			assert.same({
       
   146 				broke = {type = "cancel"; condition = "internal-server-error"; text = "It broke :("};
       
   147 				nope = {type = "auth"; condition = "not-authorized"; text = "Can't let you do that Dave"};
       
   148 			}, compact3.registry);
       
   149 		end);
   118 	end);
   150 	end);
   119 
   151 
   120 end);
   152 end);
   121 
   153