Add .rspec and require 'helper' from there

Just discovered this nice feature of RSpec where it can load all files for
us. Works with `bundle exec rake` and `bundle exec rspec spec/file_spec.rb`,
which covers all use cases.
This commit is contained in:
Kyrylo Silin 2018-11-18 14:04:44 +08:00
parent 1f60cc1ff5
commit e61354693f
65 changed files with 13 additions and 125 deletions

2
.rspec Normal file
View File

@ -0,0 +1,2 @@
--color
--require helper

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::Hooks do
before do
Pry::CLI.reset

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::CodeObject do
describe "basic lookups" do
before do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::Code do
describe '.from_file' do
specify 'read lines from a file on disk' do

View File

@ -1,9 +1,8 @@
require 'helper'
describe Pry::ColorPrinter do
describe Pry::ColorPrinter do
include Pry::Helpers::Text
let(:io) { StringIO.new }
let(:str) { strip_color(io.string.chomp) }
describe '.pp' do
describe 'Object' do
it 'prints a string' do
@ -12,32 +11,32 @@ describe Pry::ColorPrinter do
end
end
describe 'Object subclass' do
describe 'Object subclass' do
before do
class ObjectF < Object
class ObjectF < Object
def inspect
'foo'
end
end
class ObjectG < Object
def inspect
raise
def inspect
raise
end
end
end
after do
after do
Object.send :remove_const, :ObjectF
Object.send :remove_const, :ObjectG
end
end
it 'prints a string' do
Pry::ColorPrinter.pp(ObjectF.new, io)
expect(str).to eq('foo')
end
end
it 'prints a string, even when an exception is raised' do
it 'prints a string, even when an exception is raised' do
Pry::ColorPrinter.pp(ObjectG.new, io)
expect(str).to match(/\A#<ObjectG:0x\w+>\z/)
end

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::Helpers::CommandHelpers do
before do
@helper = Pry::Helpers::CommandHelpers

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe "commands" do
before do
@str_output = StringIO.new

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::CommandSet do
before do
@set = Pry::CommandSet.new do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe "Pry::Command" do
before do
@set = Pry::CommandSet.new

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "amend-line" do
before do
@t = pry_tester

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "!" do
before do
@t = pry_tester

View File

@ -1,5 +1,3 @@
require_relative '../../helper'
describe Pry::Command::Cat::FileFormatter do
before do
@p = Pry.new

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "cat" do
before do
@str_output = StringIO.new

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe 'cd' do
before do
@o, @obj = Object.new, Object.new

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "disable-pry" do
before do
@t = pry_tester

View File

@ -1,5 +1,4 @@
require 'pathname'
require_relative '../helper'
describe "edit" do
before do

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "exit-all" do
before { @pry = Pry.new }

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "exit-program" do
it 'should raise SystemExit' do
expect { pry_eval('exit-program') }.to raise_error SystemExit

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "exit" do
before { @pry = Pry.new(target: :outer, output: StringIO.new) }

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "find-method" do
MyKlass = Class.new do
def hello

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "gem-list" do
it 'should not raise when invoked' do
expect { pry_eval(self, 'gem-list') }.to_not raise_error

View File

@ -1,9 +1,6 @@
# These tests are out of date.
# They need to be updated for the new 'gist' API, but im too sleepy to
# do that now.
require_relative '../helper'
describe 'gist' do
it 'has a dependency on the jist gem' do
expect(Pry::Command::Gist.command_options[:requires_gem]).to eq("gist")

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "help" do
before do
@oldset = Pry.config.commands

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "hist" do
before do
Pry.history.clear

View File

@ -1,5 +1,3 @@
require 'helper'
RSpec.describe "jump-to" do
let(:obj) { Object.new }

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "ls" do
describe "bug #1407" do
it "behaves as usual when a method of the same name exists." do

View File

@ -1,9 +1,6 @@
# This command needs a TONNE more tests for it, but i can't figure out
# how to do them yet, and i really want to release. Sorry. Someone
# come along and do a better job.
require_relative '../helper'
describe "play" do
before do
@o = Object.new

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "raise-up" do
before do
@self = "Pad.self = self"

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "reload_code" do
describe "reload_current_file" do
it 'raises an error source code not found' do

View File

@ -1,4 +1,3 @@
require_relative '../helper'
describe "ri" do
it "prints an error message without an argument" do
expect(pry_eval("ri")).to include("Please provide a class, module, or method name (e.g: ri Array#push)")

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "save-file" do
before do
@tf = Tempfile.new(["pry", ".py"])

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe Pry::Command::ShellCommand do
describe 'cd' do
before do

View File

@ -1,4 +1,3 @@
require_relative '../helper'
require "fixtures/show_source_doc_examples"
describe "show-doc" do

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "show-input" do
before do
@t = pry_tester

View File

@ -1,4 +1,3 @@
require_relative '../helper'
require "fixtures/show_source_doc_examples"
describe "show-source" do

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "watch expression" do
# Custom eval that will:
# 1) Create an instance of pry that can use for multiple calls

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "whereami" do
it 'should work with methods that have been undefined' do
class Cor

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe "wtf?!" do
let(:tester) do
pry_tester do

View File

@ -1,4 +1,3 @@
require_relative 'helper'
require "readline" unless defined?(Readline)
require "pry/input_completer"

View File

@ -1,4 +1,3 @@
require 'helper'
RSpec.describe Pry::Config::Behavior do
let(:behavior) do
Class.new do

View File

@ -1,4 +1,3 @@
require 'helper'
RSpec.describe Pry::Config::Memoization do
let(:config) do
Class.new do

View File

@ -1,4 +1,3 @@
require_relative 'helper'
describe Pry::Config do
describe "bug #1552" do
specify "a local key has precendence over its default when the stored value is false" do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::DEFAULT_CONTROL_D_HANDLER do
describe "control-d press" do
before do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::Helpers::DocumentationHelpers do
before do
@helper = Pry::Helpers::DocumentationHelpers

View File

@ -1,5 +1,4 @@
require 'pathname'
require_relative 'helper'
describe Pry::Editor do
class Pry::Editor

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe 'Formatting Table' do
it 'knows about colorized fitting' do
t = Pry::Helpers::Table.new %w(hihi), column_count: 1

View File

@ -1,4 +1,3 @@
require_relative 'helper'
require 'tempfile'
describe Pry do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::Hooks do
before do
@hooks = Pry::Hooks.new

View File

@ -1,5 +1,3 @@
require_relative 'helper'
# Please keep in mind that any hash signs ("#") in the heredoc strings are
# placed on purpose. Without these editors might remove the whitespace on empty
# lines.
@ -249,7 +247,7 @@ def test
puts "something" rescue "whatever"
end
INPUT
expect(@indent.indent(input)).to eq input
end

View File

@ -1,4 +1,3 @@
require "helper"
require "shellwords"
RSpec.describe "Hanami integration" do

View File

@ -1,7 +1,6 @@
# These specs ensure that Pry doesn't require readline until the first time a
# REPL is started.
require "helper"
require "shellwords"
RSpec.describe "Readline" do

View File

@ -1,5 +1,3 @@
require_relative '../helper'
describe Pry::Method::Patcher do
before do
@x = Object.new

View File

@ -1,4 +1,3 @@
require_relative 'helper'
require 'set'
describe Pry::Method do

View File

@ -1,4 +1,3 @@
require_relative "helper"
describe "Pry::Pager" do
describe "PageTracker" do
before do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::Prompt do
describe ".[]" do
it "accesses prompts" do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
_version = 1
describe "test Pry defaults" do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry do
describe "output failsafe" do
after do

View File

@ -1,4 +1,3 @@
require_relative 'helper'
describe Pry::REPL do
it "should let you run commands in the middle of multiline expressions" do
ReplTester.start do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry do
before do
@str_output = StringIO.new

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry do
describe 'loading rc files' do
before do

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe "Pry.run_command" do
before do
o = Object.new

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe "Sticky locals (_file_ and friends)" do
it 'locals should all exist upon initialization' do
expect { pry_eval '_file_', '_dir_', '_ex_', '_pry_', '_' }.to_not raise_error

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry do
before do
@str_output = StringIO.new

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe "Pry.config.unrescued_exceptions" do
before do
@str_output = StringIO.new

View File

@ -1,5 +1,3 @@
require_relative 'helper'
describe Pry::WrappedModule do
describe "#initialize" do
it "should raise an exception when a non-module is passed" do