thor_tasks 0.0.5 → 0.0.6
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/lib/tasks/spec.thor +16 -15
- data/lib/thor_tasks/version.rb +1 -1
- metadata +2 -2
data/lib/tasks/spec.thor
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class Spec < Thor
|
2
2
|
include Thor::Actions
|
3
3
|
|
4
|
+
AVAILABLE_TYPES = ['controllers', 'helpers', 'models', 'requests', 'routing', 'views']
|
5
|
+
|
4
6
|
desc "all", "runs all your specs"
|
5
7
|
method_option :bundle, :type => :boolean, :aliases => "-b"
|
6
8
|
def all
|
@@ -53,30 +55,29 @@ class Spec < Thor
|
|
53
55
|
desc "list [TYPE}]", "lists specs for TYPE, see thor spec:list --help for more info."
|
54
56
|
method_options :help => false
|
55
57
|
def list(name = "*")
|
56
|
-
available_types = [
|
57
|
-
'controllers', 'helpers', 'models', 'requests', 'routing', 'views'
|
58
|
-
]
|
59
58
|
if options[:help]
|
60
59
|
puts "Available types for thor spec:list are"
|
61
|
-
|
60
|
+
AVAILABLE_TYPES.each do |t|
|
62
61
|
puts " #{t}"
|
63
62
|
end
|
64
63
|
puts "Running thor spec:list without specifying a type will list all specs from all types."
|
65
64
|
return
|
66
65
|
end
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
67
|
+
paths = Dir["spec/#{name}/**/"].sort.reject { |p| p if !AVAILABLE_TYPES.include?(p.split("/")[1]) }
|
68
|
+
paths.each do |p|
|
69
|
+
path = p.split("/")
|
70
|
+
l = path.length
|
71
|
+
# the following prints an indented path in a color that is relative to the
|
72
|
+
# levels of indentation
|
73
|
+
print "#{' ' * (l-2)}\x1b[38;5;1#{l-1}m#{path[l-1]}\x1b[0m\n"
|
74
|
+
files = Dir["#{p}*_spec.rb"].sort
|
75
|
+
files.each do |f|
|
76
|
+
spec = File.basename(f, "_spec.rb")
|
77
|
+
spec = spec.rpartition("_")[0] if ['controllers', 'helpers', 'routing'].include? path[1]
|
78
|
+
print "#{' ' * (l-1)}#{spec}\n" # prints the spec with indentation
|
78
79
|
end
|
79
|
-
|
80
|
+
print "\n" unless files.length == 0
|
80
81
|
end
|
81
82
|
end
|
82
83
|
end
|
data/lib/thor_tasks/version.rb
CHANGED