1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Merge remote-tracking branch 'rking/massive-test-renaming'

This commit is contained in:
Conrad Irwin 2012-11-18 01:31:19 -08:00
commit 74b3fe6d47
54 changed files with 26 additions and 21 deletions

View file

@ -3,14 +3,16 @@ require 'guard/guard'
module ::Guard module ::Guard
class Bacon < Guard class Bacon < Guard
def run_all def run_all
system "bundle exec bacon -Itest -q -a" system "rake spec"
puts puts
true true
end end
def run_spec(path) def run_spec(path)
if File.exists?(path) if File.exists?(path)
@success &&= system "bundle exec bacon -Itest -q #{path}" cmd = "bundle exec bacon -Ispec -q #{path}"
puts cmd
@success &&= system cmd
puts puts
end end
end end
@ -33,32 +35,32 @@ module ::Guard
end end
guard 'bacon' do guard 'bacon' do
def deduce_test_from(token) def deduce_spec_from(token)
"test/test_#{token}.rb" "spec/#{token}_spec.rb"
end end
Dir['lib/pry/*.rb'].each do |rb| Dir['lib/pry/*.rb'].each do |rb|
rb[%r(lib/pry/(.+)\.rb$)] rb[%r(lib/pry/(.+)\.rb$)]
test_rb = deduce_test_from $1 spec_rb = deduce_spec_from $1
if File.exists?(test_rb) if File.exists?(spec_rb)
watch(rb) { test_rb } watch(rb) { spec_rb }
else else
exempt = %w( exempt = %w(
commands commands
version version
).map {|token| deduce_test_from token} ).map {|token| deduce_spec_from token}
puts 'Missing ' + test_rb if puts 'Missing ' + spec_rb if
ENV['WANT_TEST_COMPLAINTS'] and not exempt.include?(test_rb) ENV['WANT_SPEC_COMPLAINTS'] and not exempt.include?(spec_rb)
end end
end end
watch(%r{^lib/pry/commands/([^.]+)\.rb}) { |m| "test/test_commands/test_#{m[1]}.rb" } watch(%r{^lib/pry/commands/([^.]+)\.rb}) { |m| "spec/commands/#{m[1]}_spec.rb" }
# If no such mapping exists, just run all of them # If no such mapping exists, just run all of them
watch(%r{^lib/}) { :all } watch(%r{^lib/}) { :all }
# If we modified one test file, run it # If we modified one spec file, run it
watch(%r{^test.*/test_.+\.rb$}) watch(%r{^spec/.+\.rb$})
end end
# vim:ft=ruby # vim:ft=ruby

View file

@ -18,7 +18,7 @@ def apply_spec_defaults(s)
s.homepage = 'http://pry.github.com' s.homepage = 'http://pry.github.com'
s.executables = ['pry'] s.executables = ['pry']
s.files = `git ls-files`.split("\n") s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n")
s.add_dependency('coderay', '~> 1.0.5') s.add_dependency('coderay', '~> 1.0.5')
s.add_dependency('slop', ['~> 3.3.1']) s.add_dependency('slop', ['~> 3.3.1'])
s.add_dependency('method_source','~> 0.8') s.add_dependency('method_source','~> 0.8')
@ -47,8 +47,11 @@ task :default => [:test]
desc "Run tests" desc "Run tests"
task :test do task :test do
check_dependencies unless ENV['SKIP_DEP_CHECK'] check_dependencies unless ENV['SKIP_DEP_CHECK']
sh "bacon -Itest -rubygems -a -q" all_specs = Dir['spec/**/*_spec.rb']
all_specs.shuffle! if all_specs.respond_to? :shuffle!
sh "bacon -Ispec -rubygems -a -q #{all_specs.join ' '}"
end end
task :spec => :test
desc "Run pry" desc "Run pry"
task :pry do task :pry do

View file

@ -36,13 +36,13 @@ describe Pry::Code do
end end
should 'check for files relative to origin pwd' do should 'check for files relative to origin pwd' do
Dir.chdir('test') do |f| Dir.chdir('spec') do |f|
Pry::Code.from_file('test/' + File.basename(__FILE__)).code_type.should == :ruby Pry::Code.from_file('spec/' + File.basename(__FILE__)).code_type.should == :ruby
end end
end end
should 'find files that are relative to the current working directory' do should 'find files that are relative to the current working directory' do
Dir.chdir('test') do |f| Dir.chdir('spec') do |f|
Pry::Code.from_file(File.basename(__FILE__)).code_type.should == :ruby Pry::Code.from_file(File.basename(__FILE__)).code_type.should == :ruby
end end
end end

View file

@ -56,7 +56,7 @@ describe "whereami" do
it 'should show description and correct code when __LINE__ and __FILE__ are outside @method.source_location' do it 'should show description and correct code when __LINE__ and __FILE__ are outside @method.source_location' do
class Cor class Cor
def blimey! def blimey!
eval <<-END, binding, "test/test_commands/example.erb", 1 eval <<-END, binding, "spec/cmd/example.erb", 1
pry_eval(binding, 'whereami') pry_eval(binding, 'whereami')
END END
end end
@ -70,7 +70,7 @@ describe "whereami" do
it 'should show description and correct code when @method.source_location would raise an error' do it 'should show description and correct code when @method.source_location would raise an error' do
class Cor class Cor
eval <<-END, binding, "test/test_commands/example.erb", 1 eval <<-END, binding, "spec/cmd/example.erb", 1
def blimey! def blimey!
pry_eval(binding, 'whereami') pry_eval(binding, 'whereami')
end end

View file

@ -276,7 +276,7 @@ OUTPUT
end end
describe "nesting" do describe "nesting" do
test = File.read("test/example_nesting.rb") test = File.read("spec/example_nesting.rb")
test.lines.each_with_index do |line, i| test.lines.each_with_index do |line, i|
result = line.split("#").last.strip result = line.split("#").last.strip