Allow stubs to replace non-function values too
brandonsturgeon opened this issue · 0 comments
brandonsturgeon commented
Sometimes you want to stub non-function values, like convars, strings, etc. from tables. Right now, you'd have to manually keep track of and clean up the changes:
{
name = "Example"
func = function( state )
state.original_foo = state.original_foo or myProject.foo
myProject.foo = "bar"
expect( myProject:returnFoo() ).to.equal( "bar" )
end,
cleanup = function( state )
myProject.foo = state.original_foo
end
}
It would be nice if we could do:
{
name = "Example"
func = function( state )
stub( myProject, "foo" ).with( "bar" )
expect( myProject:returnFoo() ).to.equal( "bar" )
end
}