Sha256: 4d06ceb5d80fcd72e63fe8cf832cdd3ec81f59239e345302ac7bd55d02770ad3

Contents?: true

Size: 722 Bytes

Versions: 6

Compression:

Stored size: 722 Bytes

Contents

require 'lib/spec_helper'
require 'opal/repl'

RSpec.describe Opal::REPL, skip: RUBY_PLATFORM != 'ruby' do
  describe '#eval_ruby' do
    let(:input_and_output) { {
      'puts 5'          => "5\n=> nil\n",
      'a = 1'           => "=> 1\n",
      'a += 1'          => "=> 2\n",
      'a + 3'           => "=> 5\n",
      'puts a + 3'      => "5\n=> nil\n",
      '"#{a} + 3"'      => "=> \"2 + 3\"\n",
      'puts "#{a} + 3"' => "2 + 3\n=> nil\n",
    } }

    subject(:repl) { described_class.new }

    it 'evaluates user inputs' do
      repl.load_opal

      input_and_output.each do |input, output|
        expect { repl.run_line(input) }.to output(output).to_stdout
      end

      repl.finish
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.2.0 spec/lib/repl_spec.rb
opal-1.2.0.beta1 spec/lib/repl_spec.rb
opal-1.1.1 spec/lib/repl_spec.rb
opal-1.1.1.rc1 spec/lib/repl_spec.rb
opal-1.1.0 spec/lib/repl_spec.rb
opal-1.1.0.rc1 spec/lib/repl_spec.rb