CFC-Servers / CFC-Servers/GLuaTest

Allow stubs to replace non-function values too

Open
#37 0 comments 0 reactions 1 assignee Claimed by @sarahsturgeon View on GitHub
enhancement good first issue
Dominant language
Lua
Stars
87
Forks
14
PR merge metrics
No merged PRs in 30d

Description

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:
```lua
{
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:
```lua
{
name = "Example"
func = function( state )
stub( myProject, "foo" ).with( "bar" )
expect( myProject:returnFoo() ).to.equal( "bar" )
end
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.