Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/support/shared/examples/msf/sessions.rb
Views: 11788
# frozen_string_literal: true12RSpec.shared_examples 'client session' do3subject(:session) do4session = described_class.new(nil, opts)5session.user_input = user_input6session.user_output = user_output7session.name = name8session9end1011describe '.type' do12it 'should have the correct type' do13expect(described_class.type).to eq(type)14end15end1617describe '.can_cleanup_files' do18it 'should be able to cleanup files' do19expect(described_class.can_cleanup_files).to eq(can_cleanup_files)20end21end2223describe '#desc' do24it 'should have the correct description' do25expect(subject.desc).to eq(description)26end27end2829describe '#type' do30it 'should have the correct type' do31expect(subject.type).to eq(type)32end33end3435describe '#initialize' do36context 'without a client' do37let(:opts) { {} }3839it 'raises a KeyError' do40expect { subject }.to raise_exception(KeyError)41end42end43context 'with a client' do44it 'does not raise an exception' do45expect { subject }.not_to raise_exception46end47end4849it 'creates a new console' do50expect(subject.console).to be_a(console_class)51end52end5354describe '#bootstrap' do55subject { session.bootstrap }5657it 'keeps the sessions user input' do58expect { subject }.not_to change(session, :user_input).from(user_input)59end6061it 'keeps the sessions user output' do62expect { subject }.not_to change(session, :user_output).from(user_output)63end6465it 'sets the console input' do66expect { subject }.to change(session.console, :input).to(user_input)67end6869it 'sets the console output' do70expect { subject }.to change(session.console, :output).to(user_output)71end7273it 'sets the log source' do74expect { subject }.to change(session.console, :log_source).to(log_source)75end76end7778describe '#reset_ui' do79before(:each) do80session.bootstrap81end8283subject { session.reset_ui }8485it 'keeps the sessions user input' do86expect { subject }.not_to change(session, :user_input).from(user_input)87end8889it 'keeps the sessions user output' do90expect { subject }.not_to change(session, :user_output).from(user_output)91end9293it 'resets the console input' do94expect { subject }.to change(session.console, :input).from(user_input).to(nil)95end9697it 'resets the console output' do98expect { subject }.to change(session.console, :output).from(user_output).to(nil)99end100end101102describe '#exit' do103subject { session.exit }104105it 'exits the session' do106expect { subject }.to change(session.console, :stopped?).from(false).to(true)107end108end109110describe '#address' do111subject { session.address }112113it { is_expected.to eq(address) }114end115116describe '#port' do117subject { session.port }118119it { is_expected.to eq(port) }120end121end122123124