mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -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.
This commit is contained in:
parent
c6f8d5c632
commit
144d32e1d6
51 changed files with 277 additions and 456 deletions
|
|
@ -15,16 +15,16 @@ describe Pry::CommandSet do
|
|||
|
||||
describe "[]=" do
|
||||
it "removes a command from the command set" do
|
||||
@set["help"].should.not == nil
|
||||
@set["help"].should_not == nil
|
||||
@set["help"] = nil
|
||||
@set["help"].should == nil
|
||||
lambda { @set.run_command(TOPLEVEL_BINDING, "help") }.should.raise Pry::NoCommandError
|
||||
expect { @set.run_command(TOPLEVEL_BINDING, "help") }.to raise_error Pry::NoCommandError
|
||||
end
|
||||
|
||||
it "replaces a command" do
|
||||
old_help = @set["help"]
|
||||
@set["help"] = @set["pry-version"]
|
||||
@set["help"].should.not == old_help
|
||||
@set["help"].should_not == old_help
|
||||
end
|
||||
|
||||
it "rebinds the command with key" do
|
||||
|
|
@ -33,7 +33,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it "raises a TypeError when command is not a subclass of Pry::Command" do
|
||||
lambda { @set["help"] = "hello" }.should.raise TypeError
|
||||
expect { @set["help"] = "hello" }.to raise_error TypeError
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -67,27 +67,21 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should raise an error when calling an undefined command' do
|
||||
@set.command('foo') {}
|
||||
lambda {
|
||||
@set.run_command @ctx, 'bar'
|
||||
}.should.raise(Pry::NoCommandError)
|
||||
expect { @set.run_command @ctx, 'bar' }.to raise_error Pry::NoCommandError
|
||||
end
|
||||
|
||||
it 'should be able to remove its own commands' do
|
||||
@set.command('foo') {}
|
||||
@set.delete 'foo'
|
||||
|
||||
lambda {
|
||||
@set.run_command @ctx, 'foo'
|
||||
}.should.raise(Pry::NoCommandError)
|
||||
expect { @set.run_command @ctx, 'foo' }.to raise_error Pry::NoCommandError
|
||||
end
|
||||
|
||||
it 'should be able to remove its own commands, by listing name' do
|
||||
@set.command(/^foo1/, 'desc', :listing => 'foo') {}
|
||||
@set.delete 'foo'
|
||||
|
||||
lambda {
|
||||
@set.run_command @ctx, /^foo1/
|
||||
}.should.raise(Pry::NoCommandError)
|
||||
expect { @set.run_command @ctx, /^foo1/ }.to raise_error Pry::NoCommandError
|
||||
end
|
||||
|
||||
it 'should be able to import some commands from other sets' do
|
||||
|
|
@ -103,9 +97,7 @@ describe Pry::CommandSet do
|
|||
@set.run_command @ctx, 'foo'
|
||||
run.should == true
|
||||
|
||||
lambda {
|
||||
@set.run_command @ctx, 'bar'
|
||||
}.should.raise(Pry::NoCommandError)
|
||||
expect { @set.run_command @ctx, 'bar' }.to raise_error Pry::NoCommandError
|
||||
end
|
||||
|
||||
it 'should return command set after import' do
|
||||
|
|
@ -211,7 +203,7 @@ describe Pry::CommandSet do
|
|||
@set['bar'].options[:interpolate].should == @set['foo'].options[:interpolate]
|
||||
|
||||
# however some options should not be inherited
|
||||
@set['bar'].options[:listing].should.not == @set['foo'].options[:listing]
|
||||
@set['bar'].options[:listing].should_not == @set['foo'].options[:listing]
|
||||
@set['bar'].options[:listing].should == "bar"
|
||||
end
|
||||
|
||||
|
|
@ -289,22 +281,19 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should be able to have its own helpers' do
|
||||
@set.command('foo') do
|
||||
should.respond_to :my_helper
|
||||
end
|
||||
|
||||
@set.helpers do
|
||||
def my_helper; end
|
||||
end
|
||||
@set.command('foo') { my_helper }
|
||||
@set.helpers { def my_helper; end }
|
||||
|
||||
@set.run_command(@ctx, 'foo')
|
||||
Pry::Command.subclass('foo', '', {}, Module.new).new({:target => binding}).should.not.respond_to :my_helper
|
||||
Pry::Command.subclass('foo', '', {}, Module.new)
|
||||
.new({:target => binding})
|
||||
.should_not(respond_to :my_helper)
|
||||
end
|
||||
|
||||
it 'should not recreate a new helper module when helpers is called' do
|
||||
@set.command('foo') do
|
||||
should.respond_to :my_helper
|
||||
should.respond_to :my_other_helper
|
||||
my_helper
|
||||
my_other_helper
|
||||
end
|
||||
|
||||
@set.helpers do
|
||||
|
|
@ -326,7 +315,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
@set.import imported_set
|
||||
@set.command('foo') { should.respond_to :imported_helper_method }
|
||||
@set.command('foo') { imported_helper_method }
|
||||
@set.run_command(@ctx, 'foo')
|
||||
end
|
||||
|
||||
|
|
@ -340,7 +329,7 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
@set.import_from imported_set, 'bar'
|
||||
@set.command('foo') { should.respond_to :imported_helper_method }
|
||||
@set.command('foo') { imported_helper_method }
|
||||
@set.run_command(@ctx, 'foo')
|
||||
end
|
||||
|
||||
|
|
@ -358,9 +347,7 @@ describe Pry::CommandSet do
|
|||
@ctx[:command_set] = @set
|
||||
@ctx[:output] = StringIO.new
|
||||
|
||||
lambda {
|
||||
@set.run_command(@ctx, 'help')
|
||||
}.should.not.raise
|
||||
expect { @set.run_command(@ctx, 'help') }.to_not raise_error
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -382,13 +369,13 @@ describe Pry::CommandSet do
|
|||
end
|
||||
|
||||
it 'should raise exception trying to rename non-existent command' do
|
||||
lambda { @set.rename_command('bar', 'foo') }.should.raise ArgumentError
|
||||
expect { @set.rename_command('bar', 'foo') }.to raise_error ArgumentError
|
||||
end
|
||||
|
||||
it 'should make old command name inaccessible' do
|
||||
@set.command('foo') { }
|
||||
@set.rename_command('bar', 'foo')
|
||||
lambda { @set.run_command(@ctx, 'foo') }.should.raise Pry::NoCommandError
|
||||
expect { @set.run_command(@ctx, 'foo') }.to raise_error Pry::NoCommandError
|
||||
end
|
||||
|
||||
it 'should be able to pass in options when renaming command' do
|
||||
|
|
@ -592,9 +579,7 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should not cause argument interpolation' do
|
||||
cmd = @set.command('hello')
|
||||
lambda {
|
||||
@set.valid_command?('hello #{raise "futz"}')
|
||||
}.should.not.raise
|
||||
expect { @set.valid_command?('hello #{raise "futz"}') }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue