summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Fitzgerald <rwfitzge@gmail.com>2014-03-13 23:11:19 -0700
committerRyan Fitzgerald <rwfitzge@gmail.com>2014-03-13 23:28:52 -0700
commitdcdc4776b6c009e835494f462c4016a7d930f2b1 (patch)
treec2b359c3b3010c0f8a9c5ff18467b3f464275e05
parent82dc33445cd66d8ffeed371c857253887e54e671 (diff)
downloadpry-minitest-bacon.tar.gz
Switch from bacon to minitest-baconminitest-bacon
This gives us more flexibility to use the other assertion types built into Minitest, use Minitest plugins, etc. The process of setting it up also revealed some order dependencies and other weirdness in the specs.
-rw-r--r--Gemfile3
-rw-r--r--Guardfile62
-rw-r--r--Rakefile29
-rw-r--r--lib/pry/history.rb1
-rw-r--r--pry.gemspec2
-rw-r--r--spec/cli_spec.rb14
-rw-r--r--spec/code_object_spec.rb40
-rw-r--r--spec/command_integration_spec.rb28
-rw-r--r--spec/command_set_spec.rb36
-rw-r--r--spec/command_spec.rb8
-rw-r--r--spec/commands/edit_spec.rb18
-rw-r--r--spec/commands/exit_all_spec.rb12
-rw-r--r--spec/commands/exit_spec.rb6
-rw-r--r--spec/commands/find_method_spec.rb34
-rw-r--r--spec/commands/gem_list_spec.rb4
-rw-r--r--spec/commands/show_source_spec.rb31
-rw-r--r--spec/commands/whereami_spec.rb25
-rw-r--r--spec/completion_spec.rb4
-rw-r--r--spec/control_d_handler_spec.rb4
-rw-r--r--spec/exception_whitelist_spec.rb2
-rw-r--r--spec/helper.rb26
-rw-r--r--spec/helpers/table_spec.rb16
-rw-r--r--spec/history_spec.rb2
-rw-r--r--spec/hooks_spec.rb28
-rw-r--r--spec/pager_spec.rb20
-rw-r--r--spec/prompt_spec.rb17
-rw-r--r--spec/pry_spec.rb18
-rw-r--r--spec/pryrc_spec.rb6
-rw-r--r--spec/spec_helpers/bacon.rb86
-rw-r--r--spec/spec_helpers/repl_tester.rb2
-rw-r--r--spec/syntax_checking_spec.rb4
-rw-r--r--spec/wrapped_module_spec.rb82
32 files changed, 264 insertions, 406 deletions
diff --git a/Gemfile b/Gemfile
index bc55a05d..ba0d7883 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,11 +1,8 @@
source 'https://rubygems.org'
gemspec
-# For Guard
group :development do
gem 'jist'
- gem 'rb-inotify', :require => 'false'
- gem 'rb-fsevent', :require => 'false'
end
platform :rbx do
diff --git a/Guardfile b/Guardfile
deleted file mode 100644
index f12cea6f..00000000
--- a/Guardfile
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'guard/guard'
-
-module ::Guard
- class Bacon < Guard
- def run_all
- system "rake spec"
- puts
- true
- end
-
- def run_on_changes(paths)
- paths.delete('some_lib')
- puts "Running: #{paths.join ' '}"
- if paths.size.zero?
- warn 'Running all tests'
- system 'rake recspec'
- else
- paths.each do |path|
- warn "Running #{path}"
- system "rake spec run=#{path}" or return
- warn "\e[32;1mNice!!\e[0m Now running all specs, just to be sure."
- run_all
- end
- end
- end
- end
-end
-
-guard 'bacon' do
- def deduce_spec_from(token)
- %W(
- spec/#{token}_spec.rb
- spec/pry_#{token}_spec.rb
- spec/commands/#{token}_spec.rb
- ).each do |e|
- return e if File.exists? e
- end
- nil
- end
-
- Dir['lib/pry/**/*.rb'].each do |rb|
- rb[%r(lib/pry/(.+)\.rb$)]
- spec_rb = deduce_spec_from($1)
- if spec_rb
- # run as 'bundle exec guard -d' to see these.
- ::Guard::UI.debug "'#{rb}' maps to '#{spec_rb}'"
- else
- ::Guard::UI.debug "No map, so run all for: '#{rb}'"
- end
- next unless spec_rb
- watch(rb) do |m| spec_rb end
- end
-
- watch(%r{^lib/.+\.rb$}) do |m|
- return if deduce_spec_from(m[0])
- 'some_lib'
- end
-
- watch(%r{^spec/.+\.rb$}) do |m| m end
-end
-
-# vim:ft=ruby
diff --git a/Rakefile b/Rakefile
index d00a9369..55c32b12 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,4 +1,5 @@
require 'rake/clean'
+require 'rake/testtask'
require 'rubygems/package_task'
$:.unshift 'lib'
@@ -18,32 +19,14 @@ rescue Bundler::GemNotFound
raise RuntimeError, "You're missing one or more required gems. Run `bundle install` first."
end
-desc "Set up and run tests"
-task :default => [:test]
-
-def run_specs paths
- quiet = ENV['VERBOSE'] ? '' : '-q'
- exec "bacon -Ispec -rubygems #{quiet} #{paths.join ' '}"
-end
-
-desc "Run tests"
-task :test do
+Rake::TestTask.new do |t|
check_dependencies unless ENV['SKIP_DEP_CHECK']
- paths =
- if explicit_list = ENV['run']
- explicit_list.split(',')
- else
- Dir['spec/**/*_spec.rb'].shuffle!
- end
- run_specs paths
+ t.libs.concat %w(spec)
+ t.pattern = "spec/**/*_spec.rb"
+ t.verbose = true
end
task :spec => :test
-
-task :recspec do
- all = Dir['spec/**/*_spec.rb'].sort_by{|path| File.mtime(path)}.reverse
- warn "Running all, sorting by mtime: #{all[0..2].join(' ')} ...etc."
- run_specs all
-end
+task :default => :test
desc "Run pry (you can pass arguments using _ in place of -)"
task :pry do
diff --git a/lib/pry/history.rb b/lib/pry/history.rb
index 1bef4a23..e0845b07 100644
--- a/lib/pry/history.rb
+++ b/lib/pry/history.rb
@@ -58,6 +58,7 @@ class Pry
def clear
@clearer.call
@history = []
+ @original_lines = 0
end
# @return [Fixnum] The number of lines in history.
diff --git a/pry.gemspec b/pry.gemspec
index 4919b58e..f1d5e119 100644
--- a/pry.gemspec
+++ b/pry.gemspec
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'mocha', '~> 1.0'
s.add_development_dependency 'simplecov', '~> 0.8'
+ s.add_development_dependency 'minitest', '~> 5.0'
+ s.add_development_dependency 'minitest-bacon', '~> 1.0'
# TODO: make this a plain dependency:
s.add_development_dependency 'bond', '~> 0.5'
end
diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb
index 0f6f88cf..e8ddb126 100644
--- a/spec/cli_spec.rb
+++ b/spec/cli_spec.rb
@@ -17,7 +17,7 @@ describe Pry::Hooks do
# irrelevant
end
end.parse_options
- ARGV.include?('-v').should == false
+ ARGV.include?('-v').should.be_false
end
end
@@ -31,7 +31,7 @@ describe Pry::Hooks do
end
end.parse_options(["--optiontest"])
- run.should == true
+ run.should.be_true
end
it "should be able to add multiple options" do
@@ -48,8 +48,8 @@ describe Pry::Hooks do
end
end.parse_options(["--optiontest", "--optiontest2"])
- run.should.be.true
- run2.should.be.true
+ run.should.be_true
+ run2.should.be_true
end
end
@@ -64,7 +64,7 @@ describe Pry::Hooks do
run = true if opts.present?(:optiontest)
end.parse_options(["--optiontest"])
- run.should == true
+ run.should.be_true
end
it "should be able to process multiple options" do
@@ -80,8 +80,8 @@ describe Pry::Hooks do
run2 = true if opts.present?(:optiontest2)
end.parse_options(["--optiontest", "--optiontest2"])
- run.should == true
- run2.should == true
+ run.should.be_true
+ run2.should.be_true
end
end
diff --git a/spec/code_object_spec.rb b/spec/code_object_spec.rb
index fde0c9d9..9d23ffaf 100644
--- a/spec/code_object_spec.rb
+++ b/spec/code_object_spec.rb
@@ -24,13 +24,13 @@ describe Pry::CodeObject do
it 'should lookup methods' do
m = Pry::CodeObject.lookup("@obj.ziggy", @p)
- m.is_a?(Pry::Method).should == true
+ m.is_a?(Pry::Method).should.be_true
m.name.to_sym.should == :ziggy
end
it 'should lookup modules' do
m = Pry::CodeObject.lookup("ClassyWassy", @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.source.should =~ /piggy/
end
@@ -38,7 +38,7 @@ describe Pry::CodeObject do
my_proc = proc { :hello }
@p.binding_stack = [binding]
m = Pry::CodeObject.lookup("my_proc", @p)
- m.is_a?(Pry::Method).should == true
+ m.is_a?(Pry::Method).should.be_true
m.source.should =~ /hello/
end
@@ -53,7 +53,7 @@ describe Pry::CodeObject do
"lobster"
end
m = Pry::CodeObject.lookup("jeremy-jones", @p)
- (m <= Pry::Command).should == true
+ (m <= Pry::Command).should.be_true
m.source.should =~ /lobster/
end
@@ -75,7 +75,7 @@ describe Pry::CodeObject do
it 'should return Pry::ClassCommand class when looking up class command' do
Pry.commands.add_command(LobsterLady)
m = Pry::CodeObject.lookup("lobster-lady", @p)
- (m <= Pry::ClassCommand).should == true
+ (m <= Pry::ClassCommand).should.be_true
m.source.should =~ /class LobsterLady/
Pry.commands.delete("lobster-lady")
end
@@ -83,7 +83,7 @@ describe Pry::CodeObject do
it 'should return Pry::WrappedModule when looking up command class directly (as a class, not as a command)' do
Pry.commands.add_command(LobsterLady)
m = Pry::CodeObject.lookup("LobsterLady", @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.source.should =~ /class LobsterLady/
Pry.commands.delete("lobster-lady")
end
@@ -94,7 +94,7 @@ describe Pry::CodeObject do
"lobster"
end
m = Pry::CodeObject.lookup("jeremy-baby", @p)
- (m <= Pry::Command).should == true
+ (m <= Pry::Command).should.be_true
m.source.should =~ /lobster/
end
@@ -113,7 +113,7 @@ describe Pry::CodeObject do
@p.binding_stack = [binding]
m = Pry::CodeObject.lookup("o#princess_bubblegum", @p)
- m.is_a?(Pry::Method).should == true
+ m.is_a?(Pry::Method).should.be_true
m.source.should =~ /mathematic!/
end
@@ -125,7 +125,7 @@ describe Pry::CodeObject do
end
@p.binding_stack = [binding]
m = Pry::CodeObject.lookup("o.finn", @p)
- m.is_a?(Pry::Method).should == true
+ m.is_a?(Pry::Method).should.be_true
m.source.should =~ /4 realzies/
end
@@ -133,7 +133,7 @@ describe Pry::CodeObject do
moddy = ClassyWassy.new
@p.binding_stack = [binding]
m = Pry::CodeObject.lookup("moddy", @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.source.should =~ /piggy/
end
@@ -148,7 +148,7 @@ describe Pry::CodeObject do
["", nil].each do |v|
@p.binding_stack = [@b1]
m = Pry::CodeObject.lookup(v, @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.name.should =~ /ClassyWassy/
end
end
@@ -157,7 +157,7 @@ describe Pry::CodeObject do
["", nil].each do |v|
@p.binding_stack = [@b2]
m = Pry::CodeObject.lookup(v, @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.name.should =~ /ClassyWassy/
end
end
@@ -170,7 +170,7 @@ describe Pry::CodeObject do
["", nil].each do |v|
@p.binding_stack = [b]
m = Pry::CodeObject.lookup(v, @p)
- m.is_a?(Pry::Method).should == true
+ m.is_a?(Pry::Method).should.be_true
m.name.should =~ /piggy/
end
end
@@ -193,13 +193,13 @@ describe Pry::CodeObject do
it 'should lookup original class with :super => 0' do
m = Pry::CodeObject.lookup("CuteSubclass", @p, :super => 0)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.wrapped.should == CuteSubclass
end
it 'should lookup immediate super class with :super => 1' do
m = Pry::CodeObject.lookup("CuteSubclass", @p, :super => 1)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.wrapped.should == MyClassyWassy
end
@@ -246,19 +246,19 @@ describe Pry::CodeObject do
it 'should look up classes before methods (at top-level)' do
m = Pry::CodeObject.lookup("ClassyWassy", @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.source.should =~ /piggy/
end
it 'should look up methods before classes when ending in () (at top-level)' do
m = Pry::CodeObject.lookup("ClassyWassy()", @p)
- m.is_a?(Pry::Method).should == true
+ m.is_a?(Pry::Method).should.be_true
m.source.should =~ /ducky/
end
it 'should look up classes before methods when namespaced' do
m = Pry::CodeObject.lookup("ClassyWassy::Puff", @p)
- m.is_a?(Pry::WrappedModule).should == true
+ m.is_a?(Pry::WrappedModule).should.be_true
m.source.should =~ /tiggy/
end
@@ -267,7 +267,7 @@ describe Pry::CodeObject do
b.eval("piggy = Puff.new")
@p.binding_stack = [b]
o = Pry::CodeObject.lookup("piggy", @p)
- o.is_a?(Pry::WrappedModule).should == true
+ o.is_a?(Pry::WrappedModule).should.be_true
end
# actually locals are never looked up (via co.default_lookup) when they're classes, it
@@ -276,7 +276,7 @@ describe Pry::CodeObject do
c = ClassyWassy
@p.binding_stack = [binding]
o = Pry::CodeObject.lookup("c", @p)
- o.is_a?(Pry::WrappedModule).should == true
+ o.is_a?(Pry::WrappedModule).should.be_true
o.wrapped.should == ClassyWassy
end
end
diff --git a/spec/command_integration_spec.rb b/spec/command_integration_spec.rb
index f6c05c3e..2d206419 100644
--- a/spec/command_integration_spec.rb
+++ b/spec/command_integration_spec.rb
@@ -409,7 +409,7 @@ describe "commands" do
end
end
- pry_tester(:commands => klass).eval("hello\n").empty?.should == true
+ pry_tester(:commands => klass).eval("hello\n").empty?.should.be_true
end
it 'a command (with :keep_retval => false) that replaces eval_string with a valid expression should not have the expression value suppressed' do
@@ -473,10 +473,10 @@ describe "commands" do
end
end
- klass.to_hash.include?("nesting").should == true
- klass.to_hash.include?("jump-to").should == true
- klass.to_hash.include?("cd").should == true
- klass.to_hash.include?("v").should == true
+ klass.to_hash.include?("nesting").should.be_true
+ klass.to_hash.include?("jump-to").should.be_true
+ klass.to_hash.include?("cd").should.be_true
+ klass.to_hash.include?("v").should.be_true
end
it 'should change description of a command using desc' do
@@ -513,8 +513,8 @@ describe "commands" do
import_from Pry::Commands, "ls", "jump-to"
end
- klass.to_hash.include?("ls").should == true
- klass.to_hash.include?("jump-to").should == true
+ klass.to_hash.include?("ls").should.be_true
+ klass.to_hash.include?("jump-to").should.be_true
end
it 'should delete some inherited commands when using delete method' do
@@ -527,13 +527,13 @@ describe "commands" do
end
commands = klass.to_hash
- commands.include?("nesting").should == true
- commands.include?("jump-to").should == true
- commands.include?("cd").should == true
- commands.include?("v").should == true
- commands.include?("show-doc").should == false
- commands.include?("show-method").should == false
- commands.include?("ls").should == false
+ commands.include?("nesting").should.be_true
+ commands.include?("jump-to").should.be_true
+ commands.include?("cd").should.be_true
+ commands.include?("v").should.be_true
+ commands.include?("show-doc").should.be_false
+ commands.include?("show-method").should.be_false
+ commands.include?("ls").should.be_false
end
it 'should override some inherited commands' do
diff --git a/spec/command_set_spec.rb b/spec/command_set_spec.rb
index ebd4963b..76948f5a 100644
--- a/spec/command_set_spec.rb
+++ b/spec/command_set_spec.rb
@@ -44,7 +44,7 @@ describe Pry::CommandSet do
end
@set.run_command @ctx, 'foo'
- run.should == true
+ run.should.be_true
end
it 'should pass arguments of the command to the block' do
@@ -101,7 +101,7 @@ describe Pry::CommandSet do
@set.import_from(other_set, 'foo')
@set.run_command @ctx, 'foo'
- run.should == true
+ run.should.be_true
lambda {
@set.run_command @ctx, 'bar'
@@ -140,7 +140,7 @@ describe Pry::CommandSet do
@set.import_from(other_set, 'foo')
@set.run_command @ctx, /^foo1/
- run.should == true
+ run.should.be_true
end
it 'should be able to import a whole set' do
@@ -163,7 +163,7 @@ describe Pry::CommandSet do
@set.command('foo') { run = true }
Pry::CommandSet.new(@set).run_command @ctx, 'foo'
- run.should == true
+ run.should.be_true
end
it 'should set the descriptions of commands' do
@@ -181,7 +181,7 @@ describe Pry::CommandSet do
@set['bar'].description.should == 'Alias for `foo`'
@set.run_command @ctx, 'bar'
- run.should == true
+ run.should.be_true
end
it "should be able to alias command with command_prefix" do
@@ -224,7 +224,7 @@ describe Pry::CommandSet do
@set['bar'].description.should == "tobina"
@set.run_command @ctx, 'bar'
- run.should == true
+ run.should.be_true
end
it "should be able to alias a command by its invocation line" do
@@ -236,7 +236,7 @@ describe Pry::CommandSet do
@set['bar'].description.should == 'Alias for `foo1`'
@set.run_command @ctx, 'bar'
- run.should == true
+ run.should.be_true
end
it "should be able to specify options when creating alias" do
@@ -370,7 +370,7 @@ describe Pry::CommandSet do
@set.command('foo') { run = true }
@set.rename_command('bar', 'foo')
@set.run_command(@ctx, 'bar')
- run.should == true
+ run.should.be_true
end
it 'should accept listing name when renaming a command' do
@@ -378,7 +378,7 @@ describe Pry::CommandSet do
@set.command('foo', "", :listing => 'love') { run = true }
@set.rename_command('bar', 'love')
@set.run_command(@ctx, 'bar')
- run.should == true
+ run.should.be_true
end
it 'should raise exception trying to rename non-existent command' do
@@ -398,7 +398,7 @@ describe Pry::CommandSet do
@set.rename_command('bar', 'foo', :description => desc, :listing => listing, :keep_retval => true)
@set['bar'].description.should == desc
@set['bar'].options[:listing].should == listing
- @set['bar'].options[:keep_retval].should == true
+ @set['bar'].options[:keep_retval].should.be_true
end
end
@@ -583,11 +583,11 @@ describe Pry::CommandSet do
describe '.valid_command?' do
it 'should be true for commands that can be found' do
cmd = @set.command('archchancellor')
- @set.valid_command?('archchancellor of_the?(:University)').should == true
+ @set.valid_command?('archchancellor of_the?(:University)').should.be_true
end
it 'should be false for commands that can\'' do
- @set.valid_command?('def monkey(ape)').should == false
+ @set.valid_command?('def monkey(ape)').should.be_false
end
it 'should not cause argument interpolation' do
@@ -602,8 +602,8 @@ describe Pry::CommandSet do
it 'should return Result.new(false) if there is no matching command' do
result = @set.process_line('1 + 42')
- result.command?.should == false
- result.void_command?.should == false
+ result.command?.should.be_false
+ result.void_command?.should.be_false
result.retval.should == nil
end
@@ -613,8 +613,8 @@ describe Pry::CommandSet do
end
result = @set.process_line('mrs-cake')
- result.command?.should == true
- result.void_command?.should == true
+ result.command?.should.be_true
+ result.void_command?.should.be_true
result.retval.should == Pry::Command::VOID_VALUE
end
@@ -624,8 +624,8 @@ describe Pry::CommandSet do
end
result = @set.process_line('magrat')
- result.command?.should == true
- result.void_command?.should == false
+ result.command?.should.be_true
+ result.void_command?.should.be_false
result.retval.should == 42
end
diff --git a/spec/command_spec.rb b/spec/command_spec.rb
index 2e07cdb3..7d214592 100644
--- a/spec/command_spec.rb
+++ b/spec/command_spec.rb
@@ -234,7 +234,7 @@ describe "Pry::Command" do
command_options :listing => 'number-one'
end
- cmd.command_options[:shellwords].should == false
+ cmd.command_options[:shellwords].should.be_false
cmd.command_options[:listing].should == 'number-one'
end
@@ -246,7 +246,7 @@ describe "Pry::Command" do
def process
opts.fetch_command(:blahblah).should == nil
- opts.fetch_command(:yell).present?.should == true
+ opts.fetch_command(:yell).present?.should.be_true
end
end
@@ -263,8 +263,8 @@ describe "Pry::Command" do
def process
args.should == ['papa']
- opts.fetch_command(:yell).present?.should == true
- opts.fetch_command(:yell).person?.should == true
+ opts.fetch_command(:yell).present?.should.be_true
+ opts.fetch_command(:yell).person?.should.be_true
end
end
diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb
index 34f8f64f..d5e5cea6 100644
--- a/spec/commands/edit_spec.rb
+++ b/spec/commands/edit_spec.rb
@@ -65,7 +65,7 @@ describe "edit" do
it "should not delete the file!" do
pry_eval 'edit Rakefile'
- File.exist?(@file).should == true
+ File.exist?(@file).should.be_true
end
it "works with files that contain blanks in their names" do
@@ -88,11 +88,11 @@ describe "edit" do
nil
}
pry_eval "edit #@tf_path"
- Pad.required.should == true
+ Pad.required.should.be_true
end
end
- describe do
+ describe "with a counter" do
before do
Pad.counter = 0
Pry.config.editor = lambda { |file, line|
@@ -144,7 +144,7 @@ describe "edit" do
end
end
- describe do
+ describe "when invoking an editor proc" do
before do
@reloading = nil
Pry.config.editor = lambda do |file, line, reloading|
@@ -155,9 +155,9 @@ describe "edit" do
it "should pass the editor a reloading arg" do
pry_eval 'edit lib/pry.rb'
- @reloading.should == true
+ @reloading.should.be_true
pry_eval 'edit -n lib/pry.rb'
- @reloading.should == false
+ @reloading.should.be_false
end
end
end
@@ -670,7 +670,7 @@ describe "edit" do
pry_eval 'edit -p X#c'
- Pry::Method.from_str("X#c").alias?.should == true
+ Pry::Method.from_str("X#c").alias?.should.be_true
X.new.b.should == :kinda
X.new.c.should == :kindaaa
@@ -689,9 +689,9 @@ describe "edit" do
it "should pass the editor a reloading arg" do
pry_eval 'edit X.x'
- @reloading.should == true
+ @reloading.should.be_true
pry_eval 'edit -n X.x'
- @reloading.should == false
+ @reloading.should.be_false
end
end
end
diff --git a/spec/commands/exit_all_spec.rb b/spec/commands/exit_all_spec.rb
index 7a771c93..1c53c84c 100644
--- a/spec/commands/exit_all_spec.rb
+++ b/spec/commands/exit_all_spec.rb
@@ -4,24 +4,24 @@ describe "exit-all" do
before { @pry = Pry.new }
it "should break out of the repl and return nil" do
- @pry.eval("exit-all").should.be.false
+ @pry.eval("exit-all").should.be_false
@pry.exit_value.should.be.nil
end
it "should break out of the repl wth a user specified value" do
- @pry.eval("exit-all 'message'").should.be.false
+ @pry.eval("exit-all 'message'").should.be_false
@pry.exit_value.should == "message"
end
it "should break out of the repl even if multiple bindings still on stack" do
- ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be.true }
- @pry.eval("exit-all 'message'").should.be.false
+ ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be_true }
+ @pry.eval("exit-all 'message'").should.be_false
@pry.exit_value.should == "message"
end
it "should have empty binding_stack after breaking out of the repl" do
- ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be.true }
- @pry.eval("exit-all").should.be.false
+ ["cd 1", "cd 2"].each { |line| @pry.eval(line).should.be_true }
+ @pry.eval("exit-all").should.be_false
@pry.binding_stack.should.be.empty
end
end
diff --git a/spec/commands/exit_spec.rb b/spec/commands/exit_spec.rb
index 8cd75876..d6d0ccbc 100644
--- a/spec/commands/exit_spec.rb
+++ b/spec/commands/exit_spec.rb
@@ -11,18 +11,18 @@ describe "exit" do
end
it "should break out of the repl when binding_stack has only one binding" do
- @pry.eval("exit").should.be.false
+ @pry.eval("exit").should.be_false
@pry.exit_value.should.be.nil
end
it "should break out of the repl and return user-given value" do
- @pry.eval("exit :john").should.be.false
+ @pry.eval("exit :john").should.be_false
@pry.exit_value.should == :john
end
it "should break out of the repl even after an exception" do
@pry.eval "exit = 42"
@pry.output.string.should =~ /^SyntaxError/
- @pry.eval("exit").should.be.false
+ @pry.eval("exit").should.be_false
end
end
diff --git a/spec/commands/find_method_spec.rb b/spec/commands/find_method_spec.rb
index a00e8b90..a579cc71 100644
--- a/spec/commands/find_method_spec.rb
+++ b/spec/commands/find_method_spec.rb
@@ -1,21 +1,27 @@
require_relative '../helper'
-MyKlass = Class.new do
- def hello
- "timothy"
- end
- def goodbye
- "jenny"
- end
- def tea_tim?
- "timothy"
+describe "find-method" do
+ before do
+ class MyKlass
+ def hello
+ "timothy"
+ end
+ def goodbye
+ "jenny"
+ end
+ def tea_tim?
+ "timothy"
+ end
+ def tea_time?
+ "polly"
+ end
+ end
end
- def tea_time?
- "polly"
+
+ after do
+ Object.remove_const :MyKlass
end
-end
-describe "find-method" do
describe "find matching methods by name regex (-n option)" do
it "should find a method by regex" do
pry_eval("find-method hell MyKlass").should =~
@@ -59,5 +65,3 @@ describe "find-method" do
pry_eval('find-method tea_time\? MyKlass').should =~ good
end
end
-
-Object.remove_const(:MyKlass)
diff --git a/spec/commands/gem_list_spec.rb b/spec/commands/gem_list_spec.rb
index cef5c745..11ce6c6d 100644
--- a/spec/commands/gem_list_spec.rb
+++ b/spec/commands/gem_list_spec.rb
@@ -10,13 +10,13 @@ describe "gem-list" do
it 'should work arglessly' do
list = pry_eval('gem-list')
list.should =~ /slop \(/
- list.should =~ /bacon \(/
+ list.should =~ /minitest \(/
end
it 'should find arg' do
prylist = pry_eval('gem-list slop')
prylist.should =~ /slop \(/
- prylist.should.not =~ /bacon/
+ prylist.should.not =~ /minitest/
end
it 'should return non-results as silence' do
diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb
index db34a68f..e465fbe9 100644
--- a/spec/commands/show_source_spec.rb
+++ b/spec/commands/show_source_spec.rb
@@ -301,7 +301,7 @@ describe "show-source" do
end
end
- class ShowSourceTestClass<ShowSourceTestSuperClass
+ class ShowSourceTestClass < ShowSourceTestSuperClass
def alpha
end
end
@@ -374,26 +374,26 @@ describe "show-source" do
end
end
- before do
- pry_eval unindent(<<-EOS)
- class Dog
- def woof
+ describe "in REPL" do
+ before do
+ pry_eval unindent(<<-EOS)
+ class Dog
+ def woof
+ end
end
- end
- class TobinaMyDog < Dog
- def woof
+ class TobinaMyDog < Dog
+ def woof
+ end
end
+ EOS
end
- EOS
- end
- after do
- Object.remove_const :Dog
- Object.remove_const :TobinaMyDog
- end
+ after do
+ Object.remove_const :Dog
+ Object.remove_const :TobinaMyDog
+ end
- describe "in REPL" do
it 'should find class defined in repl' do
pry_eval('show-source TobinaMyDog').should =~ /class TobinaMyDog/
end
@@ -404,7 +404,6 @@ describe "show-source" do
end
it 'should lookup module name with respect to current context' do
-
constant_scope(:AlphaClass, :BetaClass) do
class BetaClass
def alpha
diff --git a/spec/commands/whereami_spec.rb b/spec/commands/whereami_spec.rb
index f19f49d0..2f4dd298 100644
--- a/spec/commands/whereami_spec.rb
+++ b/spec/commands/whereami_spec.rb
@@ -202,24 +202,29 @@ describe "whereami" do
out.should.not =~ /\=\>/
end
end
+
Cor.new.blimey!
- Object.remove_const(:Cor)
+ Object.remove_const :Cor
end
it 'should use Pry.config.default_window_size for window size when outside a method context' do
old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
- :litella
- :pig
- out = pry_eval(binding, 'whereami')
- :punk
- :sanders
- out.should.not =~ /:litella/
- out.should =~ /:pig/
- out.should =~ /:punk/
- out.should.not =~ /:sanders/
+ class TemporaryClass
+ :litella
+ :pig
+ out = pry_eval(binding, 'whereami')
+ :punk
+ :sanders
+
+ out.should.not =~ /:litella/
+ out.should =~ /:pig/
+ out.should =~ /:punk/
+ out.should.not =~ /:sanders/
+ end
Pry.config.default_window_size = old_size
+ Object.remove_const :TemporaryClass
end
it "should work at the top level" do
diff --git a/spec/completion_spec.rb b/spec/completion_spec.rb
index 27425e90..c7f19628 100644
--- a/spec/completion_spec.rb
+++ b/spec/completion_spec.rb
@@ -60,11 +60,11 @@ describe Pry::InputCompleter do
# check to see if variables are in scope
object.instance_variables.
map { |v| v.to_sym }.
- include?(:'@name').should == true
+ include?(:'@name').should.be_true
object.class.class_variables.
map { |v| v.to_sym }.
- include?(:'@@number').should == true
+ include?(:'@@number').should.be_true
# Complete instance variables.
b = Pry.binding_for(object)
diff --git a/spec/control_d_handler_spec.rb b/spec/control_d_handler_spec.rb
index 1c83776d..63b7c7ac 100644
--- a/spec/control_d_handler_spec.rb
+++ b/spec/control_d_handler_spec.rb
@@ -21,7 +21,7 @@ describe Pry::DEFAULT_CONTROL_D_HANDLER do
it 'should break out of a REPL loop' do
instance = Pry.new
instance.binding_stack.should.not.be.empty
- instance.eval(nil).should.be.false
+ instance.eval(nil).should.be_false
instance.binding_stack.should.be.empty
end
end
@@ -31,7 +31,7 @@ describe Pry::DEFAULT_CONTROL_D_HANDLER do
t = pry_tester
t.eval "cd Object.new"
t.eval("_pry_.binding_stack.size").should == 2
- t.eval("_pry_.eval(nil)").should.be.true
+ t.eval("_pry_.eval(nil)").should.be_true
t.eval("_pry_.binding_stack.size").should == 1
end
diff --git a/spec/exception_whitelist_spec.rb b/spec/exception_whitelist_spec.rb
index 414abbb7..8019203e 100644
--- a/spec/exception_whitelist_spec.rb
+++ b/spec/exception_whitelist_spec.rb
@@ -6,7 +6,7 @@ describe "Pry.config.exception_whitelist" do
end
it 'should rescue all exceptions NOT specified on whitelist' do
- Pry.config.exception_whitelist.include?(NameError).should == false
+ Pry.config.exception_whitelist.include?(NameError).should.be_false
lambda { Pry.start(self, :input => StringIO.new("raise NameError\nexit"), :output => @str_output) }.should.not.raise NameError
end
diff --git a/spec/helper.rb b/spec/helper.rb
index 92b5f0f4..960d6719 100644
--- a/spec/helper.rb
+++ b/spec/helper.rb
@@ -1,10 +1,4 @@
require "bundler/setup"
-require 'mocha/api'
-require "ostruct"
-require 'pry/test/helper'
-require_relative 'spec_helpers/bacon'
-require_relative 'spec_helpers/mock_pry'
-require_relative 'spec_helpers/repl_tester'
if ENV["COVERAGE"]
require "simplecov"
@@ -16,11 +10,31 @@ unless Object.const_defined? 'Pry'
require 'pry'
end
+require 'mocha/api'
+require 'ostruct'
+require 'pry/test/helper'
+require 'minitest/autorun'
+require 'minitest/spec'
+require 'minitest/bacon'
+require 'minitest/pride'
+require_relative 'spec_helpers/mock_pry'
+require_relative 'spec_helpers/repl_tester'
+
class Module
public :remove_const
public :remove_method
end
+class Minitest::Spec
+ extend PryTestHelpers
+ include PryTestHelpers
+
+ def setup
+ Pry.toplevel_binding = nil
+ super
+ end
+end
+
# turn warnings off (esp for Pry::Hooks which will generate warnings
# in tests)
$VERBOSE = nil
diff --git a/spec/helpers/table_spec.rb b/spec/helpers/table_spec.rb
index 5b8dbc92..d84798d2 100644
--- a/spec/helpers/table_spec.rb
+++ b/spec/helpers/table_spec.rb
@@ -3,21 +3,21 @@ require_relative '../helper'
describe 'Formatting Table' do
it 'knows about colorized fitting' do
t = Pry::Helpers::Table.new %w(hihi), :column_count => 1
- t.fits_on_line?(4).should == true
+ t.fits_on_line?(4).should.be_true
t.items = []
- t.fits_on_line?(4).should == true
+ t.fits_on_line?(4).should.be_true
t.items = %w(hi hi)
- t.fits_on_line?(4).should == true
+ t.fits_on_line?(4).should.be_true
t.column_count = 2
- t.fits_on_line?(4).should == false
+ t.fits_on_line?(4).should.be_false
t.items = %w(
a ccc
bb dddd
).sort
- t.fits_on_line?(8).should == true
- t.fits_on_line?(7).should == false
+ t.fits_on_line?(8).should.be_true
+ t.fits_on_line?(7).should.be_false
end
describe 'formatting - should order downward and wrap to columns' do
@@ -99,7 +99,7 @@ asfadsssaaad fasfaafdssd s
end
end
- describe 'decide between one-line or indented output' do
- Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == 'head: ing'
+ it 'decides between one-line or indented output' do
+ Pry::Helpers.tablify_or_one_line('head', %w(ing)).should == "head: ing\n"
end
end
diff --git a/spec/history_spec.rb b/spec/history_spec.rb
index 0a7c66dc..56fd41d5 100644
--- a/spec/history_spec.rb
+++ b/spec/history_spec.rb
@@ -63,7 +63,7 @@ describe Pry do
file = fh.to_a
file.length.should == 3
- file.any? { |a| a =~ /athos/ }.should == true
+ file.any? { |a| a =~ /athos/ }.should.be_true
}
end
end
diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb
index 7b4ffb37..e21f4854 100644
--- a/spec/hooks_spec.rb
+++ b/spec/hooks_spec.rb
@@ -9,7 +9,7 @@ describe Pry::Hooks do
it 'should not execute hook while adding it' do
run = false
@hooks.add_hook(:test_hook, :my_name) { run = true }
- run.should == false
+ run.should.be_false
end
it 'should not allow adding of a hook with a duplicate name' do
@@ -34,8 +34,8 @@ describe Pry::Hooks do
@hooks.add_hook(:test_hook, :my_name, proc { foo = true }) { run = true }
@hooks.hook_count(:test_hook).should == 1
@hooks.exec_hook(:test_hook)
- run.should == true
- foo.should == false
+ run.should.be_true
+ foo.should.be_false
end
it 'should raise if not given a block or any other object' do
@@ -180,8 +180,8 @@ describe Pry::Hooks do
@hooks.add_hook(:test_hook, :my_name) { run = true }
@hooks.add_hook(:test_hook, :my_name2) { fun = true }
@hooks.get_hook(:test_hook, :my_name).call
- run.should == true
- fun.should == false
+ run.should.be_true
+ fun.should.be_false
end
it 'should return nil if hook does not exist' do
@@ -228,7 +228,7 @@ describe Pry::Hooks do
run = false
@hooks.add_hook(:test_hook, :my_name) { run = true }
@hooks.delete_hook(:test_hook, :my_name).call
- run.should == true
+ run.should.be_true
end
it 'should return nil if hook does not exist' do
@@ -241,14 +241,14 @@ describe Pry::Hooks do
run = false
@hooks.add_hook(:test_hook, :my_name) { run = true }
@hooks.exec_hook(:test_hook)
- run.should == true
+ run.should.be_true
end
it 'should execute proc hook' do
run = false
@hooks.add_hook(:test_hook, :my_name, proc { run = true })
@hooks.exec_hook(:test_hook)
- run.should == true
+ run.should.be_true
end
it 'should execute a general callable hook' do
@@ -262,7 +262,7 @@ describe Pry::Hooks do
@hooks.add_hook(:test_hook, :my_name, callable)
@hooks.exec_hook(:test_hook)
- callable.test_var.should == true
+ callable.test_var.should.be_true
end
it 'should execute all hooks for an event if more than one is defined' do
@@ -271,8 +271,8 @@ describe Pry::Hooks do
@hooks.add_hook(:test_hook, :my_name1) { y = true }
@hooks.add_hook(:test_hook, :my_name2) { x = true }
@hooks.exec_hook(:test_hook)
- x.should == true
- y.should == true
+ x.should.be_true
+ y.should.be_true
end
it 'should execute hooks in order' do
@@ -332,7 +332,7 @@ describe Pry::Hooks do
Pry.start 5, :hello => :baby
end
- b.is_a?(Binding).should == true
+ b.is_a?(Binding).should.be_true
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
@@ -360,7 +360,7 @@ describe Pry::Hooks do
Pry.start binding, :hello => :baby
end
- o.value.should == true
+ o.value.should.be_true
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
@@ -386,7 +386,7 @@ describe Pry::Hooks do
# ensure that an exception really was raised and it broke out
# of the repl
- exception.is_a?(o.great_escape).should == true
+ exception.is_a?(o.great_escape).should.be_true
# check that after_session hook ran
array.should == nil
diff --git a/spec/pager_spec.rb b/spec/pager_spec.rb
index 5e64b2cc..d9fc72de 100644
--- a/spec/pager_spec.rb
+++ b/spec/pager_spec.rb
@@ -27,40 +27,40 @@ describe "Pry::Pager" do
it "records short lines that don't add up to a page" do
9.times { record_short_line }
- @pt.page?.should.be.false
+ @pt.page?.should.be_false
end
it "records short lines that do add up to a page" do
10.times { record_short_line }
- @pt.page?.should.be.true
+ @pt.page?.should.be_true
end
it "treats a long line as taking up more than one row" do
4.times { record_long_line }
- @pt.page?.should.be.false
+ @pt.page?.should.be_false
record_long_line
- @pt.page?.should.be.true
+ @pt.page?.should.be_true
end
it "records a string with an embedded newline" do
3.times { record_multiline }
- @pt.page?.should.be.false
+ @pt.page?.should.be_false
record_short_line
- @pt.page?.should.be.true
+ @pt.page?.should.be_true
end
it "doesn't count a line until it ends" do
12.times { record_string_without_newline }
- @pt.page?.should.be.false
+ @pt.page?.should.be_false
record_short_line
- @pt.page?.should.be.true
+ @pt.page?.should.be_true
end
it "doesn't count ansi color codes towards length" do
9.times { record_string_with_color_codes }
- @pt.page?.should.be.false
+ @pt.page?.should.be_false
record_string_with_color_codes
- @pt.page?.should.be.true
+ @pt.page?.should.be_true
end
end
end
diff --git a/spec/prompt_spec.rb b/spec/prompt_spec.rb
index ddda435c..0320cb5b 100644
--- a/spec/prompt_spec.rb
+++ b/spec/prompt_spec.rb
@@ -7,7 +7,7 @@ describe "Prompts" do
redirect_pry_io(InputTester.new("exit-all")) do
Pry.start(self, :prompt => proc { |v| config = v })
end
- config.is_a?(Pry::Config).should == true
+ config.is_a?(Pry::Config).should.be_true
end
it 'should get full config object, when using a proc array' do
@@ -15,21 +15,22 @@ describe "Prompts" do
redirect_pry_io(InputTester.new("exit-all")) do
Pry.start(self, :prompt => [proc { |v| config1 = v }, proc { |v| config2 = v }])
end
- config1.is_a?(Pry::Config).should == true
+ config1.is_a?(Pry::Config).should.be_true
end
it 'should receive correct data in the config object' do
config = nil
+ o = Object.new
redirect_pry_io(InputTester.new("def hello", "exit-all")) do
- Pry.start(self, :prompt => proc { |v| config = v })
+ Pry.start(o, :prompt => proc { |v| config = v })
end
config.eval_string.should =~ /def hello/
config.nesting_level.should == 0
config.expr_number.should == 1
- config.cont.should == true
- config._pry_.is_a?(Pry).should == true
- config.object.should == self
+ config.cont.should.be_true
+ config._pry_.is_a?(Pry).should.be_true
+ config.object.should == o
end
end
@@ -42,7 +43,7 @@ describe "Prompts" do
end
o.should == :test
n.should == 0
- p.is_a?(Pry).should == true
+ p.is_a?(Pry).should.be_true
end
it 'should get 3 parameters, when using proc array' do
@@ -55,7 +56,7 @@ describe "Prompts" do
end
o1.should == :test
n1.should == 0
- p1.is_a?(Pry).should == true
+ p1.is_a?(Pry).should.be_true
end
end
end
diff --git a/spec/pry_spec.rb b/spec/pry_spec.rb
index fedb63a1..d29911f8 100644
--- a/spec/pry_spec.rb
+++ b/spec/pry_spec.rb
@@ -132,7 +132,7 @@ describe Pry do
it 'should define a nested class under Hello and not on top-level or Pry' do
mock_pry(Pry.binding_for(Hello), "class Nested", "end")
- Hello.const_defined?(:Nested).should == true
+ Hello.const_defined?(:Nested).should.be_true
end
it 'should suppress output if input ends in a ";" and is an Exception object (single line)' do
@@ -146,13 +146,13 @@ describe Pry do
it 'should be able to evaluate exceptions normally' do
was_called = false
mock_pry("RuntimeError.new", :exception_handler => proc{ was_called = true })
- was_called.should == false
+ was_called.should.be_false
end
it 'should notice when exceptions are raised' do
was_called = false
mock_pry("raise RuntimeError", :exception_handler => proc{ was_called = true })
- was_called.should == true
+ was_called.should.be_true
end
it 'should not try to catch intended exceptions' do
@@ -324,27 +324,27 @@ describe Pry do
it 'should define a method on the singleton class of an object when performing "def meth;end" inside the object' do
[Object.new, {}, []].each do |val|
pry_eval(val, 'def hello; end')
- val.methods(false).map(&:to_sym).include?(:hello).should == true
+ val.methods(false).map(&:to_sym).include?(:hello).should.be_true
end
end
it 'should define an instance method on the module when performing "def meth;end" inside the module' do
hello = Module.new
pry_eval(hello, "def hello; end")
- hello.instance_methods(false).map(&:to_sym).include?(:hello).should == true
+ hello.instance_methods(false).map(&:to_sym).include?(:hello).should.be_true
end
it 'should define an instance method on the class when performing "def meth;end" inside the class' do
hello = Class.new
pry_eval(hello, "def hello; end")
- hello.instance_methods(false).map(&:to_sym).include?(:hello).should == true
+ hello.instance_methods(false).map(&:to_sym).include?(:hello).should.be_true
end
it 'should define a method on the class of an object when performing "def meth;end" inside an immediate value or Numeric' do
[:test, 0, true, false, nil,
(0.0 unless Pry::Helpers::BaseHelpers.jruby?)].each do |val|
pry_eval(val, "def hello; end");
- val.class.instance_methods(false).map(&:to_sym).include?(:hello).should == true
+ val.class.instance_methods(false).map(&:to_sym).include?(:hello).should.be_true
end
end
end
@@ -386,7 +386,7 @@ describe Pry do
describe "Pry.binding_for" do
it 'should return TOPLEVEL_BINDING if parameter self is main' do
_main_ = lambda { TOPLEVEL_BINDING.eval('self') }
- Pry.binding_for(_main_.call).is_a?(Binding).should == true
+ Pry.binding_for(_main_.call).is_a?(Binding).should.be_true
Pry.binding_for(_main_.call).should == TOPLEVEL_BINDING
Pry.binding_for(_main_.call).should == Pry.binding_for(_main_.call)
end
@@ -408,7 +408,7 @@ describe Pry do
backtrace = Pry.new.backtrace
backtrace.should.not.be.nil
- backtrace.any? { |l| l.include?(location) }.should.be.true
+ backtrace.any? { |l| l.include?(location) }.should.be_true
end
end
end
diff --git a/spec/pryrc_spec.rb b/spec/pryrc_spec.rb
index ade04736..f8566d4e 100644
--- a/spec/pryrc_spec.rb
+++ b/spec/pryrc_spec.rb
@@ -50,7 +50,7 @@ describe Pry do
Pry.config.should_load_rc = false
Pry.config.should_load_local_rc = false
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new)
- Object.const_defined?(:TEST_RC).should == false
+ Object.const_defined?(:TEST_RC).should.be_false
end
describe "that raise exceptions" do
@@ -84,8 +84,8 @@ describe Pry do
it "should continue to run pry" do
@doing_it[]
- Object.const_defined?(:TEST_BEFORE_RAISE).should == true
- Object.const_defined?(:TEST_AFTER_RAISE).should == true
+ Object.const_defined?(:TEST_BEFORE_RAISE).should.be_true
+ Object.const_defined?(:TEST_AFTER_RAISE).should.be_true
end
it "should output an error" do
diff --git a/spec/spec_helpers/bacon.rb b/spec/spec_helpers/bacon.rb
deleted file mode 100644
index 2a7721a5..00000000
--- a/spec/spec_helpers/bacon.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-# Colorize output (based on greeneggs (c) 2009 Michael Fleet)
-# TODO: Make own gem (assigned to rking)
-module Bacon
- class Context
- include PryTestHelpers
- end
-
- COLORS = {'F' => 31, 'E' => 35, 'M' => 33, '.' => 32}
- USE_COLOR = !(ENV['NO_PRY_COLORED_BACON'] == 'true') && Pry::Helpers::BaseHelpers.use_ansi_codes?
-
- module TestUnitOutput
- def handle_requirement(description)
- error = yield
-
- if error.empty?
- print colorize_string('.')
- else
- print colorize_string(error[0..0])
- end
- end
-
- def handle_summary
- puts
- puts ErrorLog if Backtraces
-
- out = "%d tests, %d assertions, %d failures, %d errors" %
- Counter.values_at(:specifications, :requirements, :failed, :errors)
-
- if Counter.values_at(:failed, :errors).inject(:+) > 0
- puts colorize_string(out, 'F')
- else
- puts colorize_string(out, '.')
- end
- end
-
- def colorize_string(text, color = nil)
- if USE_COLOR
- "\e[#{ COLORS[color || text] }m#{ text }\e[0m"
- else
- text
- end
- end
- end
-end
-
-# Reset top-level binding at the beginning of each test case.
-module Bacon
- class Context
- def it_with_reset_binding(description, &block)
- Pry.toplevel_binding = nil
- it_without_reset_binding(description, &block)
- end
- alias it_without_reset_binding it
- alias it it_with_reset_binding
- end
-end
-
-# Support mocha
-# mocha-on-bacon (c) Copyright (C) 2011, Eloy DurĂ¡n <eloy.de.enige@gmail.com>
-module Bacon
- module MochaRequirementsCounter
- def self.increment
- Counter[:requirements] += 1
- end
- end
-
- class Context
- include Mocha::API
-
- def it_with_mocha(description, &block)
- it_without_mocha(description) do
- begin
- mocha_setup
- block.call
- mocha_verify(MochaRequirementsCounter)
- rescue Mocha::ExpectationError => e
- raise Error.new(:failed, e.message)
- ensure
- mocha_teardown
- end
- end
- end
- alias it_without_mocha it
- alias it it_with_mocha
- end
-end
diff --git a/spec/spec_helpers/repl_tester.rb b/spec/spec_helpers/repl_tester.rb
index 51457e13..45045af6 100644
--- a/spec/spec_helpers/repl_tester.rb
+++ b/spec/spec_helpers/repl_tester.rb
@@ -89,7 +89,7 @@ class ReplTester
# @private
def ensure_exit
if @should_exit_naturally
- @thread[:session_ended].should.be.true
+ @thread[:session_ended].should.be_true
else
input "exit-all"
raise "REPL didn't die" unless @thread[:session_ended]
diff --git a/spec/syntax_checking_spec.rb b/spec/syntax_checking_spec.rb
index cd2700f9..5e89c940 100644
--- a/spec/syntax_checking_spec.rb
+++ b/spec/syntax_checking_spec.rb
@@ -51,12 +51,12 @@ describe Pry do
it "should allow trailing , to continue the line" do
pry = Pry.new
- Pry::Code.complete_expression?("puts 1, 2,").should == false
+ Pry::Code.complete_expression?("puts 1, 2,").should.be_false
end
it "should complete an expression that contains a line ending with a ," do
pry = Pry.new
- Pry::Code.complete_expression?("puts 1, 2,\n3").should == true
+ Pry::Code.complete_expression?("puts 1, 2,\n3").should.be_true
end
it "should not suppress the error output if the line ends in ;" do
diff --git a/spec/wrapped_module_spec.rb b/spec/wrapped_module_spec.rb
index d3d32d04..1ab4df56 100644
--- a/spec/wrapped_module_spec.rb
+++ b/spec/wrapped_module_spec.rb
@@ -1,43 +1,47 @@
require_relative 'helper'
describe Pry::WrappedModule do
+ before do
+ class Host
+ %w(spec/fixtures/candidate_helper1.rb
+ spec/fixtures/candidate_helper2.rb).each do |file|
+ binding.eval File.read(file), file, 1
+ end
- describe "#initialize" do
- it "should raise an exception when a non-module is passed" do
- lambda{ Pry::WrappedModule.new(nil) }.should.raise ArgumentError
- end
- end
-
- describe "candidates" do
- before do
- class Host
- %w(spec/fixtures/candidate_helper1.rb
- spec/fixtures/candidate_helper2.rb).each do |file|
- binding.eval File.read(file), file, 1
- end
-
- # rank 2
- class CandidateTest
- def test6
- end
+ # rank 2
+ class CandidateTest
+ def test6
end
+ end
- class PitifullyBlank
- DEFAULT_TEST = CandidateTest
- end
+ class PitifullyBlank
+ DEFAULT_TEST = CandidateTest
+ end
- FOREVER_ALONE_LINE = __LINE__ + 1
- class ForeverAlone
- class DoublyNested
- # nested docs
- class TriplyNested
- def nested_method
- end
+ FOREVER_ALONE_LINE = __LINE__ + 1
+ class ForeverAlone
+ class DoublyNested
+ # nested docs
+ class TriplyNested
+ def nested_method
end
end
end
end
end
+ end
+
+ after do
+ Object.remove_const :Host
+ end
+
+ describe "#initialize" do
+ it "should raise an exception when a non-module is passed" do
+ lambda{ Pry::WrappedModule.new(nil) }.should.raise ArgumentError
+ end
+ end
+
+ describe "candidates" do
describe "number_of_candidates" do
it 'should return the correct number of candidates' do
@@ -134,10 +138,6 @@ describe Pry::WrappedModule do
Pry::WrappedModule(Host::ForeverAlone::DoublyNested::TriplyNested).doc.should =~ /nested docs/
end
end
-
- after do
- Object.remove_const(:Host)
- end
end
describe ".method_prefix" do
@@ -150,42 +150,42 @@ describe Pry::WrappedModule do
Object.remove_const(:Foo)
end
- it "should return Foo# for normal classes" do
+ it "returns Foo# for normal classes" do
Pry::WrappedModule.new(Foo).method_prefix.should == "Foo#"
end
- it "should return Bar# for modules" do
+ it "returns Bar# for modules" do
Pry::WrappedModule.new(Kernel).method_prefix.should == "Kernel#"
end
- it "should return Foo. for singleton classes of classes" do
+ it "returns Foo. for singleton classes of classes" do
Pry::WrappedModule.new(class << Foo; self; end).method_prefix.should == "Foo."
end
- describe "of singleton classes of objects" do
+ it "returns self. for singleton classes of objects" do
Pry::WrappedModule.new(class << @foo; self; end).method_prefix.should == "self."
end
- describe "of anonymous classes should not be empty" do
+ it "returns a representation of an anonymous class" do
Pry::WrappedModule.new(Class.new).method_prefix.should =~ /#<Class:.*>#/
end
- describe "of singleton classes of anonymous classes should not be empty" do
+ it "returns a representation of a singleton of an anonymous class" do
Pry::WrappedModule.new(class << Class.new; self; end).method_prefix.should =~ /#<Class:.*>./
end
end
describe ".singleton_class?" do
it "should be true for singleton classes" do
- Pry::WrappedModule.new(class << ""; self; end).singleton_class?.should == true
+ Pry::WrappedModule.new(class << ""; self; end).singleton_class?.should.be_true
end
it "should be false for normal classes" do
- Pry::WrappedModule.new(Class.new).singleton_class?.should == false
+ Pry::WrappedModule.new(Class.new).singleton_class?.should.be_false
end
it "should be false for modules" do
- Pry::WrappedModule.new(Module.new).singleton_class?.should == false
+ Pry::WrappedModule.new(Module.new).singleton_class?.should.be_false
end
end