spec/rubyserial_spec.rb in rubyserial-0.5.0 vs spec/rubyserial_spec.rb in rubyserial-0.6.0
- old
+ new
@@ -146,7 +146,41 @@
@sp2 = Serial.new(@ports[0], 19200, 8, :odd)
@sp = Serial.new(@ports[1], 19200, 8, :odd)
@sp.write("Hello!\n")
expect(@sp2.gets).to eql("Hello!\n")
end
+
+ it 'should accept 1 stop bit' do
+ @sp2.close
+ @sp.close
+ @sp2 = Serial.new(@ports[0], 19200, 8, :none, 1)
+ @sp = Serial.new(@ports[1], 19200, 8, :none, 1)
+ @sp.write("Hello!\n")
+ expect(@sp2.gets).to eql("Hello!\n")
+ end
+
+ it 'should accept 2 stop bits' do
+ @sp2.close
+ @sp.close
+ @sp2 = Serial.new(@ports[0], 19200, 8, :none, 2)
+ @sp = Serial.new(@ports[1], 19200, 8, :none, 2)
+ @sp.write("Hello!\n")
+ expect(@sp2.gets).to eql("Hello!\n")
+ end
+
+ it 'should set baude rate, check #46 fixed' do
+ skip 'Not a bug on Windows' if RubySerial::ON_WINDOWS
+ @sp.close
+ rate = 600
+ @sp = Serial.new(@ports[1], rate)
+ fd = @sp.instance_variable_get(:@fd)
+ module RubySerial
+ module Posix
+ attach_function :tcgetattr, [ :int, RubySerial::Posix::Termios ], :int, blocking: true
+ end
+ end
+ termios = RubySerial::Posix::Termios.new
+ RubySerial::Posix::tcgetattr(fd, termios)
+ expect(termios[:c_ispeed]).to eql(RubySerial::Posix::BAUDE_RATES[rate])
+ end
end
end