2014-03-14 00:31:24 -04:00
|
|
|
require_relative 'helper'
|
2011-12-02 01:55:48 -05:00
|
|
|
|
|
|
|
describe Pry::WrappedModule do
|
|
|
|
|
|
|
|
describe "#initialize" do
|
|
|
|
it "should raise an exception when a non-module is passed" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
expect { Pry::WrappedModule.new(nil) }.to raise_error ArgumentError
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-23 04:14:10 -04:00
|
|
|
describe "candidates" do
|
2014-08-15 14:51:51 -04:00
|
|
|
class Host
|
|
|
|
%w(spec/fixtures/candidate_helper1.rb
|
|
|
|
spec/fixtures/candidate_helper2.rb).each do |file|
|
|
|
|
binding.eval File.read(file), file, 1
|
|
|
|
end
|
2012-06-23 04:14:10 -04:00
|
|
|
|
2014-08-15 14:51:51 -04:00
|
|
|
# rank 2
|
|
|
|
class CandidateTest
|
|
|
|
def test6
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
2014-08-15 14:51:51 -04:00
|
|
|
end
|
2012-06-24 12:04:43 -04:00
|
|
|
|
2014-08-15 14:51:51 -04:00
|
|
|
class PitifullyBlank
|
|
|
|
DEFAULT_TEST = CandidateTest
|
|
|
|
end
|
2013-04-07 16:24:28 -04:00
|
|
|
|
2014-08-15 14:51:51 -04:00
|
|
|
FOREVER_ALONE_LINE = __LINE__ + 1
|
|
|
|
class ForeverAlone
|
|
|
|
class DoublyNested
|
|
|
|
# nested docs
|
|
|
|
class TriplyNested
|
|
|
|
def nested_method
|
2012-12-27 16:53:51 -05:00
|
|
|
end
|
|
|
|
end
|
2012-06-24 12:04:43 -04:00
|
|
|
end
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "number_of_candidates" do
|
|
|
|
it 'should return the correct number of candidates' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(Host::CandidateTest).number_of_candidates.should eq 3
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
2012-06-24 12:04:43 -04:00
|
|
|
|
2013-04-07 16:24:28 -04:00
|
|
|
it 'should return 0 candidates for a class with no nested modules or methods' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(Host::PitifullyBlank).number_of_candidates.should eq 0
|
2013-04-07 16:24:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return 1 candidate for a class with a nested module with methods' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(Host::ForeverAlone).number_of_candidates.should eq 1
|
2012-06-24 12:04:43 -04:00
|
|
|
end
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "ordering of candidates" do
|
|
|
|
it 'should return class with largest number of methods as primary candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(0).file.should =~ /helper1/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return class with second largest number of methods as second ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(1).file.should =~ /helper2/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return class with third largest number of methods as third ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(2).file.should =~ /#{__FILE__}/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should raise when trying to access non-existent candidate' do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
expect { Pry::WrappedModule(Host::CandidateTest).candidate(3) }.to raise_error Pry::CommandError
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-24 12:04:43 -04:00
|
|
|
describe "source_location" do
|
|
|
|
it 'should return primary candidates source_location by default' do
|
|
|
|
wm = Pry::WrappedModule(Host::CandidateTest)
|
2015-01-23 04:30:41 -05:00
|
|
|
wm.source_location.should eq wm.candidate(0).source_location
|
2012-06-24 12:04:43 -04:00
|
|
|
end
|
|
|
|
|
2013-04-07 16:24:28 -04:00
|
|
|
it 'should return the location of the outer module if an inner module has methods' do
|
|
|
|
wm = Pry::WrappedModule(Host::ForeverAlone)
|
2015-01-22 16:52:20 -05:00
|
|
|
File.expand_path(wm.source_location.first).should eq File.expand_path(__FILE__)
|
2015-01-23 04:30:41 -05:00
|
|
|
wm.source_location.last.should eq Host::FOREVER_ALONE_LINE
|
2013-04-07 16:24:28 -04:00
|
|
|
end
|
|
|
|
|
2012-06-24 12:04:43 -04:00
|
|
|
it 'should return nil if no source_location can be found' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(Host::PitifullyBlank).source_location.should eq nil
|
2012-06-24 12:04:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-23 04:14:10 -04:00
|
|
|
describe "source" do
|
|
|
|
it 'should return primary candidates source by default' do
|
|
|
|
wm = Pry::WrappedModule(Host::CandidateTest)
|
2015-01-23 04:30:41 -05:00
|
|
|
wm.source.should eq wm.candidate(0).source
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return source for highest ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(0).source.should =~ /test1/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return source for second ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(1).source.should =~ /test4/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return source for third ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(2).source.should =~ /test6/
|
|
|
|
end
|
2012-12-27 16:53:51 -05:00
|
|
|
|
|
|
|
it 'should return source for deeply nested class' do
|
|
|
|
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).source.should =~ /nested_method/
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).source.lines.count.should eq 4
|
2012-12-27 16:53:51 -05:00
|
|
|
end
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "doc" do
|
|
|
|
it 'should return primary candidates doc by default' do
|
|
|
|
wm = Pry::WrappedModule(Host::CandidateTest)
|
2015-01-23 04:30:41 -05:00
|
|
|
wm.doc.should eq wm.candidate(0).doc
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return doc for highest ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(0).doc.should =~ /rank 0/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return doc for second ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(1).doc.should =~ /rank 1/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return doc for third ranked candidate' do
|
|
|
|
Pry::WrappedModule(Host::CandidateTest).candidate(2).doc.should =~ /rank 2/
|
|
|
|
end
|
2012-12-27 16:53:51 -05:00
|
|
|
|
2012-12-27 17:20:32 -05:00
|
|
|
it 'should return docs for deeply nested class' do
|
2012-12-27 16:53:51 -05:00
|
|
|
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).doc.should =~ /nested docs/
|
|
|
|
end
|
2012-06-23 04:14:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-02 01:55:48 -05:00
|
|
|
describe ".method_prefix" do
|
|
|
|
before do
|
|
|
|
Foo = Class.new
|
|
|
|
@foo = Foo.new
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Object.remove_const(:Foo)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return Foo# for normal classes" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(Foo).method_prefix.should eq "Foo#"
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return Bar# for modules" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(Kernel).method_prefix.should eq "Kernel#"
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return Foo. for singleton classes of classes" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(class << Foo; self; end).method_prefix.should eq "Foo."
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
example "of singleton classes of objects" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(class << @foo; self; end).method_prefix.should eq "self."
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
2011-12-19 02:04:14 -05:00
|
|
|
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
example "of anonymous classes should not be empty" do
|
2011-12-19 02:04:14 -05:00
|
|
|
Pry::WrappedModule.new(Class.new).method_prefix.should =~ /#<Class:.*>#/
|
|
|
|
end
|
|
|
|
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
example "of singleton classes of anonymous classes should not be empty" do
|
2011-12-19 02:04:14 -05:00
|
|
|
Pry::WrappedModule.new(class << Class.new; self; end).method_prefix.should =~ /#<Class:.*>./
|
|
|
|
end
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe ".singleton_class?" do
|
|
|
|
it "should be true for singleton classes" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(class << ""; self; end).singleton_class?.should eq true
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false for normal classes" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(Class.new).singleton_class?.should eq false
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false for modules" do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule.new(Module.new).singleton_class?.should eq false
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe ".singleton_instance" do
|
|
|
|
it "should raise an exception when called on a non-singleton-class" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
expect { Pry::WrappedModule.new(Class).singleton_instance }.to raise_error ArgumentError
|
2011-12-02 01:55:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return the attached object" do
|
2015-01-22 16:52:20 -05:00
|
|
|
Pry::WrappedModule.new(class << "hi"; self; end).singleton_instance.should eq "hi"
|
2011-12-02 01:55:48 -05:00
|
|
|
Pry::WrappedModule.new(class << Object; self; end).singleton_instance.should.equal?(Object)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-11 20:45:54 -05:00
|
|
|
describe ".super" do
|
|
|
|
describe "receiver is a class" do
|
|
|
|
before do
|
|
|
|
@a = Class.new
|
|
|
|
@m = Module.new
|
|
|
|
@b = Class.new(@a)
|
|
|
|
@b.send(:include, @m)
|
|
|
|
@c = Class.new(@b)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return superclass for a wrapped class' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(@c).super.wrapped.should eq @b
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return nth superclass for a wrapped class' do
|
|
|
|
d = Class.new(@c)
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(d).super(2).wrapped.should eq @b
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should ignore modules when retrieving nth superclass' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(@c).super(2).wrapped.should eq @a
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return nil when no nth superclass exists' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(@c).super(10).should eq nil
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return self when .super(0) is used' do
|
|
|
|
c = Pry::WrappedModule(@c)
|
2015-01-23 04:30:41 -05:00
|
|
|
c.super(0).should eq c
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "receiver is a module" do
|
|
|
|
before do
|
|
|
|
@m1 = Module.new
|
|
|
|
@m2 = Module.new.tap { |v| v.send(:include, @m1) }
|
|
|
|
@m3 = Module.new.tap { |v| v.send(:include, @m2) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not ignore modules when retrieving supers' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(@m3).super.wrapped.should eq @m2
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should retrieve nth super' do
|
2015-01-23 04:30:41 -05:00
|
|
|
Pry::WrappedModule(@m3).super(2).wrapped.should eq @m1
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return self when .super(0) is used' do
|
|
|
|
m = Pry::WrappedModule(@m1)
|
2015-01-23 04:30:41 -05:00
|
|
|
m.super(0).should eq m
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-12-19 06:01:45 -05:00
|
|
|
|
|
|
|
describe ".from_str" do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
before do
|
|
|
|
class Namespace
|
2015-01-22 16:52:20 -05:00
|
|
|
remove_const :Value if defined? Value
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
Value = Class.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-19 06:01:45 -05:00
|
|
|
it 'should lookup a constant' do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
m = Pry::WrappedModule.from_str("Namespace::Value", binding)
|
2015-01-23 04:30:41 -05:00
|
|
|
m.wrapped.should eq Namespace::Value
|
2012-12-19 06:01:45 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should lookup a local' do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
local = Namespace::Value
|
2012-12-19 06:01:45 -05:00
|
|
|
m = Pry::WrappedModule.from_str("local", binding)
|
2015-01-23 04:30:41 -05:00
|
|
|
m.wrapped.should eq local
|
2012-12-19 06:01:45 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should lookup an ivar' do
|
Switch test suite to RSpec
Removes Bacon and Mocha
Reasoning explained in this comment: https://github.com/pry/pry/issues/277#issuecomment-51708712
Mostly this went smoothly. There were a few errors that I fixed along
the way, e.g. tests that were failing but for various reasons still
passed. Should have documented them, but didn't think about it until
very near the end. But generaly, I remember 2 reasons this would happen:
`lambda { raise "omg" }.should.raise(RuntimeError, /not-omg/)` will pass
because the second argument is ignored by Bacon. And `1.should == 2`
will return false instead of raising an error when it is not in an it
block (e.g. if stuck in a describe block, that would just return false)
The only one that I felt unsure about was spec/helpers/table_spec.rb
`Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'`
This is wrong, but was not failing because it was in a describe block
instead of an it block. In reality, it returns `"head: ing\n"`,
I updated the test to reflect this, though I don't know for sure
this is the right thing to do
This will fail on master until https://github.com/pry/pry/pull/1281 is merged.
This makes https://github.com/pry/pry/pull/1278 unnecessary.
2014-08-10 18:26:47 -04:00
|
|
|
@ivar = Namespace::Value
|
2012-12-19 06:01:45 -05:00
|
|
|
m = Pry::WrappedModule.from_str("@ivar", binding)
|
2015-01-23 04:30:41 -05:00
|
|
|
m.wrapped.should eq Namespace::Value
|
2012-12-19 06:01:45 -05:00
|
|
|
end
|
|
|
|
end
|
2012-12-11 20:45:54 -05:00
|
|
|
end
|