crab 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/crab-list ADDED
@@ -0,0 +1,25 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ include Crab::Utilities
5
+
6
+ cmd_opts = Trollop::options do
7
+ banner <<-BANNER
8
+ crab find: find a story in Rally
9
+
10
+ Usage: crab find [options] [text]
11
+ BANNER
12
+ opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ end
14
+
15
+ pattern = ARGV.map(&:strip).reject(&:empty?)
16
+ project_name = valid_project_name(cmd_opts)
17
+
18
+ Crab::Rally.new do |rally|
19
+ project = rally.find_project(project_name)
20
+ Trollop::die "Project #{cmd_opts[:project].inspect} not found" if project.nil?
21
+
22
+ rally.find_stories(project, pattern).each do |story|
23
+ puts "#{story.formatted_id}: #{story.name} (#{story.state})"
24
+ end
25
+ end
data/bin/crab-ls ADDED
@@ -0,0 +1,25 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ include Crab::Utilities
5
+
6
+ cmd_opts = Trollop::options do
7
+ banner <<-BANNER
8
+ crab find: find a story in Rally
9
+
10
+ Usage: crab find [options] [text]
11
+ BANNER
12
+ opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ end
14
+
15
+ pattern = ARGV.map(&:strip).reject(&:empty?)
16
+ project_name = valid_project_name(cmd_opts)
17
+
18
+ Crab::Rally.new do |rally|
19
+ project = rally.find_project(project_name)
20
+ Trollop::die "Project #{cmd_opts[:project].inspect} not found" if project.nil?
21
+
22
+ rally.find_stories(project, pattern).each do |story|
23
+ puts "#{story.formatted_id}: #{story.name} (#{story.state})"
24
+ end
25
+ end
data/bin/crab-new ADDED
@@ -0,0 +1,18 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ cmd_opts = Trollop::options do
5
+ banner <<-BANNER
6
+ crab create: create a new story in Rally
7
+
8
+ Usage: crab create name [options]
9
+ BANNER
10
+ end
11
+
12
+ name = ARGV.join(" ")
13
+ Trollop::die "Please specify a name for the story" if name.blank?
14
+
15
+ Crab::Rally.new do |rally|
16
+ story = rally.create_story :name => name
17
+ puts "#{story.formatted_id}: #{story.name} (#{story.state})"
18
+ end
data/bin/crab-tc CHANGED
@@ -1,78 +1,18 @@
1
- # vim: set ft=ruby :
2
- require 'crab'
1
+ #!/usr/bin/env ruby
2
+ # vim: set ft=ruby:
3
3
 
4
- def add_or_update_options(banner)
5
- Trollop::options do
6
- banner banner
7
- opt :priority, "Priority (one of: #{Crab::TestCase::PRIORITIES.join(" ")}", :default => "important", :short => '-p'
8
- opt :risk, "Risk (one of: #{Crab::TestCase::RISKS.join(" ")})", :default => "medium", :short => '-r'
9
- opt :method, "Method (one of: #{Crab::TestCase::METHODS.join(" ")})", :default => "automated", :short => '-m'
10
- opt :type, "Type (one of: #{Crab::TestCase::TYPES.join(" ")})", :default => "acceptance", :short => '-t'
11
- opt :pre, "Pre-conditions", :default => "N/A"
12
- opt :post, "Post-conditions", :default => "N/A"
13
- opt :desc, "Description", :default => "N/A", :short => '-d'
14
- end
15
- end
16
-
17
- def sanitize_options(opts, creating=true)
18
- result = {}
19
- result[:priority] = opts[:priority].capitalize if creating || opts[:priority_given]
20
- result[:risk] = opts[:risk].capitalize if creating || opts[:risk_given]
21
- result[:method] = opts[:method].capitalize if creating || opts[:method_given]
22
- result[:type] = opts[:type].capitalize if creating || opts[:type_given]
23
- result[:pre_conditions] = opts[:pre] if creating || opts[:pre_given]
24
- result[:post_conditions] = opts[:post] if creating || opts[:post_given]
25
- result[:description] = opts[:desc] if creating || opts[:desc_given]
26
- result
27
- end
4
+ cmd = ARGV.shift # get the subcommand
28
5
 
