lunarmodules / luassert

Assertion library for Lua
MIT License
202 stars 77 forks source link

Mock/Stub non-function values #140

Closed johnfoconnor closed 5 years ago

johnfoconnor commented 8 years ago

Imagine we have a table City with the key path City.current.attributes.id = 10

and a function

function isMyCity(my_city_id)
    return City.current.attributes.id == my_city_id
end

It would be useful to mock the value of City.current.attributes.id to test isMyCity. However luassert only supports mocking for keys which contain functions. Why not allow mocking for keys that contain other values. Such as the number in our above example.

Looking at the implementation i dont see a reason for this restriction. Is there something im not aware of preventing this?