ops
ops copied to clipboard
Make it easier to implement e2e specs
There are a few things that make implementing an e2e spec more work and less DRY than it should be.
This is an example:
RSpec.describe "ssh key with passphrase var" do
include_context "ops e2e"
before(:all) do
Dir.chdir(__dir__)
remove_untracked_files
@output, @output_file, @exit_status = run_ops("../../../../bin/ops up")
end
# actual tests goes here
end
Things that could be improved:
- doing a
chdir: must be done in every spec, correctly, or the tests will run with a) noops.ymlor b) worse: the wrongops.yml - removing untracked files: must be done in every spec (so far; maybe someday a spec won't need it)
- setting local variables: I'm not sure how legit this is to do in an
rspecspec; maybe there's a better way - knowing the path back to the ops installation: maybe a method in "ops e2e" context could handle this, if you pass an array like
["up", "my_action", "down"]
Basically, having to copy and paste this block to every spec and tweaking the path to bin/ops is not ideal.
This allows multiple ops commands to be tested in a single spec file, but it's a total hack:
https://github.com/nickthecook/ops/blob/4dc85856e1868f906730ffb07aebfa4cac46bae9/spec/e2e/forwards/e2e_spec.rb#L12