29
- Trollop::options do
30
- banner <<-BANNER
31
- crab testcase: manage test cases in a story (add, update, delete)
32
-
33
- Usage: crab testcase add story name [options]
34
- crab testcase update testcase [options]
35
- crab testcase delete testcase [options]
36
- BANNER
37
- stop_on %w{add update delete}
6
+ case cmd
7
+ when "-h", "--help", NilClass
8
+ system "crab-testcase-help"
9
+ exit 0
38
10
  end
39
11
 
40
- sub = ARGV.shift
41
- case sub
42
- when "add"
43
- opts = add_or_update_options "crab testcase add: add a test case to a story in Rally"
44
-
45
- story_id = ARGV.shift
46
- name = ARGV.join(" ")
47
-
48
- Crab::Rally.new do |rally|
49
- tc = rally.create_test_case(story_id, name, sanitize_options(opts))
50
- puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
51
- end
52
-
53
- when "update"
54
- opts = add_or_update_options "crab testcase update: update a test case in Rally"
55
-
56
- tc_id = ARGV.shift
57
-
58
- Crab::Rally.new do |rally|
59
- tc = rally.find_test_case(tc_id)
60
- tc.update(sanitize_options(opts))
61
- puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
62
- end
63
-
64
- when "delete"
65
- Trollop::options do
66
- banner "crab testcase delete: delete a test case in Rally"
67
- end
68
-
69
- tc_id = ARGV.shift
70
- Crab::Rally.new do |rally|
71
- tc = rally.find_test_case(tc_id)
72
- tc.delete
73
- puts "Test case #{tc_id} deleted."
12
+ unless system("crab-testcase-#{cmd}", *ARGV)
13
+ if $?.exitstatus == 127 # bash 'command not found'
14
+ $stderr.puts "Unknown subcommand \"template #{cmd}\""
15
+ system "crab-testcase-help"
16
+ exit 127
74
17
  end
75
-
76
- else
77
- Trollop::die "Unknown subcommand#{' ' + sub.inspect if sub}"
78
18
  end
data/bin/crab-testcase CHANGED
@@ -1,78 +1,18 @@
1
- # vim: set ft=ruby :
2
- require 'crab'
1
+ #!/usr/bin/env ruby
2
+ # vim: set ft=ruby:
3
3
 
4
- def add_or_update_options(banner)
5
- Trollop::options do
6
- banner banner
7
- opt :priority, "Priority (one of: #{Crab::TestCase::PRIORITIES.join(" ")}", :default => "important", :short => '-p'
8
- opt :risk, "Risk (one of: #{Crab::TestCase::RISKS.join(" ")})", :default => "medium", :short => '-r'
9
- opt :method, "Method (one of: #{Crab::TestCase::METHODS.join(" ")})", :default => "automated", :short => '-m'
10
- opt :type, "Type (one of: #{Crab::TestCase::TYPES.join(" ")})", :default => "acceptance", :short => '-t'
11
- opt :pre, "Pre-conditions", :default => "N/A"
12
- opt :post, "Post-conditions", :default => "N/A"
13
- opt :desc, "Description", :default => "N/A", :short => '-d'
14
- end
15
- end
16
-
17
- def sanitize_options(opts, creating=true)
18
- result = {}
19
- result[:priority] = opts[:priority].capitalize if creating || opts[:priority_given]
20
- result[:risk] = opts[:risk].capitalize if creating || opts[:risk_given]
21
- result[:method] = opts[:method].capitalize if creating || opts[:method_given]
22
- result[:type] = opts[:type].capitalize if creating || opts[:type_given]
23
- result[:pre_conditions] = opts[:pre] if creating || opts[:pre_given]
24
- result[:post_conditions] = opts[:post] if creating || opts[:post_given]
25
- result[:description] = opts[:desc] if creating || opts[:desc_given]
26
- result
27
- end
4
+ cmd = ARGV.shift # get the subcommand
28
5
 
29
- Trollop::options do
30
- banner <<-BANNER
31
- crab testcase: manage test cases in a story (add, update, delete)
32
-
33
- Usage: crab testcase add story name [options]
34
- crab testcase update testcase [options]
35
- crab testcase delete testcase [options]
36
- BANNER
37
- stop_on %w{add update delete}
6
+ case cmd
7
+ when "-h", "--help", NilClass
8
+ system "crab-testcase-help"
9
+ exit 0
38
10
  end
39
11
 
40
- sub = ARGV.shift
41
- case sub
42
- when "add"
43
- opts = add_or_update_options "crab testcase add: add a test case to a story in Rally"
44
-
45
- story_id = ARGV.shift
46
- name = ARGV.join(" ")
47
-
48
- Crab::Rally.new do |rally|
49
- tc = rally.create_test_case(story_id, name, sanitize_options(opts))
50
- puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
51
- end
52
-
53
- when "update"
54
- opts = add_or_update_options "crab testcase update: update a test case in Rally"
55
-
56
- tc_id = ARGV.shift
57
-
58
- Crab::Rally.new do |rally|
59
- tc = rally.find_test_case(tc_id)
60
- tc.update(sanitize_options(opts))
61
- puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
62
- end
63
-
64
- when "delete"
65
- Trollop::options do
66
- banner "crab testcase delete: delete a test case in Rally"
67
- end
68
-
69
- tc_id = ARGV.shift
70
- Crab::Rally.new do |rally|
71
- tc = rally.find_test_case(tc_id)
72
- tc.delete
73
- puts "Test case #{tc_id} deleted."
12
+ unless system("crab-testcase-#{cmd}", *ARGV)
13
+ if $?.exitstatus == 127 # bash 'command not found'
14
+ $stderr.puts "Unknown subcommand \"template #{cmd}\""
15
+ system "crab-testcase-help"
16
+ exit 127
74
17
  end
75
-
76
- else
77
- Trollop::die "Unknown subcommand#{' ' + sub.inspect if sub}"
78
18
  end
@@ -0,0 +1,25 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ include Crab::Utilities
5
+
6
+ opts = add_or_update_options "crab testcase add: add a test case to a story in Rally"
7
+
8
+ story_id = ARGV.shift
9
+ unless story_id
10
+ $stderr.puts "Error: Story ID not provided."
11
+ system "crab-testcase-help"
12
+ exit 1
13
+ end
14
+
15
+ name = ARGV.join(" ")
16
+ unless name
17
+ $stderr.puts "Error: Test case name not provided."
18
+ system "crab-testcase-help"
19
+ exit 1
20
+ end
21
+
22
+ Crab::Rally.new do |rally|
23
+ tc = rally.create_test_case(story_id, name, sanitize_options(opts))
24
+ puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
25
+ end
@@ -0,0 +1,25 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ include Crab::Utilities
5
+
6
+ opts = add_or_update_options "crab testcase add: add a test case to a story in Rally"
7
+
8
+ story_id = ARGV.shift
9
+ unless story_id
10
+ $stderr.puts "Error: Story ID not provided."
11
+ system "crab-testcase-help"
12
+ exit 1
13
+ end
14
+
15
+ name = ARGV.join(" ")
16
+ unless name
17
+ $stderr.puts "Error: Test case name not provided."
18
+ system "crab-testcase-help"
19
+ exit 1
20
+ end
21
+
22
+ Crab::Rally.new do |rally|
23
+ tc = rally.create_test_case(story_id, name, sanitize_options(opts))
24
+ puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
25
+ end
@@ -0,0 +1,13 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ Trollop::options do
5
+ banner "crab testcase delete: delete a test case in Rally"
6
+ end
7
+
8
+ tc_id = ARGV.shift
9
+ Crab::Rally.new do |rally|
10
+ tc = rally.find_test_case(tc_id)
11
+ tc.delete
12
+ puts "Test case #{tc_id} deleted."
13
+ end
@@ -0,0 +1,10 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ puts <<-HELP
5
+ crab testcase: manage test cases in a story (add, update, delete)
6
+
7
+ Usage: crab testcase add story name [options]
8
+ crab testcase update testcase [options]
9
+ crab testcase delete testcase [options]
10
+ HELP
@@ -0,0 +1,24 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ opts = Trollop::options do
5
+ banner <<-BANNER
6
+ crab testcase list: displays all testcases in Rally in a story as Cucumber scenarios
7
+
8
+ Usage: crab testcase list <story> [options]"
9
+ BANNER
10
+ opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ end
12
+
13
+ id = ARGV.shift
14
+ unless id
15
+ $stderr.puts "Error: No story ID provided."
16
+ system "crab-testcase-help"
17
+ exit 1
18
+ end
19
+
20
+ Crab::Rally.new do |rally|
21
+ story = rally.find_story_with_id id
22
+
23
+ puts Array(story.scenarios).map {|scenario| Crab::CucumberScenario.new(opts[:language]).generate_from scenario }.join.strip
24
+ end
@@ -0,0 +1,24 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ opts = Trollop::options do
5
+ banner <<-BANNER
6
+ crab testcase list: displays all testcases in Rally in a story as Cucumber scenarios
7
+
8
+ Usage: crab testcase list <story> [options]"
9
+ BANNER
10
+ opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ end
12
+
13
+ id = ARGV.shift
14
+ unless id
15
+ $stderr.puts "Error: No story ID provided."
16
+ system "crab-testcase-help"
17
+ exit 1
18
+ end
19
+
20
+ Crab::Rally.new do |rally|
21
+ story = rally.find_story_with_id id
22
+
23
+ puts Array(story.scenarios).map {|scenario| Crab::CucumberScenario.new(opts[:language]).generate_from scenario }.join.strip
24
+ end
@@ -0,0 +1,25 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ include Crab::Utilities
5
+
6
+ opts = add_or_update_options "crab testcase add: add a test case to a story in Rally"
7
+
8
+ story_id = ARGV.shift
9
+ unless story_id
10
+ $stderr.puts "Error: Story ID not provided."
11
+ system "crab-testcase-help"
12
+ exit 1
13
+ end
14
+
15
+ name = ARGV.join(" ")
16
+ unless name
17
+ $stderr.puts "Error: Test case name not provided."
18
+ system "crab-testcase-help"
19
+ exit 1
20
+ end
21
+
22
+ Crab::Rally.new do |rally|
23
+ tc = rally.create_test_case(story_id, name, sanitize_options(opts))
24
+ puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
25
+ end
@@ -0,0 +1,13 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ Trollop::options do
5
+ banner "crab testcase delete: delete a test case in Rally"
6
+ end
7
+
8
+ tc_id = ARGV.shift
9
+ Crab::Rally.new do |rally|
10
+ tc = rally.find_test_case(tc_id)
11
+ tc.delete
12
+ puts "Test case #{tc_id} deleted."
13
+ end
@@ -0,0 +1,23 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ opts = Trollop::options do
5
+ banner <<-BANNER
6
+ crab testcase show: displays a testcase in Rally as a Cucumber scenario
7
+
8
+ Usage: crab testcase show <testcase> [options]"
9
+ BANNER
10
+ opt :language, "Language to display Cucumber features in (ISO code)", :default => "en", :short => "-l"
11
+ end
12
+
13
+ id = ARGV.shift
14
+ unless id
15
+ $stderr.puts "Error: No test case ID provided."
16
+ system "crab-testcase-help"
17
+ exit 1
18
+ end
19
+
20
+ Crab::Rally.new do |rally|
21
+ tc = rally.find_test_case id
22
+ puts Crab::CucumberScenario.new(opts[:language]).generate_from(tc).strip
23
+ end
@@ -0,0 +1,14 @@
1
+ # vim: set ft=ruby :
2
+ require 'crab'
3
+
4
+ include Crab::Utilities
5
+
6
+ opts = add_or_update_options "crab testcase update: update a test case in Rally"
7
+
8
+ tc_id = ARGV.shift
9
+
10
+ Crab::Rally.new do |rally|
11
+ tc = rally.find_test_case(tc_id)
12
+ tc.update(sanitize_options(opts))
13
+ puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
14
+ end
@@ -40,5 +40,32 @@ module Crab
40
40
  Crab::Story::VALID_STATES[i >= max ? max -1 : i]
