dtf 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/Gemfile +4 -0
- data/Rakefile +19 -2
- data/TODO +11 -0
- data/bin/dtf +5 -2
- data/lib/dtf.rb +157 -172
- data/lib/dtf/version.rb +1 -1
- data/spec/acceptance/verify_sub_commands.feature +26 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/steps/feature_steps.rb +73 -1
- metadata +4 -2
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -4,8 +4,25 @@
|
|
4
4
|
require "bundler/gem_tasks"
|
5
5
|
|
6
6
|
begin
|
7
|
-
|
7
|
+
require 'tasks/standalone_migrations'
|
8
8
|
rescue LoadError => e
|
9
|
-
|
9
|
+
puts "gem install standalone_migrations to get db:migrate:* tasks! (Error: #{e})"
|
10
10
|
end
|
11
11
|
|
12
|
+
namespace :cover_me do
|
13
|
+
|
14
|
+
desc "Generates and opens code coverage report."
|
15
|
+
task :report do
|
16
|
+
require 'cover_me'
|
17
|
+
CoverMe.complete!
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
task :test do
|
23
|
+
Rake::Task['cover_me:report'].invoke
|
24
|
+
end
|
25
|
+
|
26
|
+
task :spec do
|
27
|
+
Rake::Task['cover_me:report'].invoke
|
28
|
+
end
|
data/TODO
CHANGED
@@ -23,3 +23,14 @@ dtf-session becomes a dependency of dtf-shell which will be written to support
|
|
23
23
|
specific Shells
|
24
24
|
|
25
25
|
dtf-rvm will have a dependency on both dtf-session, and rvm gems
|
26
|
+
|
27
|
+
wrap the trollop use of ARGV in a method that takes an argument,
|
28
|
+
call the argument 'argv' and then pass in ARGV in your bin-script
|
29
|
+
and then in a test, pass in a different array. In the trollop code,
|
30
|
+
adjust any reference to ARGV to point to argv.
|
31
|
+
|
32
|
+
the trollop parse method (from my quick google) is defined with
|
33
|
+
'def parse cmdline=ARGV', you could follow a similar idea
|
34
|
+
(same with options - def options args=ARGV, *a, &b)
|
35
|
+
Also, check out 'ri CLI'
|
36
|
+
Rework dtf module to apply Command design pattern to Dtf::Command and clean up case statements.
|
data/bin/dtf
CHANGED
@@ -6,5 +6,8 @@
|
|
6
6
|
|
7
7
|
require 'dtf'
|
8
8
|
|
9
|
-
@
|
10
|
-
|
9
|
+
@parser = Dtf::OptionsParser.new
|
10
|
+
@cmd, @cmd_opts = @parser.parse_cmds # Parse the command-line, and return the cmd & its specific cmd_opts
|
11
|
+
|
12
|
+
@new_cmd = Dtf::Command.create_cmd(@cmd) # Create a command named after contents of @cmd var
|
13
|
+
@new_cmd.execute(@cmd_opts) # Pass @cmd_opts to that command's execute method
|
data/lib/dtf.rb
CHANGED
@@ -1,18 +1,167 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'dtf/version'
|
4
4
|
require 'trollop'
|
5
5
|
|
6
6
|
module Dtf
|
7
7
|
load "#{File.join(File.dirname(__FILE__), "/config/environment.rb")}"
|
8
|
+
|
9
|
+
module Command
|
10
|
+
def self.create_cmd(cmd)
|
11
|
+
puts "#{@cmd}"
|
12
|
+
begin
|
13
|
+
new_cmd = Dtf::Command.const_get(cmd.camelize).new
|
14
|
+
rescue NameError
|
15
|
+
puts "DTF has no registered command by that name."
|
16
|
+
puts "Please see 'dtf -h' for the list of recognized commands."
|
17
|
+
else
|
18
|
+
return new_cmd
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# This sub-command is used to add a User to the Test Framework system
|
23
|
+
#
|
24
|
+
# Required Parameters are:
|
25
|
+
# --user-name [String], --full-name [String], --email-address [String]
|
26
|
+
#
|
27
|
+
# '--user-name' is used to specify the user_name of the created User, and *must* be unique in the system.
|
28
|
+
# '--full-name' is the Real Name of the created User.
|
29
|
+
# '--email-address' is the email address of the created User, and *must* be unique in the system.
|
30
|
+
class CreateUser
|
31
|
+
def execute(cmd_opts)
|
32
|
+
if [:user_name_given, :full_name_given, :email_address_given].all? { |sym| cmd_opts.key?(sym) } then
|
33
|
+
user = User.where(user_name: cmd_opts[:user_name],
|
34
|
+
full_name: cmd_opts[:full_name],
|
35
|
+
email_address: cmd_opts[:email_address]).create
|
36
|
+
|
37
|
+
# Check to make sure user was actually saved to the db
|
38
|
+
if user.persisted? then
|
39
|
+
puts "Created user \'#{cmd_opts[:user_name]}\' for \'#{cmd_opts[:full_name]}\'"
|
40
|
+
else
|
41
|
+
# Oops, it wasn't! Notify user and display any error message(s)
|
42
|
+
$stderr.puts "ERROR: #{cmd_opts[:user_name].to_s} was NOT created! Please fix the following errors and try again:"
|
43
|
+
user.errors.full_messages.each do |msg|
|
44
|
+
$stderr.puts "#{msg}"
|
45
|
+
end
|
46
|
+
# Now throw a proper error code to the system, while exiting the script
|
47
|
+
abort()
|
48
|
+
end
|
49
|
+
else
|
50
|
+
Dtf::ErrorSystem.raise_error(@cmd) # This error here is thrown when not all params are provided
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# This sub-command generates, adds, and associates a Verification Suite in the Testing Framework system.
|
56
|
+
#
|
57
|
+
# Required Parameters are:
|
58
|
+
# --user-name [String], --name [String]
|
59
|
+
#
|
60
|
+
# '--user-name' is the user_name of the User that should own this Verification Suite.
|
61
|
+
# '--name' is the descriptive name of the Verification Suite.
|
62
|
+
#
|
63
|
+
# Options are:
|
64
|
+
# --description [String]
|
65
|
+
#
|
66
|
+
# This *optional* parameter is for providing a description of the Verification Suite's use.
|
67
|
+
# e.g. --description "RSpec Verification"
|
68
|
+
class CreateVs
|
69
|
+
def execute(cmd_opts)
|
70
|
+
if [:user_name_given, :name_given].all? { |sym| cmd_opts.key?(sym) } then
|
71
|
+
user = User.find_by_user_name(cmd_opts[:user_name])
|
72
|
+
vs = user.verification_suites.create(name: cmd_opts[:name], description: cmd_opts[:description])
|
73
|
+
if vs.persisted? then
|
74
|
+
puts "VS named \'#{cmd_opts[:name]}\' allocated to user \'#{cmd_opts[:user_name]}\'"
|
75
|
+
else
|
76
|
+
$stderr.puts "ERROR: Failed to save Verification Suite. Check DB logfile for errors"
|
77
|
+
abort()
|
78
|
+
end
|
79
|
+
else
|
80
|
+
Dtf::ErrorSystem.raise_error(@cmd)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
8
84
|
|
85
|
+
# This sub-command removes a User from the Testing Framework system
|
86
|
+
#
|
87
|
+
# Required Parameters are:
|
88
|
+
# --user-name [String]
|
89
|
+
#
|
90
|
+
# '--user-name' is the assigned user_name of the User you wish to delete.
|
91
|
+
#
|
92
|
+
# Optional Flags are:
|
93
|
+
# --delete-all|--no-delete-all
|
94
|
+
#
|
95
|
+
# By default this command will delete *all* Verification Suites owned by the deleted user.
|
96
|
+
# The default behaviour is as if the sub-command had been invoked passing the '--delete-all' flag explicitly.
|
97
|
+
#
|
98
|
+
# To delete the user, but *keep* their VS, pass the '--no-delete-all' flag.
|
99
|
+
# This flag will find all Verification Suites owned by the user being deleted, and reassign them
|
100
|
+
# to 'Library Owner' (user_name: library_owner) which is the generic in-house User shipped with DTF.
|
101
|
+
class DeleteUser
|
102
|
+
def execute(cmd_opts)
|
103
|
+
if [:user_name_given, :delete_all].all? { |sym| cmd_opts.key?(sym) } then
|
104
|
+
# NOTE: :delete_all is 'true' by default. passing '--no-delete-all' sets it to false,
|
105
|
+
# and adds the :delete_all_given key to the cmd_opts hash, set to true.
|
106
|
+
# This means NOT to delete all VSs associated with this user. We delete them by default.
|
107
|
+
if cmd_opts[:delete_all] == false && cmd_opts[:delete_all_given] == true
|
108
|
+
puts "Called with '--no-delete-all' set! NOT deleting all owned VSs!"
|
109
|
+
puts "Reassigning VSs to Library. New owner will be \'Library Owner\'"
|
110
|
+
user = User.find_by_user_name(cmd_opts[:user_name])
|
111
|
+
lib_owner = User.find_by_user_name("library_owner")
|
112
|
+
user.verification_suites.all.each do |vs|
|
113
|
+
vs.user_id = lib_owner.id
|
114
|
+
vs.save
|
115
|
+
end
|
116
|
+
User.delete(user)
|
117
|
+
else
|
118
|
+
puts "Called with '--delete-all' set or on by default! Deleting all VSs owned by #{cmd_opts[:user_name]}"
|
119
|
+
user = User.find_by_user_name(cmd_opts[:user_name])
|
120
|
+
if ! user.nil? then
|
121
|
+
user.verification_suites.all.each do |vs|
|
122
|
+
VerificationSuite.delete(vs)
|
123
|
+
end
|
124
|
+
if user.verification_suites.empty? then
|
125
|
+
User.delete(user)
|
126
|
+
end
|
127
|
+
else
|
128
|
+
$stderr.puts "ERROR: No user named \'#{cmd_opts[:user_name].to_s}\' found!"
|
129
|
+
abort()
|
130
|
+
end
|
131
|
+
end
|
132
|
+
else
|
133
|
+
Dtf::ErrorSystem.raise_error(@cmd)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# This sub-command removes a Verification Suite from the Testing Framework system
|
139
|
+
#
|
140
|
+
# Required Parameters are:
|
141
|
+
# --user-name [String], --id [Integer]
|
142
|
+
#
|
143
|
+
# The '--user-name' parameter is the user_name of the User that owns the Verification Suite you wish to delete
|
144
|
+
# The '--id' parameter is the ID # of the Verification Suite you wish to delete, as provided by @vs.id
|
145
|
+
class DeleteVs
|
146
|
+
def execute(cmd_opts)
|
147
|
+
if [:user_name_given, :id_given].all? { |sym| cmd_opts.key?(sym) } then
|
148
|
+
puts "Deleting #{cmd_opts[:user_name]}\'s VS with ID \'#{cmd_opts[:id]}\'"
|
149
|
+
user = User.find_by_user_name(cmd_opts[:user_name])
|
150
|
+
vs = user.verification_suites.find(cmd_opts[:id])
|
151
|
+
VerificationSuite.delete(vs)
|
152
|
+
else
|
153
|
+
Dtf::ErrorSystem.raise_error(@cmd)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end # End of Dtf::Command module
|
159
|
+
|
9
160
|
# Dtf::ErrorSystem is DTF's custom error management class
|
10
161
|
class ErrorSystem
|
11
162
|
# Reusable error raising and response method.
|
12
163
|
# Returns exit status code of '1' via abort().
|
13
164
|
def self.raise_error(cmd)
|
14
|
-
raise ArgumentError
|
15
|
-
rescue
|
16
165
|
$stderr.puts "ERROR! #{cmd} did not receive all required options."
|
17
166
|
$stderr.puts "Please execute \'dtf #{cmd} -h\' for more information."
|
18
167
|
abort()
|
@@ -30,8 +179,7 @@ module Dtf
|
|
30
179
|
obj.errors.full_messages.all.each do |msg|
|
31
180
|
$stderr.puts "#{msg}"
|
32
181
|
end
|
33
|
-
end
|
34
|
-
|
182
|
+
end
|
35
183
|
end
|
36
184
|
|
37
185
|
# Dtf::OptionsParser is DTF's command/options/parameters parsing class.
|
@@ -46,7 +194,7 @@ module Dtf
|
|
46
194
|
# and provides the help system for options/parameters.
|
47
195
|
#
|
48
196
|
# Returned Values: @cmd [Type: String] and @cmd_opts [Type: Hash]
|
49
|
-
def
|
197
|
+
def parse_cmds(arg=ARGV)
|
50
198
|
# Global options default to '--version|-v' and '--help|-h'
|
51
199
|
global_opts = Trollop::options do
|
52
200
|
version "DTF v#{Dtf::VERSION}"
|
@@ -66,7 +214,7 @@ module Dtf
|
|
66
214
|
stop_on SUB_COMMANDS
|
67
215
|
end
|
68
216
|
|
69
|
-
@cmd =
|
217
|
+
@cmd = arg.shift
|
70
218
|
@cmd_opts = case @cmd
|
71
219
|
when "create_user"
|
72
220
|
Trollop::options do
|
@@ -99,168 +247,5 @@ module Dtf
|
|
99
247
|
return @cmd, @cmd_opts # Explicitly return @cmd and its @cmd_opts
|
100
248
|
end
|
101
249
|
end
|
102
|
-
|
103
|
-
|
104
|
-
# Dtf::Command contains all sub-commands availabe in the DTF master gem.
|
105
|
-
# All methods receive the @cmd and @cmd_opts returned by Dtf::OptionsParser.parse_cmds()
|
106
|
-
class Command
|
107
|
-
|
108
|
-
# Process both the requested command and all/any parameters.
|
109
|
-
# NOTE: This method is the 'master' method. It parses @cmd for which sub-command to execute and then hands
|
110
|
-
# off to the appropriate method. All methods are a 1:1 match in their name.
|
111
|
-
# e.g 'create_user' sub-command is matched to the 'create_user' method of this class.
|
112
|
-
#
|
113
|
-
# This method requires, and processes, 2 arguments. The first is a String, the second is a Hash.
|
114
|
-
# They are the 'cmd' to process and any options/parameters, stored in the 'cmd_opts' hash, of that sub-command.
|
115
|
-
def self.process(cmd, cmd_opts)
|
116
|
-
case cmd
|
117
|
-
when "create_user"
|
118
|
-
self.create_user(cmd, cmd_opts)
|
119
|
-
|
120
|
-
when "delete_user"
|
121
|
-
self.delete_user(cmd, cmd_opts)
|
122
|
-
|
123
|
-
when "create_vs"
|
124
|
-
self.create_vs(cmd, cmd_opts)
|
125
|
-
|
126
|
-
when "delete_vs"
|
127
|
-
self.delete_vs(cmd, cmd_opts)
|
128
|
-
|
129
|
-
else
|
130
|
-
$stderr.puts "Unknown DTF sub-command: #{cmd}"
|
131
|
-
abort()
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# This sub-command is used to add a User to the Test Framework system
|
136
|
-
#
|
137
|
-
# Required Parameters are:
|
138
|
-
# --user-name [String], --full-name [String], --email-address [String]
|
139
|
-
#
|
140
|
-
# '--user-name' is used to specify the user_name of the created User, and *must* be unique in the system.
|
141
|
-
# '--full-name' is the Real Name of the created User.
|
142
|
-
# '--email-address' is the email address of the created User, and *must* be unique in the system.
|
143
|
-
def self.create_user(cmd, cmd_opts)
|
144
|
-
if [:user_name_given, :full_name_given, :email_address_given].all? { |sym| cmd_opts.key?(sym) } then
|
145
|
-
user = User.where(user_name: cmd_opts[:user_name],
|
146
|
-
full_name: cmd_opts[:full_name],
|
147
|
-
email_address: cmd_opts[:email_address]).create
|
148
|
-
|
149
|
-
# Check to make sure user was actually saved to the db
|
150
|
-
if user.persisted? then
|
151
|
-
puts "Created user \'#{cmd_opts[:user_name]}\' for \'#{cmd_opts[:full_name]}\'"
|
152
|
-
else
|
153
|
-
# Oops, it wasn't! Notify user and display any error message(s)
|
154
|
-
$stderr.puts "ERROR: #{cmd_opts[:user_name].to_s} was NOT created! Please fix the following errors and try again:"
|
155
|
-
user.errors.full_messages.each do |msg|
|
156
|
-
$stderr.puts "#{msg}"
|
157
|
-
end
|
158
|
-
# Now throw a proper error code to the system, while exiting the script
|
159
|
-
abort()
|
160
|
-
end
|
161
|
-
else
|
162
|
-
Dtf::ErrorSystem.raise_error(cmd) # This error here is thrown when not all params are provided
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# This sub-command removes a User from the Testing Framework system
|
167
|
-
#
|
168
|
-
# Required Parameters are:
|
169
|
-
# --user-name [String]
|
170
|
-
#
|
171
|
-
# '--user-name' is the assigned user_name of the User you wish to delete.
|
172
|
-
#
|
173
|
-
# Optional Flags are:
|
174
|
-
# --delete-all|--no-delete-all
|
175
|
-
#
|
176
|
-
# By default this command will delete *all* Verification Suites owned by the deleted user.
|
177
|
-
# The default behaviour is as if the sub-command had been invoked passing the '--delete-all' flag explicitly.
|
178
|
-
#
|
179
|
-
# To delete the user, but *keep* their VS, pass the '--no-delete-all' flag.
|
180
|
-
# This flag will find all Verification Suites owned by the user being deleted, and reassign them
|
181
|
-
# to 'Library Owner' (user_name: library_owner) which is the generic in-house User shipped with DTF.
|
182
|
-
def self.delete_user(cmd, cmd_opts)
|
183
|
-
if [:user_name_given, :delete_all].all? { |sym| cmd_opts.key?(sym) } then
|
184
|
-
# NOTE: :delete_all is 'true' by default. passing '--no-delete-all' sets it to false,
|
185
|
-
# and adds the :delete_all_given key to the cmd_opts hash, set to true.
|
186
|
-
# This means NOT to delete all VSs associated with this user. We delete them by default.
|
187
|
-
if cmd_opts[:delete_all] == false && cmd_opts[:delete_all_given] == true
|
188
|
-
puts "#{cmd} called with '--no-delete-all' set! NOT deleting all owned VSs!"
|
189
|
-
puts "Reassigning VSs to Library. New owner will be \'Library Owner\'"
|
190
|
-
user = User.find_by_user_name(cmd_opts[:user_name])
|
191
|
-
lib_owner = User.find_by_user_name("library_owner")
|
192
|
-
user.verification_suites.all.each do |vs|
|
193
|
-
vs.user_id = lib_owner.id
|
194
|
-
vs.save
|
195
|
-
end
|
196
|
-
User.delete(user)
|
197
|
-
else
|
198
|
-
puts "#{cmd} called with '--delete-all' set or on by default! Deleting all VSs owned by #{cmd_opts[:user_name]}"
|
199
|
-
user = User.find_by_user_name(cmd_opts[:user_name])
|
200
|
-
if ! user.nil? then
|
201
|
-
user.verification_suites.all.each do |vs|
|
202
|
-
VerificationSuite.delete(vs)
|
203
|
-
end
|
204
|
-
if user.verification_suites.empty? then
|
205
|
-
User.delete(user)
|
206
|
-
end
|
207
|
-
else
|
208
|
-
$stderr.puts "ERROR: No user named \'#{cmd_opts[:user_name].to_s}\' found!"
|
209
|
-
abort()
|
210
|
-
end
|
211
|
-
end
|
212
|
-
else
|
213
|
-
Dtf::ErrorSystem.raise_error(cmd)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
# This sub-command generates, adds, and associates a Verification Suite in the Testing Framework system.
|
218
|
-
#
|
219
|
-
# Required Parameters are:
|
220
|
-
# --user-name [String], --name [String]
|
221
|
-
#
|
222
|
-
# '--user-name' is the user_name of the User that should own this Verification Suite.
|
223
|
-
# '--name' is the descriptive name of the Verification Suite.
|
224
|
-
#
|
225
|
-
# Options are:
|
226
|
-
# --description [String]
|
227
|
-
#
|
228
|
-
# This *optional* parameter is for providing a description of the Verification Suite's use.
|
229
|
-
# e.g. --description "RSpec Verification"
|
230
|
-
#
|
231
|
-
def self.create_vs(cmd, cmd_opts)
|
232
|
-
if [:user_name_given, :name_given].all? { |sym| cmd_opts.key?(sym) } then
|
233
|
-
user = User.find_by_user_name(cmd_opts[:user_name])
|
234
|
-
vs = user.verification_suites.create(name: cmd_opts[:name], description: cmd_opts[:description])
|
235
|
-
if vs.persisted? then
|
236
|
-
puts "VS named \'#{cmd_opts[:name]}\' allocated to user \'#{cmd_opts[:user_name]}\'"
|
237
|
-
else
|
238
|
-
$stderr.puts "ERROR: Failed to save Verification Suite. Check DB logfile for errors"
|
239
|
-
abort()
|
240
|
-
end
|
241
|
-
else
|
242
|
-
Dtf::ErrorSystem.raise_error(cmd)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
# This sub-command removes a Verification Suite from the Testing Framework system
|
247
|
-
#
|
248
|
-
# Required Parameters are:
|
249
|
-
# --user-name [String], --id [Integer]
|
250
|
-
#
|
251
|
-
# The '--user-name' parameter is the user_name of the User that owns the Verification Suite you wish to delete
|
252
|
-
# The '--id' parameter is the ID # of the Verification Suite you wish to delete, as provided by @vs.id
|
253
|
-
def self.delete_vs(cmd, cmd_opts)
|
254
|
-
if [:user_name_given, :id_given].all? { |sym| cmd_opts.key?(sym) } then
|
255
|
-
puts "#{cmd} called! Deleting #{cmd_opts[:user_name]}\'s VS with ID \'#{cmd_opts[:id]}\'"
|
256
|
-
user = User.find_by_user_name(cmd_opts[:user_name])
|
257
|
-
vs = user.verification_suites.find(cmd_opts[:id])
|
258
|
-
VerificationSuite.delete(vs)
|
259
|
-
else
|
260
|
-
Dtf::ErrorSystem.raise_error(cmd)
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
end # End of module
|
250
|
+
|
251
|
+
end # End of Dtf module
|
data/lib/dtf/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: Verify sub commands
|
2
|
+
In order to ensure each sub-command works
|
3
|
+
As a User
|
4
|
+
I want to execute each command successfully
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I have dtf installed
|
8
|
+
|
9
|
+
Scenario: Execution of create_user succeeds
|
10
|
+
Given I execute 'create_user'
|
11
|
+
Then I should find 'testuser' in the database
|
12
|
+
|
13
|
+
Scenario: Execution of delete_user succeeds
|
14
|
+
send "I execute 'create_user'"
|
15
|
+
Given I execute 'delete_user'
|
16
|
+
Then I should not find 'testuser' in the database
|
17
|
+
|
18
|
+
Scenario: Execution of create_vs succeeds
|
19
|
+
send "I create 'create_user'"
|
20
|
+
Given I execute 'create_vs'
|
21
|
+
Then I should find a VS in the database
|
22
|
+
|
23
|
+
Scenario: Execution of delete_vs succeeds
|
24
|
+
send "I execute 'create_user'"
|
25
|
+
Given I execute 'delete_vs'
|
26
|
+
Then I should not find a VS in the database
|
data/spec/spec_helper.rb
CHANGED
data/spec/steps/feature_steps.rb
CHANGED
@@ -17,4 +17,76 @@ step "I should see :help_response in the response" do |help_response|
|
|
17
17
|
result = %x[bundle exec dtf #{cmd[0]} -h]
|
18
18
|
result.should include("#{cmd[1]}")
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
21
|
+
|
22
|
+
step "I execute 'create_user'" do
|
23
|
+
@cmd = "create_user"
|
24
|
+
@cmd_opts = {user_name: "testuser",
|
25
|
+
full_name: "My Test User",
|
26
|
+
email_address: "me@example.com",
|
27
|
+
user_name_given: true,
|
28
|
+
full_name_given: true,
|
29
|
+
email_address_given: true,
|
30
|
+
delete_all: true
|
31
|
+
}
|
32
|
+
|
33
|
+
@new_cmd = Dtf::Command.create_cmd(@cmd)
|
34
|
+
@new_cmd.execute(@cmd_opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
step "I should find 'testuser' in the database" do
|
38
|
+
user = User.find_by_user_name('testuser')
|
39
|
+
user.should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
step "I execute 'delete_user'" do
|
43
|
+
send "I execute 'create_user'"
|
44
|
+
end
|
45
|
+
|
46
|
+
step "I should not find 'testuser' in the database" do
|
47
|
+
@cmd = "delete_user"
|
48
|
+
@cmd_opts = { user_name: "testuser",
|
49
|
+
delete_all_given: true,
|
50
|
+
user_name_given: true,
|
51
|
+
delete_all: false
|
52
|
+
}
|
53
|
+
@new_cmd = Dtf::Command.create_cmd(@cmd)
|
54
|
+
@new_cmd.execute(@cmd_opts)
|
55
|
+
end
|
56
|
+
|
57
|
+
step "I execute 'create_vs'" do
|
58
|
+
send "I execute 'create_user'"
|
59
|
+
@cmd = "create_vs"
|
60
|
+
@cmd_opts = {user_name: "testuser",
|
61
|
+
name: "My Test VS",
|
62
|
+
description: "Bogus VS for testing",
|
63
|
+
user_name_given: true,
|
64
|
+
name_given: true,
|
65
|
+
description_given: true
|
66
|
+
}
|
67
|
+
|
68
|
+
@new_cmd = Dtf::Command.create_cmd(@cmd)
|
69
|
+
@new_cmd.execute(@cmd_opts)
|
70
|
+
end
|
71
|
+
|
72
|
+
step "I should find a VS in the database" do
|
73
|
+
user = User.find_by_user_name('testuser')
|
74
|
+
user.verification_suites.should_not be_empty
|
75
|
+
end
|
76
|
+
|
77
|
+
step "I execute 'delete_vs'" do
|
78
|
+
send "I execute 'create_vs'"
|
79
|
+
@cmd = "delete_vs"
|
80
|
+
@cmd_opts = {user_name: "testuser",
|
81
|
+
id: 1,
|
82
|
+
user_name_given: true,
|
83
|
+
id_given: true
|
84
|
+
}
|
85
|
+
@new_cmd = Dtf::Command.create_cmd(@cmd)
|
86
|
+
@new_cmd.execute(@cmd_opts)
|
87
|
+
end
|
88
|
+
|
89
|
+
step "I should not find a VS in the database" do
|
90
|
+
user = User.find_by_user_name('testuser')
|
91
|
+
user.verification_suites.should be_empty
|
92
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -327,6 +327,7 @@ files:
|
|
327
327
|
- lib/tasks/setup.thor
|
328
328
|
- spec/acceptance/create_basic_associations.feature
|
329
329
|
- spec/acceptance/implement_help_system.feature
|
330
|
+
- spec/acceptance/verify_sub_commands.feature
|
330
331
|
- spec/fabricators/analysis_case_fabricator.rb
|
331
332
|
- spec/fabricators/case_test_fabricator.rb
|
332
333
|
- spec/fabricators/user_fabricator.rb
|
@@ -367,6 +368,7 @@ summary: DTF is a modular testing framework. This is the master gem for the DTF
|
|
367
368
|
test_files:
|
368
369
|
- spec/acceptance/create_basic_associations.feature
|
369
370
|
- spec/acceptance/implement_help_system.feature
|
371
|
+
- spec/acceptance/verify_sub_commands.feature
|
370
372
|
- spec/fabricators/analysis_case_fabricator.rb
|
371
373
|
- spec/fabricators/case_test_fabricator.rb
|
372
374
|
- spec/fabricators/user_fabricator.rb
|