require "open3" describe "detom set" do subject { Open3.capture3(command) } let(:stdout) { subject[0] } let(:stderr) { subject[1] } before do @original_dir = Dir.pwd Dir.chdir File.join(File.dirname(__FILE__), "..", "..", "tmp") %x(rm -rf .detom) end after do Dir.chdir @original_dir end context "when no args are provided" do let(:command) { "bundle exec ../bin/detom set" } let(:expected_stderr) do <"foo"} OUT end it do expect(stdout).to eq expected_stdout expect(File.exist? ".detom").to be_truthy end context "and config already exists" do before { %x(bundle exec ../bin/detom set faa) } let(:expected_stdout) do <"foo"} OUT end it do expect(stdout).to eq expected_stdout expect(File.exist? ".detom").to be_truthy end end end context "when a client and project are provided" do let(:command) { "bundle exec ../bin/detom set foo project_tree" } let(:expected_stdout) do <"foo", :project=>"project_tree"} OUT end it do expect(stdout).to eq expected_stdout expect(File.exist? ".detom").to be_truthy end context "and config already exists" do before { %x(bundle exec ../bin/detom set faa) } let(:expected_stdout) do <"foo", :project=>"project_tree"} OUT end it do expect(stdout).to eq expected_stdout expect(File.exist? ".detom").to be_truthy end end end end