thor_tasks 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,3 +5,41 @@ Add the gem to your Gemfile:
5
5
  Run bundle, and install the tasks into your app:
6
6
  bundle
7
7
  rails g thor_tasks:install
8
+ You can see a list of all the available tasks by running:
9
+ thor list
10
+
11
+ == Spork tasks
12
+
13
+ These tasks allow you to start, stop, and restart Spork as a background process
14
+ from a Bash console.
15
+
16
+ The tasks are:
17
+ thor spork:start
18
+ thor spork:restart
19
+ thor spork:stop
20
+
21
+ Since spork is being forked as a background process, once you start it, it will
22
+ take some time to load. During the time that Spork is loading, it will output
23
+ some text to the terminal. It's best just to wait until it's completely loaded
24
+ to continue.
25
+
26
+ == Spec tasks
27
+
28
+ The following tasks are helpers for running your RSpecs:
29
+ thor spec:all
30
+ thor spec:controller [NAME]
31
+ thor spec:helper [NAME]
32
+ thor spec:model [NAME]
33
+ thor spec:request [NAME]
34
+ thor spec:routing [NAME]
35
+ thor spec:view [CONTROLLER] [ACTION]
36
+ thor spec:list [TYPE]
37
+
38
+ Running any spec task without any options will run all the specs for that
39
+ category, with the exception of the list spec, which will list all the available
40
+ spec files. For the spec:view task, you can specify a controller, and an action.
41
+ If you specify a controller without an action, all the actions for that view
42
+ will run.
43
+
44
+ Running any spec with the option --bundle or -b will execute that task using
45
+ bundle exec.
data/lib/tasks/spec.thor CHANGED
@@ -1,34 +1,53 @@
1
1
  class Spec < Thor
2
2
  include Thor::Actions
3
3
 
4
+ desc "all", "runs all your specs"
5
+ method_option :bundle, :type => :boolean, :aliases => "-b"
6
+ def all
7
+ b = options[:bundle] ? "bundle exec" : ""
8
+ run "rspec spec"
9
+ end
10
+
4
11
  desc "controller [NAME]", "runs rspec for controllers"
12
+ method_option :bundle, :type => :boolean, :aliases => "-b"
5
13
  def controller(name="*")
6
- run "rspec spec/controllers/#{name}_controller_spec.rb"
14
+ b = options[:bundle] ? "bundle exec" : ""
15
+ run "#{b} rspec spec/controllers/#{name}_controller_spec.rb"
7
16
  end
8
17
 
9
18
  desc "helper [NAME]", "runs rspec for helpers"
19
+ method_option :bundle, :type => :boolean, :aliases => "-b"
10
20
  def helper(name = "*")
11
- run "rspec spec/helpers/#{name}_helper_spec.rb"
21
+ b = options[:bundle] ? "bundle exec" : ""
22
+ run "#{b} rspec spec/helpers/#{name}_helper_spec.rb"
12
23
  end
13
24
 
14
25
  desc "model [NAME]", "runs rspec for models"
26
+ method_option :bundle, :type => :boolean, :aliases => "-b"
15
27
  def model(name = "*")
16
- run "rspec spec/models/#{name}_spec.rb"
28
+ b = options[:bundle] ? "bundle exec" : ""
29
+ run "#{b} rspec spec/models/#{name}_spec.rb"
17
30
  end
18
31
 
19
32
  desc "request [NAME]", "runs rspec for requests"
33
+ method_option :bundle, :type => :boolean, :aliases => "-b"
20
34
  def request(name = "*")
21
- run "rspec spec/requests/#{name}_spec.rb"
35
+ b = options[:bundle] ? "bundle exec" : ""
36
+ run "#{b} rspec spec/requests/#{name}_spec.rb"
22
37
  end
23
38
 
24
39
  desc "routing [NAME]", "runs rspec for routing"
40
+ method_option :bundle, :type => :boolean, :aliases => "-b"
25
41
  def routing(name = "*")
26
- run "rspec spec/routing/#{name}_spec.rb"
42
+ b = options[:bundle] ? "bundle exec" : ""
43
+ run "#{b} rspec spec/routing/#{name}_spec.rb"
27
44
  end
28
45
 
29
46
  desc "view [CONTROLLER] [ACTION]", "runs rspec for views"
47
+ method_option :bundle, :type => :boolean, :aliases => "-b"
30
48
  def view(controller = "*", action = "*")
31
- run "rspec spec/views/#{controller}/#{action}*_spec.rb"
49
+ b = options[:bundle] ? "bundle exec" : ""
50
+ run "#{b} rspec spec/views/#{controller}/#{action}*_spec.rb"
32
51
  end
33
52
 
34
53
  desc "list [TYPE}]", "lists specs for TYPE, see thor spec:list --help for more info."
@@ -46,10 +65,18 @@ class Spec < Thor
46
65
  return
47
66
  end
48
67
 
68
+ lastType = ""
69
+ currentType = ""
49
70
  Dir["spec/#{name}/*_spec.rb"].each do |f|
50
- f = f.split("_")[0]
51
- f = name == "*" ? f.partition("/")[2] : f.gsub("spec/#{name}/", "")
52
- puts " #{f}"
71
+ spec = File.basename(f, "_spec.rb")
72
+ dir = File.dirname(f).split("/")
73
+ currentType = dir[dir.length-1]
74
+ spec = spec.rpartition("_")[0] if ['controllers', 'helpers', 'routing'].include? currentType
75
+ if currentType != lastType
76
+ print "\n\x1b[38;5;10m#{currentType}\x1b[0m\n"
77
+ lastType = currentType
78
+ end
79
+ puts " #{spec}"
53
80
  end
54
81
  end
55
82
  end
@@ -1,3 +1,3 @@
1
1
  module ThorTasks
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Spec do
4
+ it { should respond_to :all }
4
5
  it { should respond_to :controller }
5
6
  it { should respond_to :helper }
6
7
  it { should respond_to :model }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Haynes