crab 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -159,7 +159,6 @@ To do / Roadmap
159
159
 
160
160
  ### Later / before 1.0.0
161
161
 
162
- - Dry-run mode
163
162
  - Encrypt password in generated `~/.crab/credentials`
164
163
  - Add a Cucumber Formatter that updates Test Runs in Rally with results from CI
165
164
  - Test in Ruby 1.9
data/bin/crab-add CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab create: create a new story in Rally
7
7
 
8
8
  Usage: crab create name [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  name = ARGV.join(" ")
13
14
  Trollop::die "Please specify a name for the story" if name.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.create_story :name => name
17
18
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
18
19
  end
data/bin/crab-change CHANGED
@@ -17,6 +17,7 @@ Usage: crab update story [options]
17
17
  opt :blocked, "Blocked", :short => "-b"
18
18
  opt :unblocked, "Unblocked", :short => "-u"
19
19
  opt :parent, "Parent", :type => String, :short => "-p"
20
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
20
21
  end
21
22
 
22
23
  Trollop::die "No story given" if ARGV.empty?
@@ -33,7 +34,7 @@ end
33
34
  opts[:blocked] = cmd_opts[:blocked] if cmd_opts[:blocked_given]
34
35
  opts[:blocked] = !cmd_opts[:unblocked] if cmd_opts[:unblocked_given]
35
36
 
36
- Crab::Rally.new do |rally|
37
+ Crab::Rally.new(opts[:dry]) do |rally|
37
38
  rally.connect
38
39
 
39
40
  story = rally.find_story_with_id ARGV.first
data/bin/crab-create CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab create: create a new story in Rally
7
7
 
8
8
  Usage: crab create name [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  name = ARGV.join(" ")
13
14
  Trollop::die "Please specify a name for the story" if name.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.create_story :name => name
17
18
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
18
19
  end
data/bin/crab-del CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab delete: delete an existing story in Rally
7
7
 
8
8
  Usage: crab delete story [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  id = ARGV.join(" ")
13
14
  Trollop::die "Story ID must be specified" if story_id.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.find_story_with_id id
17
18
  story.delete
18
19
 
data/bin/crab-delete CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab delete: delete an existing story in Rally
7
7
 
8
8
  Usage: crab delete story [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  id = ARGV.join(" ")
13
14
  Trollop::die "Story ID must be specified" if story_id.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.find_story_with_id id
17
18
  story.delete
18
19
 
data/bin/crab-find CHANGED
@@ -3,21 +3,22 @@ require 'crab'
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- cmd_opts = Trollop::options do
6
+ opts = Trollop::options do
7
7
  banner <<-BANNER
8
8
  crab find: find a story in Rally
9
9
 
10
10
  Usage: crab find [options] [text]
11
11
  BANNER
12
12
  opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
14
  end
14
15
 
15
16
  pattern = ARGV.map(&:strip).reject(&:empty?)
16
- project_name = valid_project_name(cmd_opts)
17
+ project_name = valid_project_name(opts)
17
18
 
18
- Crab::Rally.new do |rally|
19
+ Crab::Rally.new(opts[:dry]) do |rally|
19
20
  project = rally.find_project(project_name)
20
- Trollop::die "Project #{cmd_opts[:project].inspect} not found" if project.nil?
21
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
21
22
 
22
23
  rally.find_stories(project, pattern).each do |story|
23
24
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
data/bin/crab-help CHANGED
@@ -17,7 +17,6 @@ crab version #{Crab::VERSION}: A Cucumber-Rally bridge
17
17
  pull Downloads stories (and its test cases) as Cucumber feature files
18
18
  show Show a story (and its test cases) as a Cucumber feature
19
19
  testcase Manage test cases in a story (add, update, delete)
20
- truncate Make sphor happy!
21
20
  update Update a story (name, estimate, etc)
22
21
 
23
22
 
data/bin/crab-list CHANGED
@@ -3,21 +3,22 @@ require 'crab'
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- cmd_opts = Trollop::options do
6
+ opts = Trollop::options do
7
7
  banner <<-BANNER
8
8
  crab find: find a story in Rally
9
9
 
10
10
  Usage: crab find [options] [text]
11
11
  BANNER
12
12
  opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
14
  end
14
15
 
15
16
  pattern = ARGV.map(&:strip).reject(&:empty?)
16
- project_name = valid_project_name(cmd_opts)
17
+ project_name = valid_project_name(opts)
17
18
 
18
- Crab::Rally.new do |rally|
19
+ Crab::Rally.new(opts[:dry]) do |rally|
19
20
  project = rally.find_project(project_name)
20
- Trollop::die "Project #{cmd_opts[:project].inspect} not found" if project.nil?
21
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
21
22
 
22
23
  rally.find_stories(project, pattern).each do |story|
23
24
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
data/bin/crab-ls CHANGED
@@ -3,21 +3,22 @@ require 'crab'
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- cmd_opts = Trollop::options do
6
+ opts = Trollop::options do
7
7
  banner <<-BANNER
8
8
  crab find: find a story in Rally
9
9
 
10
10
  Usage: crab find [options] [text]
11
11
  BANNER
12
12
  opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
14
  end
14
15
 
15
16
  pattern = ARGV.map(&:strip).reject(&:empty?)
16
- project_name = valid_project_name(cmd_opts)
17
+ project_name = valid_project_name(opts)
17
18
 
18
- Crab::Rally.new do |rally|
19
+ Crab::Rally.new(opts[:dry]) do |rally|
19
20
  project = rally.find_project(project_name)
20
- Trollop::die "Project #{cmd_opts[:project].inspect} not found" if project.nil?
21
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
21
22
 
22
23
  rally.find_stories(project, pattern).each do |story|
23
24
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
data/bin/crab-move CHANGED
@@ -3,23 +3,24 @@ require 'crab'
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- cmd_opts = Trollop::options do
6
+ opts = Trollop::options do
7
7
  banner <<-BANNER
8
8
  crab move: move a story from one status to the next (or previous)
9
9
 
10
10
  Usage: crab move story [options]
11
11
  BANNER
12
12
  opt :back, "Move story backwards (from accepted to completed, for example)"
13
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
14
  end
14
15
 
15
16
  id = ARGV.join(" ")
16
17
  Trollop::die "No story given" if id.empty?
17
18
 
18
- Crab::Rally.new do |rally|
19
+ Crab::Rally.new(opts[:dry]) do |rally|
19
20
  story = rally.find_story_with_id id
20
21
  state = state_from(story.state)
21
22
 
22
- story.update :schedule_state => (cmd_opts[:back] ? state_before(state) : state_after(state))
23
+ story.update :schedule_state => (opts[:back] ? state_before(state) : state_after(state))
23
24
 
24
25
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
25
26
  end
data/bin/crab-mv CHANGED
@@ -3,23 +3,24 @@ require 'crab'
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- cmd_opts = Trollop::options do
6
+ opts = Trollop::options do
7
7
  banner <<-BANNER
8
8
  crab move: move a story from one status to the next (or previous)
9
9
 
10
10
  Usage: crab move story [options]
11
11
  BANNER
12
12
  opt :back, "Move story backwards (from accepted to completed, for example)"
13
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
14
  end
14
15
 
15
16
  id = ARGV.join(" ")
16
17
  Trollop::die "No story given" if id.empty?
17
18
 
18
- Crab::Rally.new do |rally|
19
+ Crab::Rally.new(opts[:dry]) do |rally|
19
20
  story = rally.find_story_with_id id
20
21
  state = state_from(story.state)
21
22
 
22
- story.update :schedule_state => (cmd_opts[:back] ? state_before(state) : state_after(state))
23
+ story.update :schedule_state => (opts[:back] ? state_before(state) : state_after(state))
23
24
 
24
25
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
25
26
  end
data/bin/crab-new CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab create: create a new story in Rally
7
7
 
8
8
  Usage: crab create name [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  name = ARGV.join(" ")
13
14
  Trollop::die "Please specify a name for the story" if name.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.create_story :name => name
17
18
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
18
19
  end
data/bin/crab-project CHANGED
@@ -3,12 +3,13 @@ require 'crab'
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- cmd_opts = Trollop::options do
6
+ opts = Trollop::options do
7
7
  banner <<-BANNER
8
8
  crab project: show or persistently select project to work with in Rally
9
9
 
10
10
  Usage: crab project [name]
11
11
  BANNER
12
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
12
13
  end
13
14
 
14
15
  current_project_name = self.class.current_project_name
@@ -23,12 +24,19 @@ end
23
24
 
24
25
  name = ARGV.join(" ").strip
25
26
 
26
- Crab::Rally.new do |rally|
27
+ Crab::Rally.new(opts[:dry]) do |rally|
27
28
  project = rally.find_project name
28
29
  Trollop::die "#{name.inspect} is not a valid project" if project.nil?
29
30
 
30
- FileUtils.mkdir_p ".crab"
31
- File.open(".crab/project", "w") do |file|
32
- file.puts project.name
31
+ FileUtils.mkdir_p ".crab", opts[:dry] ? { :noop => true, :verbose => true } : {}
32
+ file = ".crab/project"
33
+ output = project.name
34
+
35
+ if opts[:dry]
36
+ puts "Would write to #{file}:\n\n#{output}"
37
+ else
38
+ File.open(file, "w") do |file|
39
+ file.puts project.name
40
+ end
33
41
  end
34
42
  end
data/bin/crab-pull CHANGED
@@ -1,16 +1,17 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab pull: pulls stories from Rally and writes them out as Cucumber features
7
7
 
8
8
  Usage: crab pull [options] story1 [story2 ...]
9
9
  BANNER
10
10
  opt :language, "Language to generate Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
11
12
  end
12
13
 
13
- Crab::Rally.new do |rally|
14
+ Crab::Rally.new(opts[:dry]) do |rally|
14
15
 
15
16
  ARGV.each do |story_number|
16
17
  story = rally.find_story_with_id story_number
@@ -18,12 +19,19 @@ Crab::Rally.new do |rally|
18
19
 
19
20
  puts "#{story.formatted_id}: #{story.full_file_name}"
20
21
 
21
- FileUtils.mkdir_p File.dirname(story.full_file_name)
22
- FileUtils.touch story.full_file_name
22
+ fileutils_opts = opts[:dry] ? { :noop => true, :verbose => true } : {}
23
23
 
24
- File.open(story.full_file_name, "w") do |file|
25
- file.write Crab::CucumberFeature.new(cmd_opts[:language]).generate_from story
24
+ FileUtils.mkdir_p File.dirname(story.full_file_name), fileutils_opts
25
+ FileUtils.touch story.full_file_name, fileutils_opts
26
+
27
+ output = Crab::CucumberFeature.new(opts[:language]).generate_from story
28
+
29
+ if opts[:dry]
30
+ puts "Would write to #{story.full_file_name}:\n\n#{output}"
31
+ else
32
+ File.open(story.full_file_name, "w") do |file|
33
+ file.write output
34
+ end
26
35
  end
27
36
  end
28
-
29
37
  end
data/bin/crab-remove CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab delete: delete an existing story in Rally
7
7
 
8
8
  Usage: crab delete story [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  id = ARGV.join(" ")
13
14
  Trollop::die "Story ID must be specified" if story_id.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.find_story_with_id id
17
18
  story.delete
18
19
 
data/bin/crab-rm CHANGED
@@ -1,18 +1,19 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'crab'
3
3
 
4
- cmd_opts = Trollop::options do
4
+ opts = Trollop::options do
5
5
  banner <<-BANNER
6
6
  crab delete: delete an existing story in Rally
7
7
 
8
8
  Usage: crab delete story [options]
9
9
  BANNER
10
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
10
11
  end
11
12
 
12
13
  id = ARGV.join(" ")
13
14
  Trollop::die "Story ID must be specified" if story_id.blank?
14
15
 
15
- Crab::Rally.new do |rally|
16
+ Crab::Rally.new(opts[:dry]) do |rally|
16
17
  story = rally.find_story_with_id id
17
18
  story.delete
18
19
 
data/bin/crab-show CHANGED
@@ -8,10 +8,11 @@ crab show: displays a story in Rally as a Cucumber feature
8
8
  Usage: crab show story"
9
9
  BANNER
10
10
  opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
11
12
  end
12
13
 
13
14
  id = ARGV.first
14
- Crab::Rally.new do |rally|
15
+ Crab::Rally.new(opts[:dry]) do |rally|
15
16
  story = rally.find_story_with_id(id)
16
17
 
17
18
  puts Crab::CucumberFeature.new(opts[:language]).generate_from story
@@ -19,7 +19,7 @@ unless name
19
19
  exit 1
20
20
  end
21
21
 
22
- Crab::Rally.new do |rally|
22
+ Crab::Rally.new(opts[:dry]) do |rally|
23
23
  tc = rally.create_test_case(story_id, name, sanitize_options(opts))
24
24
  puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
25
25
  end
@@ -19,7 +19,7 @@ unless name
19
19
  exit 1
20
20
  end
21
21
 
22
- Crab::Rally.new do |rally|
22
+ Crab::Rally.new(opts[:dry]) do |rally|
23
23
  tc = rally.create_test_case(story_id, name, sanitize_options(opts))
24
24
  puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
25
25
  end
@@ -3,10 +3,11 @@ require 'crab'
3
3
 
4
4
  Trollop::options do
5
5
  banner "crab testcase delete: delete a test case in Rally"
6
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
6
7
  end
7
8
 
8
9
  tc_id = ARGV.shift
9
- Crab::Rally.new do |rally|
10
+ Crab::Rally.new(opts[:dry]) do |rally|
10
11
  tc = rally.find_test_case(tc_id)
11
12
  tc.delete
12
13
  puts "Test case #{tc_id} deleted."
@@ -8,6 +8,7 @@ crab testcase list: displays all testcases in Rally in a story as Cucumber scena
8
8
  Usage: crab testcase list <story> [options]"
9
9
  BANNER
10
10
  opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
11
12
  end
12
13
 
13
14
  id = ARGV.shift
@@ -17,7 +18,7 @@ unless id
17
18
  exit 1
18
19
  end
19
20
 
20
- Crab::Rally.new do |rally|
21
+ Crab::Rally.new(opts[:dry]) do |rally|
21
22
  story = rally.find_story_with_id id
22
23
 
23
24
  puts Array(story.scenarios).map {|scenario| Crab::CucumberScenario.new(opts[:language]).generate_from scenario }.join.strip
data/bin/crab-testcase-ls CHANGED
@@ -8,6 +8,7 @@ crab testcase list: displays all testcases in Rally in a story as Cucumber scena
8
8
  Usage: crab testcase list <story> [options]"
9
9
  BANNER
10
10
  opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
11
12
  end
12
13
 
13
14
  id = ARGV.shift
@@ -17,7 +18,7 @@ unless id
17
18
  exit 1
18
19
  end
19
20
 
20
- Crab::Rally.new do |rally|
21
+ Crab::Rally.new(opts[:dry]) do |rally|
21
22
  story = rally.find_story_with_id id
22
23
 
23
24
  puts Array(story.scenarios).map {|scenario| Crab::CucumberScenario.new(opts[:language]).generate_from scenario }.join.strip
@@ -19,7 +19,7 @@ unless name
19
19
  exit 1
20
20
  end
21
21
 
22
- Crab::Rally.new do |rally|
22
+ Crab::Rally.new(opts[:dry]) do |rally|
23
23
  tc = rally.create_test_case(story_id, name, sanitize_options(opts))
24
24
  puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
25
25
  end
data/bin/crab-testcase-rm CHANGED
@@ -3,10 +3,11 @@ require 'crab'
3
3
 
4
4
  Trollop::options do
5
5
  banner "crab testcase delete: delete a test case in Rally"
6
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
6
7
  end
7
8
 
8
9
  tc_id = ARGV.shift
9
- Crab::Rally.new do |rally|
10
+ Crab::Rally.new(opts[:dry]) do |rally|
10
11
  tc = rally.find_test_case(tc_id)
11
12
  tc.delete
12
13
  puts "Test case #{tc_id} deleted."
@@ -8,6 +8,7 @@ crab testcase show: displays a testcase in Rally as a Cucumber scenario
8
8
  Usage: crab testcase show <testcase> [options]"
9
9
  BANNER
10
10
  opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
11
12
  end
12
13
 
13
14
  id = ARGV.shift
@@ -17,7 +18,7 @@ unless id
17
18
  exit 1
18
19
  end
19
20
 
20
- Crab::Rally.new do |rally|
21
+ Crab::Rally.new(opts[:dry]) do |rally|
21
22
  tc = rally.find_test_case id
22
23
  puts Crab::CucumberScenario.new(opts[:language]).generate_from(tc).strip
23
24
  end
@@ -7,7 +7,7 @@ opts = add_or_update_options "crab testcase update: update a test case in Rally"
7
7
 
8
8
  tc_id = ARGV.shift
9
9
 
10
- Crab::Rally.new do |rally|
10
+ Crab::Rally.new(opts[:dry]) do |rally|
11
11
  tc = rally.find_test_case(tc_id)
12
12
  tc.update(sanitize_options(opts))
13
13
  puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
data/bin/crab-truncate CHANGED
@@ -1,8 +1,3 @@
1
1
  # vim: set ft=ruby :
2
- require 'crab'
3
-
4
- Trollop::options do
5
- banner "crab truncate: Make spohr happy!"
6
- end
7
2
 
8
3
  puts "You have been truncated! Now back to work!"
data/bin/crab-up CHANGED
@@ -17,6 +17,7 @@ Usage: crab update story [options]
17
17
  opt :blocked, "Blocked", :short => "-b"
18
18
  opt :unblocked, "Unblocked", :short => "-u"
19
19
  opt :parent, "Parent", :type => String, :short => "-p"
20
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
20
21
  end
21
22
 
22
23
  Trollop::die "No story given" if ARGV.empty?
@@ -33,7 +34,7 @@ end
33
34
  opts[:blocked] = cmd_opts[:blocked] if cmd_opts[:blocked_given]
34
35
  opts[:blocked] = !cmd_opts[:unblocked] if cmd_opts[:unblocked_given]
35
36
 
36
- Crab::Rally.new do |rally|
37
+ Crab::Rally.new(opts[:dry]) do |rally|
37
38
  rally.connect
38
39
 
39
40
  story = rally.find_story_with_id ARGV.first
data/bin/crab-update CHANGED
@@ -17,6 +17,7 @@ Usage: crab update story [options]
17
17
  opt :blocked, "Blocked", :short => "-b"
18
18
  opt :unblocked, "Unblocked", :short => "-u"
19
19
  opt :parent, "Parent", :type => String, :short => "-p"
20
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
20
21
  end
21
22
 
22
23
  Trollop::die "No story given" if ARGV.empty?
@@ -33,7 +34,7 @@ end
33
34
  opts[:blocked] = cmd_opts[:blocked] if cmd_opts[:blocked_given]
34
35
  opts[:blocked] = !cmd_opts[:unblocked] if cmd_opts[:unblocked_given]
35
36
 
36
- Crab::Rally.new do |rally|
37
+ Crab::Rally.new(opts[:dry]) do |rally|
37
38
  rally.connect
38
39
 
39
40
  story = rally.find_story_with_id ARGV.first
@@ -17,7 +17,6 @@ crab version #{Crab::VERSION}: A Cucumber-Rally bridge
17
17
  pull Downloads stories (and its test cases) as Cucumber feature files
18
18
  show Show a story (and its test cases) as a Cucumber feature
19
19
  testcase Manage test cases in a story (add, update, delete)
20
- truncate Make sphor happy!
21
20
  update Update a story (name, estimate, etc)
22
21
 
23
22
 
data/lib/crab/rally.rb CHANGED
@@ -3,7 +3,9 @@ module Crab
3
3
 
4
4
  include Crab::Utilities
5
5
 
6
- def initialize
6
+ def initialize(dry_run)
7
+ @dry_run = dry_run
8
+
7
9
  if block_given?
8
10
  connect
9
11
  yield self
@@ -20,25 +22,30 @@ module Crab
20
22
  end
21
23
 
22
24
  def find_story_with_id story_id
23
- Crab::Story.new @rally.find(:hierarchical_requirement) { equal :formatted_i_d, story_id }.first
25
+ story = @rally.find(:hierarchical_requirement) { equal :formatted_i_d, story_id }.first
26
+ Crab::Story.new(story, @dry_run)
24
27
  end
25
28
 
26
29
  def find_all_stories(opts={})
27
- @rally.find_all(:hierarchical_requirement, {:fetch => true}.merge(opts)).map {|s| Crab::Story.new s }
30
+ @rally.find_all(:hierarchical_requirement, {:fetch => true}.merge(opts)).map do |story|
31
+ Crab::Story.new(story, @dry_run)
32
+ end
28
33
  end
29
34
 
30
35
  def find_stories(project, pattern=[])
31
36
  return find_all_stories :project => project if pattern.empty?
32
37
 
33
- @rally.find(:hierarchical_requirement, :fetch => true, :project => project) {
38
+ rally_stories = @rally.find(:hierarchical_requirement, :fetch => true, :project => project) do
34
39
  pattern.each do |word|
35
- _or_ {
40
+ _or_ do
36
41
  contains :name, word
37
42
  contains :description, word
38
43
  contains :notes, word
39
- }
44
+ end
40
45
  end
41
- }.map {|s| Crab::Story.new s }
46
+ end
47
+
48
+ rally_stories.map {|story| Crab::Story.new(story, @dry_run) }
42
49
  end
43
50
 
44
51
  def find_project(name)
@@ -54,16 +61,27 @@ module Crab
54
61
  end
55
62
 
56
63
  def create_story(opts)
57
- Crab::Story.new @rally.create(:hierarchical_requirement, opts)
64
+ if @dry_run
65
+ Crab::DryRun::Story.new opts
66
+ else
67
+ Crab::Story.new(@rally.create(:hierarchical_requirement, opts), @dry_run)
68
+ end
58
69
  end
59
70
 
60
71
  def create_test_case(story_id, name, opts)
61
72
  story = find_story_with_id story_id
62
- Crab::TestCase.new @rally.create(:test_case, {:name => name, :work_product => story.rally_object, :project => story.rally_object.project}.merge(opts))
73
+ opts = {:name => name, :work_product => story.rally_object, :project => story.rally_object.project}.merge(opts)
74
+
75
+ if @dry_run
76
+ puts "Would create test case for story with ID #{story_id} with #{opts.inspect}"
77
+ else
78
+ tc = @rally.create(:test_case, opts)
79
+ Crab::TestCase.new(tc, @dry_run)
80
+ end
63
81
  end
64
82
 
65
83
  def find_test_case(tc_id)
66
- Crab::TestCase.new @rally.find(:test_case) { equal :formatted_i_d, tc_id }.first
84
+ Crab::TestCase.new(@rally.find(:test_case) { equal :formatted_i_d, tc_id }.first, @dry_run)
67
85
  end
68
86
 
69
87
  end
data/lib/crab/story.rb CHANGED
@@ -4,8 +4,9 @@ module Crab
4
4
 
5
5
  VALID_STATES = %w{Grooming Defined In-Progress Completed Accepted Released}
6
6
 
7
- def initialize(rally_story)
7
+ def initialize(rally_story, dry_run)
8
8
  @rally_story = rally_story
9
+ @dry_run = dry_run
9
10
  end
10
11
 
11
12
  def name
@@ -37,15 +38,23 @@ module Crab
37
38
  end
38
39
 
39
40
  def scenarios
40
- Array(@rally_story.test_cases).map {|tc| Crab::TestCase.new tc }
41
+ Array(@rally_story.test_cases).map {|tc| Crab::TestCase.new(tc, @dry_run) }
41
42
  end
42
43
 
43
44
  def update(opts)
44
- @rally_story.update opts
45
+ if @dry_run
46
+ puts "Would update story #{formatted_id} with #{opts.inspect}"
47
+ else
48
+ @rally_story.update opts
49
+ end
45
50
  end
46
51
 
47
52
  def delete
48
- @rally_story.delete
53
+ if @dry_run
54
+ puts "Would delete story #{formatted_id}"
55
+ else
56
+ @rally_story.delete
57
+ end
49
58
  end
50
59
 
51
60
  def rally_object
@@ -62,4 +71,35 @@ module Crab
62
71
 
63
72
  end
64
73
 
74
+ module DryRun
75
+ class Story
76
+ def initialize(opts)
77
+ puts "Would create story with #{opts.inspect}"
78
+
79
+ @name = opts[:name]
80
+ end
81
+
82
+ def name
83
+ @name
84
+ end
85
+
86
+ def formatted_id
87
+ "USXXXX"
88
+ end
89
+
90
+ def state
91
+ "grooming"
92
+ end
93
+
94
+ def description
95
+ ""
96
+ end
97
+
98
+ def scenarios
99
+ []
100
+ end
101
+
102
+ end
103
+ end
65
104
  end
105
+
data/lib/crab/testcase.rb CHANGED
@@ -7,8 +7,9 @@ module Crab
7
7
  METHODS = %w{automated manual}
8
8
  TYPES = %w{acceptance functional non-functional performance regression usability}
9
9
 
10
- def initialize(rally_test_case)
10
+ def initialize(rally_test_case, dry_run)
11
11
  @rally_test_case = rally_test_case
12
+ @dry_run
12
13
  end
13
14
 
14
15
  def formatted_id
@@ -40,15 +41,23 @@ module Crab
40
41
  end
41
42
 
42
43
  def story
43
- Crab::Story.new @rally_test_case.work_product
44
+ Crab::Story.new(@rally_test_case.work_product, @dry_run)
44
45
  end
45
46
 
46
47
  def delete
47
- @rally_test_case.delete
48
+ if @dry_run
49
+ puts "Would delete test case #{formatted_id}"
50
+ else
51
+ @rally_test_case.delete
52
+ end
48
53
  end
49
54
 
50
55
  def update(options)
51
- @rally_test_case.update options
56
+ if @dry_run
57
+ puts "Would update test case #{formatted_id} with #{options.inspect}"
58
+ else
59
+ @rally_test_case.update options
60
+ end
52
61
  end
53
62
 
54
63
  def steps
@@ -51,6 +51,8 @@ module Crab
51
51
  opt :pre, "Pre-conditions", :default => "N/A"
52
52
  opt :post, "Post-conditions", :default => "N/A"
53
53
  opt :desc, "Description", :default => "N/A", :short => '-d'
54
+
55
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
54
56
  end
55
57
  end
56
58
 
data/lib/crab/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Crab
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crab
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carlos Villela