spec/unit/cli_spec.rb in trollolo-0.0.6 vs spec/unit/cli_spec.rb in trollolo-0.0.7
- old
+ new
@@ -94,6 +94,47 @@
EOT
expect {
@cli.get_checklists
}.to output(expected_output).to_stdout
end
+
+ it "gets description" do
+ body = <<-EOT
+{
+ "id": "54ae8485221b1cc5b173e713",
+ "desc": "haml"
+}
+EOT
+ stub_request(
+ :get, "https://api.trello.com/1/cards/54ae8485221b1cc5b173e713?key=mykey&token=mytoken"
+ ).with(
+ :headers => {
+ '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