spec/network/unix_spec.rb in ronin-support-0.5.1 vs spec/network/unix_spec.rb in ronin-support-0.5.2

- old
+ new

@@ -13,44 +13,43 @@ end describe "#unix_open?" do include_context "UNIX Server" - let(:old_path) { socket_path('ronin_old_unix_socket') } - let(:bad_path) { socket_path('ronin_bad_unix_socket') } - - before(:all) { UNIXServer.new(old_path).close } - it "should return true for listening UNIX sockets" do - subject.unix_open?(path).should == true + expect(subject.unix_open?(path)).to be(true) end it "should return false for closed UNIX sockets" do - subject.unix_open?(old_path).should == false + old_path = socket_path('ronin_old_unix_socket') + UNIXServer.new(old_path).close + + expect(subject.unix_open?(old_path)).to be(false) + + FileUtils.rm(old_path) end it "should have a timeout for non-existent UNIX sockets" do - timeout = 2 + bad_path = socket_path('ronin_bad_unix_socket') + timeout = 2 t1 = Time.now subject.unix_open?(bad_path,timeout) t2 = Time.now - (t2 - t1).to_i.should <= timeout + expect((t2 - t1).to_i).to be <= timeout end - - after(:all) { FileUtils.rm(old_path) } end describe "#unix_connect" do include_context "UNIX Server" it "should open a UNIXSocket" do socket = subject.unix_connect(path) - socket.should be_kind_of(UNIXSocket) - socket.should_not be_closed + expect(socket).to be_kind_of(UNIXSocket) + expect(socket).not_to be_closed socket.close end it "should yield the new UNIXSocket" do @@ -58,11 +57,11 @@ subject.unix_connect(path) do |yielded_socket| socket = yielded_socket end - socket.should_not be_closed + expect(socket).not_to be_closed socket.close end end describe "#unix_connect_and_send" do @@ -72,11 +71,11 @@ it "should connect and then send data" do socket = subject.unix_connect_and_send(data,path) response = socket.readline - response.should == data + expect(response).to eq(data) socket.close end it "should yield the UNIXSocket" do @@ -84,11 +83,11 @@ socket = subject.unix_connect_and_send(data,path) do |socket| response = socket.readline end - response.should == data + expect(response).to eq(data) socket.close end end @@ -100,12 +99,12 @@ subject.unix_session(path) do |yielded_socket| socket = yielded_socket end - socket.should be_kind_of(UNIXSocket) - socket.should be_closed + expect(socket).to be_kind_of(UNIXSocket) + expect(socket).to be_closed end end describe "#unix_send" do let(:server_path) { File.join(Dir.tmpdir,'ronin_unix_server') } @@ -119,11 +118,11 @@ client = @server.accept sent = client.readline client.close - sent.should == data + expect(sent).to eq(data) end after(:each) do @server.close @@ -135,12 +134,12 @@ let(:server_path) { File.join(Dir.tmpdir,'ronin_unix_server') } it "should create a new UNIXServer" do server = subject.unix_server(server_path) - server.should be_kind_of(UNIXServer) - server.should_not be_closed + expect(server).to be_kind_of(UNIXServer) + expect(server).not_to be_closed server.close end it "should yield the new UNIXServer" do @@ -148,12 +147,12 @@ subject.unix_server(server_path) do |yielded_server| server = yielded_server end - server.should be_kind_of(UNIXServer) - server.should_not be_closed + expect(server).to be_kind_of(UNIXServer) + expect(server).not_to be_closed server.close end after(:each) { FileUtils.rm(server_path) } @@ -167,11 +166,11 @@ subject.unix_server_session(server_path) do |yielded_server| server = yielded_server end - server.should be_kind_of(UNIXServer) - server.should be_closed + expect(server).to be_kind_of(UNIXServer) + expect(server).to be_closed end after(:each) { FileUtils.rm(server_path) } end