mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#absolute_path' do
|
||||
before :each do
|
||||
@frame = ThreadBacktraceLocationSpecs.locations[0]
|
||||
end
|
||||
|
||||
it 'returns the absolute path of the call frame' do
|
||||
@frame.absolute_path.should == File.realpath(__FILE__)
|
||||
end
|
||||
end
|
12
spec/ruby/core/thread/backtrace/location/base_label_spec.rb
Normal file
12
spec/ruby/core/thread/backtrace/location/base_label_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#base_label' do
|
||||
before :each do
|
||||
@frame = ThreadBacktraceLocationSpecs.locations[0]
|
||||
end
|
||||
|
||||
it 'returns the base label of the call frame' do
|
||||
@frame.base_label.should == '<top (required)>'
|
||||
end
|
||||
end
|
17
spec/ruby/core/thread/backtrace/location/fixtures/classes.rb
Normal file
17
spec/ruby/core/thread/backtrace/location/fixtures/classes.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module ThreadBacktraceLocationSpecs
|
||||
MODULE_LOCATION = caller_locations(0) rescue nil
|
||||
|
||||
def self.locations
|
||||
caller_locations
|
||||
end
|
||||
|
||||
def self.method_location
|
||||
caller_locations(0)
|
||||
end
|
||||
|
||||
def self.block_location
|
||||
1.times do
|
||||
return caller_locations(0)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
def example
|
||||
caller_locations[0].path
|
||||
end
|
||||
|
||||
print example
|
13
spec/ruby/core/thread/backtrace/location/inspect_spec.rb
Normal file
13
spec/ruby/core/thread/backtrace/location/inspect_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#inspect' do
|
||||
before :each do
|
||||
@frame = ThreadBacktraceLocationSpecs.locations[0]
|
||||
@line = __LINE__ - 1
|
||||
end
|
||||
|
||||
it 'converts the call frame to a String' do
|
||||
@frame.inspect.should include("#{__FILE__}:#{@line}:in ")
|
||||
end
|
||||
end
|
20
spec/ruby/core/thread/backtrace/location/label_spec.rb
Normal file
20
spec/ruby/core/thread/backtrace/location/label_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#label' do
|
||||
it 'returns the base label of the call frame' do
|
||||
ThreadBacktraceLocationSpecs.locations[0].label.should include('<top (required)>')
|
||||
end
|
||||
|
||||
it 'returns the method name for a method location' do
|
||||
ThreadBacktraceLocationSpecs.method_location[0].label.should == "method_location"
|
||||
end
|
||||
|
||||
it 'returns the block name for a block location' do
|
||||
ThreadBacktraceLocationSpecs.block_location[0].label.should == "block in block_location"
|
||||
end
|
||||
|
||||
it 'returns the module name for a module location' do
|
||||
ThreadBacktraceLocationSpecs::MODULE_LOCATION[0].label.should include "ThreadBacktraceLocationSpecs"
|
||||
end
|
||||
end
|
13
spec/ruby/core/thread/backtrace/location/lineno_spec.rb
Normal file
13
spec/ruby/core/thread/backtrace/location/lineno_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#lineno' do
|
||||
before :each do
|
||||
@frame = ThreadBacktraceLocationSpecs.locations[0]
|
||||
@line = __LINE__ - 1
|
||||
end
|
||||
|
||||
it 'returns the absolute path of the call frame' do
|
||||
@frame.lineno.should == @line
|
||||
end
|
||||
end
|
91
spec/ruby/core/thread/backtrace/location/path_spec.rb
Normal file
91
spec/ruby/core/thread/backtrace/location/path_spec.rb
Normal file
|
@ -0,0 +1,91 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#path' do
|
||||
context 'outside a main script' do
|
||||
it 'returns an absolute path' do
|
||||
frame = ThreadBacktraceLocationSpecs.locations[0]
|
||||
|
||||
frame.path.should == __FILE__
|
||||
end
|
||||
end
|
||||
|
||||
context 'in a main script' do
|
||||
before do
|
||||
@script = fixture(__FILE__, 'main.rb')
|
||||
end
|
||||
|
||||
context 'when the script is in the working directory' do
|
||||
before do
|
||||
@directory = File.dirname(@script)
|
||||
end
|
||||
|
||||
context 'when using a relative script path' do
|
||||
it 'returns a path relative to the working directory' do
|
||||
Dir.chdir(@directory) {
|
||||
ruby_exe('main.rb')
|
||||
}.should == 'main.rb'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when using an absolute script path' do
|
||||
it 'returns an absolute path' do
|
||||
Dir.chdir(@directory) {
|
||||
ruby_exe(@script)
|
||||
}.should == @script
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the script is in a sub directory of the working directory' do
|
||||
context 'when using a relative script path' do
|
||||
it 'returns a path relative to the working directory' do
|
||||
path = 'fixtures/main.rb'
|
||||
directory = File.dirname(__FILE__)
|
||||
Dir.chdir(directory) {
|
||||
ruby_exe(path)
|
||||
}.should == path
|
||||
end
|
||||
end
|
||||
|
||||
context 'when using an absolute script path' do
|
||||
it 'returns an absolute path' do
|
||||
ruby_exe(@script).should == @script
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the script is outside of the working directory' do
|
||||
before do
|
||||
@parent_dir = tmp('path_outside_pwd')
|
||||
@sub_dir = File.join(@parent_dir, 'sub')
|
||||
@script = File.join(@parent_dir, 'main.rb')
|
||||
source = fixture(__FILE__, 'main.rb')
|
||||
|
||||
mkdir_p(@sub_dir)
|
||||
|
||||
cp(source, @script)
|
||||
end
|
||||
|
||||
after do
|
||||
rm_r(@script)
|
||||
rm_r(@sub_dir)
|
||||
rm_r(@parent_dir)
|
||||
end
|
||||
|
||||
context 'when using a relative script path' do
|
||||
it 'returns a path relative to the working directory' do
|
||||
Dir.chdir(@sub_dir) {
|
||||
ruby_exe('../main.rb')
|
||||
}.should == '../main.rb'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when using an absolute path' do
|
||||
it 'returns an absolute path' do
|
||||
ruby_exe(@script).should == @script
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
spec/ruby/core/thread/backtrace/location/to_s_spec.rb
Normal file
13
spec/ruby/core/thread/backtrace/location/to_s_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
describe 'Thread::Backtrace::Location#to_s' do
|
||||
before :each do
|
||||
@frame = ThreadBacktraceLocationSpecs.locations[0]
|
||||
@line = __LINE__ - 1
|
||||
end
|
||||
|
||||
it 'converts the call frame to a String' do
|
||||
@frame.to_s.should include("#{__FILE__}:#{@line}:in ")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue