2014-03-14 03:00:48 -04:00
|
|
|
require 'bundler/setup'
|
2014-03-14 20:47:58 -04:00
|
|
|
Bundler.require :default, :test
|
2017-12-24 00:05:44 -05:00
|
|
|
require 'pry/testable'
|
2014-03-14 00:31:24 -04:00
|
|
|
require_relative 'spec_helpers/mock_pry'
|
|
|
|
require_relative 'spec_helpers/repl_tester'
|
|
|
|
|
2014-05-30 16:43:25 -04:00
|
|
|
if ENV["COVERAGE"]
|
|
|
|
require "simplecov"
|
|
|
|
SimpleCov.start
|
|
|
|
end
|
|
|
|
|
2012-12-06 19:52:37 -05:00
|
|
|
class Module
|
|
|
|
public :remove_const
|
|
|
|
public :remove_method
|
|
|
|
end
|
|
|
|
|
2014-03-14 21:22:27 -04:00
|
|
|
Pad = Class.new do
|
|
|
|
include Pry::Config::Behavior
|
|
|
|
end.new(nil)
|
2012-12-08 17:56:57 -05:00
|
|
|
|
2012-12-06 19:52:37 -05:00
|
|
|
# to help with tracking down bugs that cause an infinite loop in the test suite
|
|
|
|
if ENV["SET_TRACE_FUNC"]
|
2018-10-15 16:38:17 -04:00
|
|
|
set_trace_func(
|
|
|
|
proc { |event, file, line, id, binding, classname|
|
2012-12-06 19:52:37 -05:00
|
|
|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
2018-10-15 16:38:17 -04:00
|
|
|
}
|
|
|
|
)
|
2012-12-06 19:52:37 -05:00
|
|
|
end
|
2012-12-08 20:11:40 -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
|
|
|
RSpec.configure do |config|
|
2014-08-18 15:17:18 -04:00
|
|
|
config.expect_with :rspec do |c|
|
|
|
|
c.syntax = [:should, :expect]
|
|
|
|
end
|
2014-09-12 12:42:42 -04:00
|
|
|
|
2017-11-04 00:32:31 -04:00
|
|
|
config.before(:each) do
|
|
|
|
Pry::Testable.set_testenv_variables
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after(:each) do
|
|
|
|
Pry::Testable.unset_testenv_variables
|
|
|
|
end
|
|
|
|
config.include Pry::Testable::Mockable
|
|
|
|
config.include Pry::Testable::Utility
|
|
|
|
include Pry::Testable::Evalable
|
|
|
|
include Pry::Testable::Variables
|
2017-11-18 14:54:03 -05:00
|
|
|
|
|
|
|
# Optionally skip a test on specific Ruby engine(s).
|
|
|
|
# Please use this feature sparingly! It is better that a feature works than not.
|
|
|
|
# Inapplicable features are OK.
|
|
|
|
config.before(:each) do |example|
|
|
|
|
Pry::Platform.known_engines.each do |engine|
|
|
|
|
example.metadata[:expect_failure].to_a.include?(engine) and
|
|
|
|
Pry::Platform.public_send(:"#{engine}?") and
|
|
|
|
skip("This spec is failing or inapplicable on #{engine}.")
|
|
|
|
end
|
|
|
|
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
|
|
|
end
|
2017-11-04 00:32:31 -04:00
|
|
|
|
|
|
|
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}, CodeRay v#{CodeRay::VERSION}, Pry::Slop v#{Pry::Slop::VERSION}"
|