Sha256: 5cdf629598aeb452dc598e5012f0e4e5a1101aab37e0b3c6c112489c58163170

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 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(-1) }
    end

    test 'find coerces ids' 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(-1) }
      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

3 entries across 3 versions & 1 rubygems

Version Path
web-console-2.0.0.beta3 test/web_console/repl_session_test.rb
web-console-2.0.0.beta2 test/web_console/repl_session_test.rb
web-console-2.0.0.beta1 test/web_console/repl_session_test.rb