Ruby Can';";require();某些核心包?

Ruby Can';";require();某些核心包?,ruby,Ruby,鲁比好像在耍我。那还是红宝石。因此,我创建了一个名为NetworkDaemon的类,并在NetworkDaemonSpecification中创建了它的相关规范。很简单 然而,我的问题是,我似乎不能从网络守护进程.rb使用要求“tcp\u服务器”,但我可以从网络守护进程规范.rb使用 如果我尝试从network\u daemon.rb(在network\u daemon\u specification.rb中进行单元测试)引用tcp\u服务器,我会得到以下堆栈跟踪 E:/Ruby200/lib/

鲁比好像在耍我。那还是红宝石。因此,我创建了一个名为
NetworkDaemon
的类,并在
NetworkDaemonSpecification
中创建了它的相关规范。很简单

然而,我的问题是,我似乎不能从
网络守护进程.rb
使用
要求“tcp\u服务器”
,但我可以从
网络守护进程规范.rb
使用

如果我尝试从
network\u daemon.rb
(在
network\u daemon\u specification.rb
中进行单元测试)引用
tcp\u服务器
,我会得到以下堆栈跟踪

E:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require': cannot load such file -- tcp_server (LoadError)
    from E:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from E:/Ruby/RubyCraft/network/network_daemon.rb:1:in `<top (required)>'
    from E:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from E:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from E:/Ruby/RubyCraft/specification/network_daemon_specification.rb:1:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'
network\u daemon\u specification.rb

require 'tcp_server'

module RubyCraft
  module Network
    # The network daemon controls the listening and responses
    class NetworkDaemon
      attr_reader :port
      # Creates the NetworkDaemon from the given port
      # @param [Fixnum] port
      def initialize port
        @port = port
        @sock = TCPServer.new @port
      end

      # Closes the NetworkDaemon
      def close
        @sock.close
      end
    end
  end
end
# Unit tests for the Network Daemon that will be used to listen for connections
module RubyCraft
  module Specifications
    class NetworkDaemonSpecification < Test::Unit::TestCase
      def setup
        @port = 9999
        @daemon = NetworkDaemon.new @port
      end

      def test_port_should_equal_injected_port
        assert_equal @daemon.port, @port
      end

      def teardown
        @daemon.close
      end
    end
  end
end
#用于侦听连接的网络守护进程的单元测试
模块RubyCraft
模块规格
类NetworkDaemonSpecification
事实证明
tcp\u服务器
不是你需要的(不管鲁比明怎么说)-你应该需要
socket
你需要
需要“socket”
不是
tcp\u服务器


查看
TCPServer
文档以了解更多信息RubyMine误导了我...\u.你怎么知道你可以要求它形成规范文件?你是在使用该文件还是在加载应用程序时加载它?如果不是,规范文件中的require将永远不会运行,你也不会看到错误。因为我是在我不知道RubyMine会做什么来加载一个不存在的文件。