test/test/cluster/unit/cluster_test.rb in elasticsearch-extensions-0.0.30 vs test/test/cluster/unit/cluster_test.rb in elasticsearch-extensions-0.0.31

- old
+ new

@@ -250,26 +250,29 @@ @subject = Elasticsearch::Extensions::Test::Cluster::Cluster.new command: '/foo/bar/bin/elasticsearch' end should "return version from lib/elasticsearch.X.Y.Z.jar" do File.expects(:exist?).with('/foo/bar/bin/../lib/').returns(true) - Dir.expects(:entries).with('/foo/bar/bin/../lib/').returns(['foo.jar', 'elasticsearch-2.3.0.jar']) + Dir.expects(:entries).with('/foo/bar/bin/../lib/').returns(['foo.jar', 'elasticsearch-foo-1.0.0.jar', 'elasticsearch-2.3.0.jar', 'elasticsearch-bar-9.9.9.jar']) assert_equal '2.0', @subject.__determine_version end should "return version from `elasticsearch --version`" do File.expects(:exist?).with('/foo/bar/bin/../lib/').returns(false) File.expects(:exist?).with('/foo/bar/bin/elasticsearch').returns(true) + io = mock('IO') + io.expects(:pid).returns(123) + io.expects(:read).returns('Version: 2.3.0-SNAPSHOT, Build: d1c86b0/2016-03-30T10:43:20Z, JVM: 1.8.0_60') + io.expects(:closed?).returns(false) + io.expects(:close) + IO.expects(:popen).returns(io) + Process.stubs(:wait) - Process.expects(:spawn).returns(123) Process.expects(:kill).with('INT', 123) - IO.any_instance.expects(:read) - .returns('Version: 2.3.0-SNAPSHOT, Build: d1c86b0/2016-03-30T10:43:20Z, JVM: 1.8.0_60') - assert_equal '2.0', @subject.__determine_version end should "return version from arguments" do cluster = Elasticsearch::Extensions::Test::Cluster::Cluster.new command: '/foo/bar/bin/elasticsearch', version: '5.2' @@ -286,14 +289,18 @@ should "raise an exception when the version cannot be parsed from command output" do File.expects(:exist?).with('/foo/bar/bin/../lib/').returns(false) File.expects(:exist?).with('/foo/bar/bin/elasticsearch').returns(true) + io = mock('IO') + io.expects(:pid).returns(123) + io.expects(:read).returns('Version: FOOBAR') + io.expects(:closed?).returns(false) + io.expects(:close) + IO.expects(:popen).returns(io) + Process.stubs(:wait) - Process.expects(:spawn).returns(123) Process.expects(:kill).with('INT', 123) - - IO.any_instance.expects(:read).returns('Version: FOOBAR') assert_raise(RuntimeError) { @subject.__determine_version } end should "raise an exception when the version cannot be converted to short version" do