Permalink
Browse files

Remove unused testing helpers

  • Loading branch information...
joshuaclayton committed Feb 27, 2012
1 parent 6e3fe3f commit e519f45a33219fb9ad0778d7c11b88238f5e77dc
Showing with 0 additions and 216 deletions.
  1. +0 −4 aliasrc
  2. +0 −99 bin/ruby_spec
  3. +0 −95 bin/ruby_test
  4. +0 −18 zsh_profile.d/completion.zsh
View
@@ -1,8 +1,4 @@
# ruby/rails
-alias tf="ruby_test functional"
-alias tu="ruby_test unit"
-alias sc="ruby_spec controllers"
-alias sm="ruby_spec models"
alias bes="bundle exec rspec"
alias ber="bundle exec rake"
alias bake="bundle exec rake"
View
@@ -1,99 +0,0 @@
-#!/usr/bin/env ruby
-
-require "fileutils"
-
-class SpecFinder
- attr_reader :prefix
- def initialize(prefix)
- @prefix = prefix
- end
-
- def name_to_file(name, line = nil)
- file = "#{prefix}/#{name}_spec.rb"
- return file unless line
-
- file << if line =~ /^\d+$/
- ":#{line}"
- else
- " -e '#{line}'"
- end
-
- file
- end
-
- def file_to_name(file)
- file.sub(%r{^#{Regexp.escape(prefix)}/}, "").sub(%r{_spec\.rb$}, "")
- end
-
- def spec_files
- @spec_files ||= Dir["#{prefix}/**/*_spec.rb"]
- end
-
- def spec_names
- @spec_names ||= spec_files.collect {|file| file_to_name(file) }
- end
-
- def run(specs)
- if specs.empty?
- if spec_files.empty?
- puts "Nothing to do."
- else
- run(spec_files)
- end
- else
- specs = specs.collect {|spec| force_spec_file(spec) }
- command = command_to_run(specs)
- puts command
- exec command
- end
- end
-
- def list
- puts spec_names.sort.join("\n")
- end
-
- private
-
- def force_spec_file(spec_and_line)
- spec, line = spec_and_line.split(":")
- if spec_files.include?(spec)
- spec_and_line
- elsif spec_names.include?(spec)
- name_to_file(spec, line)
- else
- raise "No such spec: #{spec.inspect}"
- end
- end
-
- def command_to_run(files)
- files_string = files.join(" ")
- "#{script_to_run} #{files_string}"
- end
-
- def script_to_run
- if File.exist?("Gemfile")
- rspec_exec = if File.new("Gemfile").read =~ /rspec.*2\./
- "rspec"
- else
- "spec"
- end
- "bundle exec #{rspec_exec}"
- elsif File.exist?("script/spec")
- "script/spec"
- else
- "spec"
- end
- end
-end
-
-list = ARGV.delete("-l") || ARGV.delete("--list")
-prefix = ARGV.shift
-prefix = prefix ? "spec/#{prefix}" : "spec"
-finder = SpecFinder.new(prefix)
-specs = ARGV.dup
-
-if list
- finder.list
-else
- finder.run(specs)
-end
View
@@ -1,95 +0,0 @@
-#!/usr/bin/env ruby
-
-require "fileutils"
-
-class TestFinder
-
- attr_reader :prefix
-
- def initialize(prefix)
- @prefix = prefix
- end
-
-
- def name_to_file(name)
- "#{prefix}/#{name}_test.rb"
- end
-
- def file_to_name(file)
- file.sub(%r{^#{Regexp.escape(prefix)}/}, "").sub(%r{_test\.rb$}, "")
- end
-
- def test_files
- @test_files ||= Dir["#{prefix}/**/*_test.rb"]
- end
-
- def test_names
- @test_names ||= test_files.collect {|file| file_to_name(file) }
- end
-
- def run(tests, pattern)
- if tests.empty?
- if test_files.empty?
- puts "Nothing to do."
- else
- run(test_files)
- end
- else
- tests = tests.collect {|test| force_test_file(test) }
- command = command_to_run(tests, pattern)
- puts command
- exec command
- end
- end
-
- def list
- puts test_names.sort.join("\n")
- end
-
- private
-
- def force_test_file(test)
- if test_files.include?(test)
- test
- elsif test_names.include?(test)
- name_to_file(test)
- else
- raise "No such test: #{test.inspect}"
- end
- end
-
- def command_to_run(files, pattern)
- files_string = files.inspect
- require_string = "require '#{f}'"
- command_arguments = %w(-Itest -e)
- command_arguments << "#{files_string}.each {|f| #{require_string} }"
- if pattern != ""
- command_arguments << "--" << "-n" << "/#{pattern}/"
- end
- exec("ruby", *command_arguments)
- end
-end
-
-list = ARGV.delete("-l") || ARGV.delete("--list")
-prefix = ARGV.shift
-prefix = prefix ? "test/#{prefix}" : "test"
-finder = TestFinder.new(prefix)
-args = ARGV.dup
-
-if list
- finder.list
-else
- pattern = []
- tests = []
-
- ARGV.each do |arg|
- if pattern.size > 0 || arg =~ /^\//
- pattern << arg.sub(/^\//, "")
- else
- tests << arg
- end
- end
- pattern = pattern.join(" ")
-
- finder.run(tests, pattern)
-end
@@ -4,24 +4,6 @@ setopt prompt_subst
autoload -U compinit
compinit
-# autocompletion for ruby_test
-# works with tu/tf aliases
-_ruby_test() {
- if [[ -n $words[2] ]]; then
- compadd $(ruby_test -l ${words[2]})
- fi
-}
-compdef _ruby_test ruby_test
-
-# autocompletion for ruby_spec
-# works with sm/sc aliases
-_ruby_spec() {
- if [[ -n $words[2] ]]; then
- compadd $(ruby_spec -l ${words[2]})
- fi
-}
-compdef _ruby_spec ruby_spec
-
_grb() {
if [[ -n $(git symbolic-ref HEAD 2> /dev/null) ]]; then
if (( CURRENT == 2 )); then

0 comments on commit e519f45

Please sign in to comment.