Sha256: 7351a4722bdd1d5eb31b718c3d290489a81151df62df3726bcc7f311b320ffc0

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'

module WebConsole
  class REPLSessionTest < ActionView::TestCase
    setup do
      WebConsole::REPLSession::INMEMORY_STORAGE.clear
      @model1 = @model = WebConsole::REPLSession.new binding: TOPLEVEL_BINDING
      @model2 = WebConsole::REPLSession.new binding: TOPLEVEL_BINDING
    end

    test 'raises WebConsole::REPLSession::NotFound on not found sessions' do
      assert_raises(WebConsole::REPLSession::NotFound) { WebConsole::REPLSession.find("nonexistent session") }
    end

    test 'find returns a persisted object' do
      assert_equal @model.save, WebConsole::REPLSession.find(@model.id)
    end

    test 'not found exceptions are JSON serializable' do
      exception = assert_raises(WebConsole::REPLSession::NotFound) { WebConsole::REPLSession.find("nonexistent session") }
      assert_equal '{"error":"Session unavailable"}', exception.to_json
    end

    test 'create gives already persisted models' do
      assert WebConsole::REPLSession.create(binding: TOPLEVEL_BINDING).persisted?
    end

    test 'no gives not persisted models' do
      assert_not WebConsole::REPLSession.new(binding: TOPLEVEL_BINDING).persisted?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
web-console-2.0.0 test/web_console/repl_session_test.rb
web-console-2.0.0.beta4 test/web_console/repl_session_test.rb