Permalink
Browse files

Removed scripts for running ruby tests in favor of aliases/completion

  • Loading branch information...
jferris committed Jan 13, 2011
1 parent 246c719 commit 64051a49deeeb04ba686ad198b97d00106f116cc
Showing with 0 additions and 284 deletions.
  1. +0 −26 cuc
  2. +0 −89 ruby_spec
  3. +0 −96 ruby_test
  4. +0 −73 ruby_tu_rs
View
26 cuc
@@ -1,26 +0,0 @@
-#!/usr/bin/env ruby
-
-args = ARGV.join(' ')
-feature_args, cucumber_args = *(args.split('--').map { |string| string.split(' ') })
-cucumber_args ||= []
-
-cucumber_args += feature_args.map do |arg|
- name, line = *arg.strip.split(':')
- line = ":#{line}" if line
- "features/#{name}.feature#{line}"
-end
-
-script = if File.directory?(".bundle")
- cucumber_args.unshift("exec", "cucumber")
- "bundle"
- elsif File.executable?('script/cucumber')
- 'script/cucumber'
- else
- 'cucumber'
- end
-
-
-ENV['CUCUMBER_FORMAT'] ||= 'pretty'
-
-puts "CUCUMBER_FORMAT=#{ENV['CUCUMBER_FORMAT']} #{script} #{cucumber_args.join(' ')}"
-exec(script, *cucumber_args)
View
@@ -1,89 +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"
- file << ":#{line}" if line
- 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")
- "bundle exec rspec"
- 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,96 +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
-
View
@@ -1,73 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'fileutils'
-
-class TestFinder
- attr_reader :prefix
- def initialize(prefix)
- @prefix = prefix
- end
-
-
- def name_to_file(name, line = nil)
- file = "#{prefix}/#{name}_test.rb"
- file << ":#{line}" if line
- file
- 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)
- 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) }
- puts "Running:\n#{tests.join("\n")}"
- exec("script/spec", *tests)
- end
- end
-
- def list
- puts test_names.sort.join("\n")
- end
-
- private
-
- def force_test_file(test_and_line)
- test, line = test_and_line.split(':')
- if test_files.include?(test)
- test_and_line
- elsif test_names.include?(test)
- name_to_file(test, line)
- else
- raise "No such test: #{test.inspect}"
- end
- end
-end
-
-list = ARGV.delete('-l') || ARGV.delete('--list')
-prefix = ARGV.shift
-prefix = prefix ? "test/#{prefix}" : 'test'
-finder = TestFinder.new(prefix)
-tests = ARGV.dup
-
-if list
- finder.list
-else
- finder.run(tests)
-end
-

0 comments on commit 64051a4

Please sign in to comment.