test/models/console_session_test.rb in web-console-rails3-0.4.1 vs test/models/console_session_test.rb in web-console-rails3-1.0.0

- old
+ new

@@ -3,36 +3,42 @@ module WebConsole class ConsoleSessionTest < ActionView::TestCase include ActiveModel::Lint::Tests setup do - PTY.stubs(:spawn).returns([String.new, String.new, Random.rand(20000)]) + PTY.stubs(:spawn).returns([StringIO.new, StringIO.new, Random.rand(20000)]) ConsoleSession::INMEMORY_STORAGE.clear @model1 = @model = ConsoleSession.new @model2 = ConsoleSession.new end - test 'raises ConsoleSession::NotFound on not found sessions' do - assert_raises(ConsoleSession::NotFound) { ConsoleSession.find(-1) } + test 'raises ConsoleSession::Unavailable on not found sessions' do + assert_raises(ConsoleSession::Unavailable) { ConsoleSession.find(-1) } end test 'find coerces ids' do assert_equal @model.persist, ConsoleSession.find("#{@model.pid}") end test 'not found exceptions are json serializable' do - exception = assert_raises(ConsoleSession::NotFound) { ConsoleSession.find(-1) } + exception = assert_raises(ConsoleSession::Unavailable) { ConsoleSession.find(-1) } assert_equal '{"error":"Session unavailable"}', exception.to_json end test 'can be used as slave as the methods are delegated' do slave_methods = Slave.instance_methods - @model.methods slave_methods.each { |method| assert @model.respond_to?(method) } end + test 'slave methods are cached on the singleton' do + assert_not @model.singleton_methods.include?(:pending_output?) + @model.pending_output? rescue nil + assert @model.singleton_methods.include?(:pending_output?) + end + test 'persisted models knows that they are in memory' do - refute @model.persisted? + assert_not @model.persisted? @model.persist assert @model.persisted? end test 'persisted models knows about their keys' do @@ -44,9 +50,9 @@ test 'create gives already persisted models' do assert ConsoleSession.create.persisted? end test 'no gives not persisted models' do - refute ConsoleSession.new.persisted? + assert_not ConsoleSession.new.persisted? end end end