spec/unit/cli_spec.rb in trollolo-0.0.9 vs spec/unit/cli_spec.rb in trollolo-0.0.10
- old
+ new
@@ -4,11 +4,12 @@
describe Cli do
use_given_filesystem
before(:each) do
- Cli.settings = dummy_settings
+ Cli.settings = Settings.new(
+ File.expand_path('../../data/trollolorc_with_board_aliases', __FILE__))
@cli = Cli.new
end
it "fetches burndown data from board-list" do
full_board_mock
@@ -24,10 +25,16 @@
expect_any_instance_of(Backup).to receive(:backup)
@cli.options = {"board-id" => "1234"}
@cli.backup
end
+ it "backups board using an alias" do
+ expect_any_instance_of(Backup).to receive(:backup)
+ @cli.options = {"board-id" => "MyTrelloBoard"}
+ @cli.backup
+ end
+
it "gets lists" do
full_board_mock
@cli.options = {"board-id" => "53186e8391ef8671265eba9d"}
expected_output = <<EOT
Sprint Backlog
@@ -38,10 +45,17 @@
Legend
EOT
expect {
@cli.get_lists
}.to output(expected_output).to_stdout
+
+
+ # Using an alias
+ @cli.options = {"board-id" => "MyTrelloBoard"}
+ expect {
+ @cli.get_lists
+ }.to output(expected_output).to_stdout
end
it "gets cards" do
full_board_mock
@cli.options = {"board-id" => "53186e8391ef8671265eba9d"}
@@ -71,10 +85,16 @@
Background image
EOT
expect {
@cli.get_cards
}.to output(expected_output).to_stdout
+
+ # Using an alias
+ @cli.options = {"board-id" => "MyTrelloBoard"}
+ expect {
+ @cli.get_cards
+ }.to output(expected_output).to_stdout
end
it "gets checklists" do
full_board_mock
@cli.options = {"board-id" => "53186e8391ef8671265eba9d"}
@@ -93,10 +113,16 @@
Tasks
EOT
expect {
@cli.get_checklists
}.to output(expected_output).to_stdout
+
+ # Using an alias
+ @cli.options = {"board-id" => "MyTrelloBoard"}
+ expect {
+ @cli.get_checklists
+ }.to output(expected_output).to_stdout
end
it "gets description" do
body = <<-EOT
{
@@ -134,7 +160,54 @@
}
).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
+
+ it "sets priorities for default planning list", vcr: "prioritize_backlog_list", vcr_record: false do
+ @cli.options = {"board-id" => "neUHHzDo"}
+
+ expected_output = <<-EOT
+set priority to 1 for "P1: (2) Document how to run cf-openstack-validator on SUSE"
+set priority to 2 for "P2: Etymologie von Foo"
+set priority to 3 for "P3: (3) Set up Concourse pipeline for stemcell building"
+set priority to 4 for "P4: (6) Build #stemcell in containers &sort=123"
+set priority to 5 for "P5: (2) Document how to run cf-openstack-validator on SUSE"
+set priority to 6 for "P6: (3) Set up Concourse pipeline for os image building"
+set priority to 7 for "P7: (3) Set up Concourse pipeline for stemcell building"
+set priority to 8 for "P8: (6) Build stemcell in containers"
+set priority to 9 for "P9: (3) Set up Concourse pipeline for BATs"
+set priority to 10 for "P10: seabed"
+set priority to 11 for "P11: (3) Set up Concourse pipeline for BATs"
+set priority to 12 for "P12: Bike Shedding Feature"
+set priority to 13 for "P13: (3) Set up Concourse pipeline for os image building"
+EOT
+ expect {
+ @cli.set_priorities
+ }.to output(expected_output).to_stdout
+ end
+
+ it "sets priorities for specified planning list", vcr: "prioritize_backlog_list", vcr_record: false do
+ @cli.options = {"board-id" => "neUHHzDo", "backlog-list-name" => "Nonexisting List"}
+
+ expect {
+ @cli.set_priorities
+ }.to raise_error /'Nonexisting List' not found/
+ end
+
+ context "#board_id" do
+ before do
+ Cli.settings = Settings.new(
+ File.expand_path('../../data/trollolorc_with_board_aliases', __FILE__))
+ @cli = Cli.new
+ end
+
+ it "returns the id when no alias exists" do
+ expect(@cli.send(:board_id, "1234")).to eq("1234")
+ end
+
+ it "return the id when an alias exists" do
+ expect(@cli.send(:board_id, "MyTrelloBoard")).to eq("53186e8391ef8671265eba9d")
+ end
end
end