Skip to content

Facilitate testing cog::command #33

@pcarranza

Description

@pcarranza

Hey, I love cog and I would like to provide some feedback to improve it if that's possible.

Just yesterday I finished build a cog command and I wanted to add some form of testing for it, in the process of doing it I ended up hitting a couple of walls given how things are implemented.

I was trying to inject values using the environment, which worked great in my local environment, but then it failed silently in the CI environment. The reason why is because CI's env is not a tty: I had to add this before { allow(STDIN).to receive(:tty?) { true } } to my tests because of the request just returning an empty set of arguments and

A better solution would be to just be able of building a request and injecting it in the command when I'm building it, but I saw no simple way without stubbing or monkey patching, and I rather not do it in a dependency I don't own.

You can see the whole test implementation here and you can see how it fails in this GitLab-CI execution

In other words, it's kinda hard to implement tests for cog commands, and it would be great if there is a straightforward way of doing it without having to reverse engineer how cog works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions