dtf 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/dtf +2 -8
- data/doc/AnalysisCase.html +1 -1
- data/doc/CaseTest.html +1 -1
- data/doc/Dtf.html +3 -5
- data/doc/Dtf/Command.html +127 -117
- data/doc/Dtf/ErrorSystem.html +272 -0
- data/doc/Dtf/OptionsParser.html +321 -0
- data/doc/User.html +1 -1
- data/doc/VerificationSuite.html +1 -1
- data/doc/_index.html +19 -6
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/method_list.html +13 -5
- data/doc/top-level-namespace.html +1 -149
- data/dtf.gemspec +2 -2
- data/lib/dtf.rb +109 -23
- data/lib/dtf/version.rb +1 -1
- data/spec/models/analysis_case_spec.rb +4 -1
- data/spec/models/case_test_spec.rb +4 -1
- data/spec/models/user_spec.rb +4 -1
- data/spec/models/verification_suite_spec.rb +4 -1
- metadata +6 -9
- data/doc/.gitkeep +0 -0
- data/doc/Dtf/HelpSystem.html +0 -128
- data/lib/dtf/error_system.rb +0 -16
- data/lib/dtf/help_system.rb +0 -59
@@ -100,160 +100,12 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
|
104
|
-
<h2>
|
105
|
-
Instance Method Summary
|
106
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
107
|
-
</h2>
|
108
|
-
|
109
|
-
<ul class="summary">
|
110
|
-
|
111
|
-
<li class="public ">
|
112
|
-
<span class="summary_signature">
|
113
|
-
|
114
|
-
<a href="#display_errors-instance_method" title="#display_errors (instance method)">- (Object) <strong>display_errors</strong>(cmd) </a>
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
</span>
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
129
|
-
|
130
|
-
</li>
|
131
|
-
|
132
|
-
|
133
|
-
<li class="public ">
|
134
|
-
<span class="summary_signature">
|
135
|
-
|
136
|
-
<a href="#raise_error-instance_method" title="#raise_error (instance method)">- (Object) <strong>raise_error</strong>(cmd) </a>
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
</span>
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
<span class="summary_desc"><div class='inline'>
|
151
|
-
<p>Reusable error response method.</p>
|
152
|
-
</div></span>
|
153
|
-
|
154
|
-
</li>
|
155
|
-
|
156
|
-
|
157
|
-
</ul>
|
158
|
-
|
159
103
|
|
160
104
|
|
161
|
-
|
162
|
-
<div id="instance_method_details" class="method_details_list">
|
163
|
-
<h2>Instance Method Details</h2>
|
164
|
-
|
165
|
-
|
166
|
-
<div class="method_details first">
|
167
|
-
<h3 class="signature first" id="display_errors-instance_method">
|
168
|
-
|
169
|
-
- (<tt>Object</tt>) <strong>display_errors</strong>(cmd)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
</h3><table class="source_code">
|
176
|
-
<tr>
|
177
|
-
<td>
|
178
|
-
<pre class="lines">
|
179
|
-
|
180
|
-
|
181
|
-
13
|
182
|
-
14
|
183
|
-
15
|
184
|
-
16</pre>
|
185
|
-
</td>
|
186
|
-
<td>
|
187
|
-
<pre class="code"><span class="info file"># File 'lib/dtf/error_system.rb', line 13</span>
|
188
|
-
|
189
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_display_errors'>display_errors</span><span class='lparen'>(</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rparen'>)</span>
|
190
|
-
<span class='comment'># TODO: Refactor error display to take sub-command as an arg
|
191
|
-
</span> <span class='comment'># and display obj.errors.messages.each properly for each arg type.
|
192
|
-
</span><span class='kw'>end</span></pre>
|
193
|
-
</td>
|
194
|
-
</tr>
|
195
|
-
</table>
|
196
|
-
</div>
|
197
|
-
|
198
|
-
<div class="method_details ">
|
199
|
-
<h3 class="signature " id="raise_error-instance_method">
|
200
|
-
|
201
|
-
- (<tt>Object</tt>) <strong>raise_error</strong>(cmd)
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
</h3><div class="docstring">
|
208
|
-
<div class="discussion">
|
209
|
-
|
210
|
-
<p>Reusable error response method</p>
|
211
|
-
|
212
|
-
|
213
|
-
</div>
|
214
|
-
</div>
|
215
|
-
<div class="tags">
|
216
|
-
|
217
|
-
|
218
|
-
</div><table class="source_code">
|
219
|
-
<tr>
|
220
|
-
<td>
|
221
|
-
<pre class="lines">
|
222
|
-
|
223
|
-
|
224
|
-
3
|
225
|
-
4
|
226
|
-
5
|
227
|
-
6
|
228
|
-
7
|
229
|
-
8
|
230
|
-
9
|
231
|
-
10
|
232
|
-
11</pre>
|
233
|
-
</td>
|
234
|
-
<td>
|
235
|
-
<pre class="code"><span class="info file"># File 'lib/dtf/error_system.rb', line 3</span>
|
236
|
-
|
237
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_raise_error'>raise_error</span><span class='lparen'>(</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rparen'>)</span>
|
238
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span>
|
239
|
-
<span class='kw'>rescue</span>
|
240
|
-
<span class='gvar'>$stderr</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ERROR! </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rbrace'>}</span><span class='tstring_content'> did not receive all required options.</span><span class='tstring_end'>"</span></span>
|
241
|
-
<span class='gvar'>$stderr</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>See 'dtf </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rbrace'>}</span><span class='tstring_content'> -h' for help with this sub-command</span><span class='tstring_end'>"</span></span>
|
242
|
-
|
243
|
-
<span class='comment'># Set non-zero exit value on error, for scripting use.
|
244
|
-
</span> <span class='id identifier rubyid_abort'>abort</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
245
|
-
<span class='kw'>end</span></pre>
|
246
|
-
</td>
|
247
|
-
</tr>
|
248
|
-
</table>
|
249
|
-
</div>
|
250
|
-
|
251
|
-
</div>
|
252
|
-
|
253
105
|
</div>
|
254
106
|
|
255
107
|
<div id="footer">
|
256
|
-
Generated on
|
108
|
+
Generated on Thu Sep 20 00:16:43 2012 by
|
257
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
258
110
|
0.8.2.1 (ruby-1.9.3).
|
259
111
|
</div>
|
data/dtf.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/dtf/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["David Deryl Downey"]
|
6
6
|
gem.email = ["me@daviddwdowney.com"]
|
7
|
-
gem.description = %q{DTF is a modular testing framework skeleton. This is the control gem
|
8
|
-
gem.summary = %q{DTF is a modular testing framework. This is the
|
7
|
+
gem.description = %q{DTF is a modular testing framework skeleton. This is the control gem containing the db schema(s) and command-line script.}
|
8
|
+
gem.summary = %q{DTF is a modular testing framework. This is the master gem for the DTF framework.}
|
9
9
|
gem.homepage = "https://github.com/dtf-gems/dtf"
|
10
10
|
gem.license = 'MIT'
|
11
11
|
gem.platform = Gem::Platform::RUBY
|
data/lib/dtf.rb
CHANGED
@@ -1,41 +1,122 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require "dtf/version"
|
4
|
+
require 'trollop' # Used to implement help system
|
4
5
|
|
5
6
|
module Dtf
|
6
7
|
load "#{File.join(File.dirname(__FILE__), "/config/environment.rb")}"
|
7
8
|
|
9
|
+
class ErrorSystem
|
10
|
+
# Reusable error response method
|
11
|
+
def self.raise_error(cmd)
|
12
|
+
raise ArgumentError
|
13
|
+
rescue
|
14
|
+
$stderr.puts "ERROR! #{cmd} did not receive all required options."
|
15
|
+
$stderr.puts "Please execute \'dtf #{cmd} -h\' for more information."
|
16
|
+
# Set non-zero exit value on error, for scripting use.
|
17
|
+
abort()
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.display_errors(obj)
|
21
|
+
# TODO: Refactor error display to take sub-command as an arg
|
22
|
+
# and display obj.errors.full_messages.each properly for each arg type.
|
23
|
+
obj.errors.full_messages.all.each do |msg|
|
24
|
+
$stderr.puts "#{msg}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end # End of Dtf::ErrorSystem class
|
29
|
+
|
30
|
+
class OptionsParser
|
31
|
+
# List of all sub-commands known within the Help System
|
32
|
+
SUB_COMMANDS = %w(create_user delete_user create_vs delete_vs)
|
33
|
+
|
34
|
+
def self.parse_cmds
|
35
|
+
# Global options default to '--version|-v' and '--help|-h'
|
36
|
+
global_opts = Trollop::options do
|
37
|
+
version "DTF v#{Dtf::VERSION}"
|
38
|
+
banner <<-EOS
|
39
|
+
#{version}
|
40
|
+
(c) Copyright 2012 David Deryl Downey / Deryl R. Doucette. All Rights Reserved.
|
41
|
+
This is free software; see the LICENSE file for copying conditions.
|
42
|
+
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
43
|
+
|
44
|
+
Usage:
|
45
|
+
dtf -v|--version -h|--help [[sub_cmds <options>] -h|--help]
|
46
|
+
|
47
|
+
Valid [sub_cmds] are: create_(user|vs), delete_(user|vs)
|
48
|
+
See 'dtf [sub_cmd] -h' for each sub_cmd's details and options
|
49
|
+
|
50
|
+
EOS
|
51
|
+
stop_on SUB_COMMANDS
|
52
|
+
end
|
53
|
+
|
54
|
+
@cmd = ARGV.shift
|
55
|
+
@cmd_opts = case @cmd
|
56
|
+
when "create_user"
|
57
|
+
Trollop::options do
|
58
|
+
opt(:user_name, desc="Username for new TF user - REQUIRED", opts={:type => :string, :short => '-u'})
|
59
|
+
opt(:full_name, desc="Real name for new TF user - REQUIRED", opts={:type => :string, :short => '-n'})
|
60
|
+
opt(:email_address, desc="Email address for new TF user - REQUIRED", opts={:type => :string, :short => '-e'})
|
61
|
+
end
|
62
|
+
when "create_vs"
|
63
|
+
Trollop::options do
|
64
|
+
opt(:user_name, desc="TF user to associate this VS with - REQUIRED", opts={:type => :string, :short => '-u'})
|
65
|
+
opt(:name, desc="Name for new VS - REQUIRED", opts={:type => :string, :short => '-n'})
|
66
|
+
opt(:description, desc="Description of VS's intended use - OPTIONAL", opts={:type => :string, :short => '-d', :default => ''})
|
67
|
+
end
|
68
|
+
when "delete_user"
|
69
|
+
Trollop::options do
|
70
|
+
opt(:user_name, desc="Username of TF user to delete - REQUIRED", opts={:type => :string, :short => '-u'})
|
71
|
+
opt(:delete_all, desc="Delete _all_ VSs this user owns", :type => :flag, :default => true)
|
72
|
+
end
|
73
|
+
when "delete_vs"
|
74
|
+
Trollop::options do
|
75
|
+
opt(:user_name, desc="Username of VS owner - REQUIRED", opts={:type => :string, :short => '-u'})
|
76
|
+
opt(:id, desc="ID of VS to be deleted - REQUIRED", opts={:type => :int, :short => '-i'})
|
77
|
+
end
|
78
|
+
when nil
|
79
|
+
Trollop::die "No command specified! Please specify an applicable command"
|
80
|
+
else
|
81
|
+
Trollop::die "Unknown DTF sub-command: #{@cmd.inspect}"
|
82
|
+
end
|
83
|
+
|
84
|
+
return @cmd, @cmd_opts # Specifically return @cmd and its @cmd_opts
|
85
|
+
end
|
86
|
+
end # End Dtf::OptionsParser clas
|
87
|
+
|
88
|
+
|
8
89
|
# Dtf::Command contains all sub-commands availabe in the DTF master gem.
|
9
90
|
# All methods recieve the @cmd and @cmd_opts parsed from the command-line.
|
10
91
|
# They are what was captured in the ivars in Dtf::HelpSystem
|
11
92
|
class Command
|
12
|
-
|
93
|
+
|
13
94
|
# Process both the requested command and all/any parameters.
|
14
95
|
# NOTE: This method is the 'master' method. It parses @cmd for which sub-command to execute and then hands
|
15
96
|
# off to the appropriate method. All methods are a 1:1 match in their name.
|
16
|
-
# e.g 'create_user' sub-command is matched to the 'create_user' method of this class.
|
97
|
+
# e.g 'create_user' sub-command is matched to the 'create_user' method of this class.
|
17
98
|
#
|
18
99
|
# This method requires, and processes, 2 arguments. The 'cmd' to process, and any 'cmd_opts' of that sub-command.
|
19
100
|
def self.process(cmd, cmd_opts)
|
20
101
|
case cmd
|
21
102
|
when "create_user"
|
22
|
-
create_user(cmd, cmd_opts)
|
103
|
+
self.create_user(cmd, cmd_opts)
|
23
104
|
|
24
105
|
when "delete_user"
|
25
|
-
delete_user(cmd, cmd_opts)
|
106
|
+
self.delete_user(cmd, cmd_opts)
|
26
107
|
|
27
108
|
when "create_vs"
|
28
|
-
create_vs(cmd, cmd_opts)
|
109
|
+
self.create_vs(cmd, cmd_opts)
|
29
110
|
|
30
111
|
when "delete_vs"
|
31
|
-
delete_vs(cmd, cmd_opts)
|
112
|
+
self.delete_vs(cmd, cmd_opts)
|
32
113
|
|
33
114
|
else
|
34
|
-
$stderr.puts "Unknown DTF sub-command: #{cmd
|
115
|
+
$stderr.puts "Unknown DTF sub-command: #{cmd}"
|
35
116
|
abort()
|
36
117
|
end
|
37
118
|
end
|
38
|
-
|
119
|
+
|
39
120
|
# This sub-command is used to add a User to the Test Framework system
|
40
121
|
#
|
41
122
|
# Required Parameters are:
|
@@ -48,7 +129,7 @@ module Dtf
|
|
48
129
|
if [:user_name_given, :full_name_given, :email_address_given].all? { |sym| cmd_opts.key?(sym) } then
|
49
130
|
user = User.where(user_name: cmd_opts[:user_name],
|
50
131
|
full_name: cmd_opts[:full_name],
|
51
|
-
email_address: cmd_opts[:email_address]).
|
132
|
+
email_address: cmd_opts[:email_address]).create
|
52
133
|
|
53
134
|
# Check to make sure user was actually saved to the db
|
54
135
|
if user.persisted? then
|
@@ -56,17 +137,17 @@ module Dtf
|
|
56
137
|
else
|
57
138
|
# Oops, it wasn't! Notify user and display any error message(s)
|
58
139
|
$stderr.puts "ERROR: #{cmd_opts[:user_name].to_s} was NOT created! Please fix the following errors and try again:"
|
59
|
-
user.errors.
|
60
|
-
$stderr.puts "#{
|
140
|
+
user.errors.full_messages.each do |msg|
|
141
|
+
$stderr.puts "#{msg}"
|
61
142
|
end
|
62
143
|
# Now throw a proper error code to the system, while exiting the script
|
63
144
|
abort()
|
64
145
|
end
|
65
146
|
else
|
66
|
-
raise_error(cmd) # This error here is thrown when not all params are provided
|
147
|
+
Dtf::ErrorSystem.raise_error(cmd) # This error here is thrown when not all params are provided
|
67
148
|
end
|
68
149
|
end
|
69
|
-
|
150
|
+
|
70
151
|
# This sub-command removes a User from the Testing Framework system
|
71
152
|
#
|
72
153
|
# Required Parameters are:
|
@@ -101,18 +182,23 @@ module Dtf
|
|
101
182
|
else
|
102
183
|
puts "#{cmd} called with '--delete-all' set or on by default! Deleting all VSs owned by #{cmd_opts[:user_name]}"
|
103
184
|
user = User.find_by_user_name(cmd_opts[:user_name])
|
104
|
-
user.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
185
|
+
if ! user.nil? then
|
186
|
+
user.verification_suites.all.each do |vs|
|
187
|
+
VerificationSuite.delete(vs)
|
188
|
+
end
|
189
|
+
if user.verification_suites.empty? then
|
190
|
+
User.delete(user)
|
191
|
+
end
|
192
|
+
else
|
193
|
+
$stderr.puts "ERROR: No user named \'#{cmd_opts[:user_name].to_s}\' found!"
|
194
|
+
abort()
|
109
195
|
end
|
110
196
|
end
|
111
197
|
else
|
112
|
-
raise_error(cmd)
|
198
|
+
Dtf::ErrorSystem.raise_error(cmd)
|
113
199
|
end
|
114
200
|
end
|
115
|
-
|
201
|
+
|
116
202
|
# This sub-command generates, adds, and associates a Verification Suite in the Testing Framework system.
|
117
203
|
#
|
118
204
|
# Required Parameters are:
|
@@ -138,7 +224,7 @@ module Dtf
|
|
138
224
|
abort()
|
139
225
|
end
|
140
226
|
else
|
141
|
-
raise_error(cmd)
|
227
|
+
Dtf::ErrorSystem.raise_error(cmd)
|
142
228
|
end
|
143
229
|
end
|
144
230
|
|
@@ -156,9 +242,9 @@ module Dtf
|
|
156
242
|
vs = user.verification_suites.find(cmd_opts[:id])
|
157
243
|
VerificationSuite.delete(vs)
|
158
244
|
else
|
159
|
-
raise_error(cmd)
|
245
|
+
Dtf::ErrorSystem.raise_error(cmd)
|
160
246
|
end
|
161
|
-
end
|
247
|
+
end
|
162
248
|
|
163
249
|
end # End of class
|
164
250
|
|
data/lib/dtf/version.rb
CHANGED
@@ -14,18 +14,21 @@ describe "AnalysisCase" do
|
|
14
14
|
|
15
15
|
it "should be invalid without being assigned to a verification suite" do
|
16
16
|
analysis_case.should_not be_valid
|
17
|
+
analysis_case.errors.should_not be_empty
|
17
18
|
analysis_case[:verification_suite_id].should be_nil
|
18
19
|
analysis_case.new_record?.should be_true
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should be invalid without a name" do
|
22
23
|
analysis_case.should_not be_valid
|
24
|
+
analysis_case.errors.should_not be_empty
|
23
25
|
analysis_case.errors.messages[:name].should eq(["can't be blank"])
|
24
26
|
analysis_case.new_record?.should be_true
|
25
27
|
end
|
26
28
|
|
27
29
|
it "should be invalid without a description" do
|
28
30
|
analysis_case.should_not be_valid
|
31
|
+
analysis_case.errors.should_not be_empty
|
29
32
|
analysis_case.errors.messages[:description].should eq(["can't be blank"])
|
30
33
|
analysis_case.new_record?.should be_true
|
31
34
|
end
|
@@ -49,7 +52,7 @@ describe "AnalysisCase" do
|
|
49
52
|
|
50
53
|
it "should have a valid name and description" do
|
51
54
|
analysis_case.should be_valid
|
52
|
-
analysis_case.errors.
|
55
|
+
analysis_case.errors.should be_empty
|
53
56
|
analysis_case.name.should_not be_nil
|
54
57
|
analysis_case.description.should_not be_nil
|
55
58
|
end
|
@@ -14,18 +14,21 @@ describe "CaseTest" do
|
|
14
14
|
|
15
15
|
it "should be invalid without being assigned to a analysis case" do
|
16
16
|
case_test.should_not be_valid
|
17
|
+
case_test.errors.should_not be_empty
|
17
18
|
case_test[:analysis_case_id].should be_nil
|
18
19
|
case_test.new_record?.should be_true
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should be invalid without a cmd" do
|
22
23
|
case_test.should_not be_valid
|
24
|
+
case_test.errors.should_not be_empty
|
23
25
|
case_test.errors.messages[:cmd].should eq(["can't be blank"])
|
24
26
|
case_test.new_record?.should be_true
|
25
27
|
end
|
26
28
|
|
27
29
|
it "should be invalid without a description" do
|
28
30
|
case_test.should_not be_valid
|
31
|
+
case_test.errors.should_not be_empty
|
29
32
|
case_test.errors.messages[:description].should eq(["can't be blank"])
|
30
33
|
case_test.new_record?.should be_true
|
31
34
|
end
|
@@ -52,7 +55,7 @@ describe "CaseTest" do
|
|
52
55
|
|
53
56
|
it "should have a valid cmd and description" do
|
54
57
|
case_test.should be_valid
|
55
|
-
case_test.errors.
|
58
|
+
case_test.errors.should be_empty
|
56
59
|
case_test.cmd.should_not be_nil
|
57
60
|
case_test.description.should_not be_nil
|
58
61
|
end
|