41
41
  end
42
42
 
43
+ # TODO REFACTOR testcase related stuff that didn't have a good home
44
+ def add_or_update_options(banner)
45
+ Trollop::options do
46
+ banner banner
47
+ opt :priority, "Priority (one of: #{Crab::TestCase::PRIORITIES.join(" ")}", :default => "important", :short => '-p'
48
+ opt :risk, "Risk (one of: #{Crab::TestCase::RISKS.join(" ")})", :default => "medium", :short => '-r'
49
+ opt :method, "Method (one of: #{Crab::TestCase::METHODS.join(" ")})", :default => "automated", :short => '-m'
50
+ opt :type, "Type (one of: #{Crab::TestCase::TYPES.join(" ")})", :default => "acceptance", :short => '-t'
51
+ opt :pre, "Pre-conditions", :default => "N/A"
52
+ opt :post, "Post-conditions", :default => "N/A"
53
+ opt :desc, "Description", :default => "N/A", :short => '-d'
54
+ end
55
+ end
56
+
57
+ # TODO REFACTOR testcase related stuff that didn't have a good home
58
+ def sanitize_options(opts, creating=true)
59
+ result = {}
60
+ result[:priority] = opts[:priority].capitalize if creating || opts[:priority_given]
61
+ result[:risk] = opts[:risk].capitalize if creating || opts[:risk_given]
62
+ result[:method] = opts[:method].capitalize if creating || opts[:method_given]
63
+ result[:type] = opts[:type].capitalize if creating || opts[:type_given]
64
+ result[:pre_conditions] = opts[:pre] if creating || opts[:pre_given]
65
+ result[:post_conditions] = opts[:post] if creating || opts[:post_given]
66
+ result[:description] = opts[:desc] if creating || opts[:desc_given]
67
+ result
68
+ end
69
+
43
70
  end
44
71
  end
data/lib/crab/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Crab
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
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: 9
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 9
10
- version: 0.1.9
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carlos Villela
@@ -156,9 +156,12 @@ executables:
156
156
  - crab-delete
157
157
  - crab-find
158
158
  - crab-help
159
+ - crab-list
159
160
  - crab-login
161
+ - crab-ls
160
162
  - crab-move
161
163
  - crab-mv
164
+ - crab-new
162
165
  - crab-project
163
166
  - crab-pull
164
167
  - crab-remove
@@ -166,6 +169,16 @@ executables:
166
169
  - crab-show
167
170
  - crab-tc
168
171
  - crab-testcase
172
+ - crab-testcase-add
173
+ - crab-testcase-create
174
+ - crab-testcase-delete
175
+ - crab-testcase-help
176
+ - crab-testcase-list
177
+ - crab-testcase-ls
178
+ - crab-testcase-new
179
+ - crab-testcase-rm
180
+ - crab-testcase-show
181
+ - crab-testcase-update
169
182
  - crab-truncate
170
183
  - crab-up
171
184
  - crab-update
@@ -188,9 +201,12 @@ files:
188
201
  - bin/crab-delete
189
202
  - bin/crab-find
190
203
  - bin/crab-help
204
+ - bin/crab-list
191
205
  - bin/crab-login
206
+ - bin/crab-ls
192
207
  - bin/crab-move
193
208
  - bin/crab-mv
209
+ - bin/crab-new
194
210
  - bin/crab-project
195
211
  - bin/crab-pull
196
212
  - bin/crab-remove
@@ -198,6 +214,16 @@ files:
198
214
  - bin/crab-show
199
215
  - bin/crab-tc
200
216
  - bin/crab-testcase
217
+ - bin/crab-testcase-add
218
+ - bin/crab-testcase-create
219
+ - bin/crab-testcase-delete
220
+ - bin/crab-testcase-help
221
+ - bin/crab-testcase-list
222
+ - bin/crab-testcase-ls
223
+ - bin/crab-testcase-new
224
+ - bin/crab-testcase-rm
225
+ - bin/crab-testcase-show
226
+ - bin/crab-testcase-update
201
227
  - bin/crab-truncate
202
228
  - bin/crab-up
203
229
  - bin/crab-update