direc = File.dirname(__FILE__) require 'pry' require "#{direc}/../lib/pry-doc" require "#{direc}/helper" require "#{direc}/gem_with_cext/gems/sample" require 'set' require 'fileutils' require 'readline' puts "Testing pry-doc version #{PryDoc::VERSION}..." puts "Ruby version: #{RUBY_VERSION}" RSpec.describe PryDoc do describe Pry::CInternals::CodeFetcher do def decolor(str) Pry::Helpers::Text.strip_color(str) end before do described_class.symbol_map = nil described_class.ruby_source_folder = File.join(File.dirname(__FILE__), "fixtures/c_source") end context "no tags file exists" do it "attempts to install and setup ruby" do described_class.ruby_source_folder = File.join(File.dirname(__FILE__), "fishface") expect(described_class.ruby_source_installer).to receive(:install) # will try to read from the 'created' tags file, this will error, so rescue # (since we're stubbing out `install` no tags file # ever gets created) described_class.symbol_map rescue nil end end describe ".symbol_map" do it "generates the map with the correct symbols" do expect(described_class.symbol_map).to have_key("foo") expect(described_class.symbol_map).to have_key("baby") expect(described_class.symbol_map).to have_key("wassup") expect(described_class.symbol_map).to have_key("bar") expect(described_class.symbol_map).to have_key("baz") expect(described_class.symbol_map).to have_key("cute_enum_e") expect(described_class.symbol_map).to have_key("baby_enum") expect(described_class.symbol_map).to have_key("cutie_pie") end end describe "#fetch_all_definitions" do it "returns both code and file name" do file_ = described_class.symbol_map["foo"].first.file _, file = described_class.new.fetch_all_definitions("foo") expect(file).to eq file_ end it "returns the code for all symbols" do code, = described_class.new.fetch_all_definitions("foo") expect(decolor code).to include <