require_relative 'spec_helper' include GivenFilesystemSpecHelpers describe Cli do use_given_filesystem before(:each) do Cli.settings = dummy_settings @cli = Cli.new end it "fetches burndown data from board-list" do full_board_mock dir = given_directory @cli.options = {"board-list" => "spec/data/board-list.yaml", "output" => dir} @cli.burndowns expect(File.exist?(File.join(dir,"orange/burndown-data-01.yaml"))) expect(File.exist?(File.join(dir,"blue/burndown-data-01.yaml"))) end it "backups board" do expect_any_instance_of(Backup).to receive(:backup) @cli.options = {"board-id" => "1234"} @cli.backup end it "gets lists" do full_board_mock @cli.options = {"board-id" => "53186e8391ef8671265eba9d"} expected_output = < "53186e8391ef8671265eba9d"} expected_output = < "53186e8391ef8671265eba9d"} expected_output = < { 'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby' } ).to_return(:status => 200, :body => body, :headers => {}) @cli.options = {"card-id" => "54ae8485221b1cc5b173e713"} expected_output = "haml\n" expect { @cli.get_description }.to output(expected_output).to_stdout end it "sets description" do expect(STDIN).to receive(:read).and_return("My description") stub_request( :put, "https://api.trello.com/1/cards/54ae8485221b1cc5b173e713/desc?key=mykey&token=mytoken&value=My%20description" ).with( :headers => { 'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Content-Length'=>'0', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby' } ).to_return(:status => 200, :body => "", :headers => {}) @cli.options = {"card-id" => "54ae8485221b1cc5b173e713"} @cli.set_description expect(WebMock).to have_requested(:put, "https://api.trello.com/1/cards/54ae8485221b1cc5b173e713/desc?key=mykey&token=mytoken&value=My%20description") end end