Sha256: 03529f00346c3657f3d1469b4c88f795fdab237f2efb1ffa8bc76f74fae6b48f

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe RubyPython do
  include RubyPythonStartStop

  describe "#import" do
    it "should handle multiple imports" do
      lambda do
        RubyPython.import 'cPickle'
        RubyPython.import 'urllib'
      end.should_not raise_exception
    end

    it "should propagate Python errors" do
      lambda do
        RubyPython.import 'nonExistentModule'
      end.should raise_exception(RubyPython::PythonError)
    end

    it "should return a RubyPyModule" do
      RubyPython.import('urllib2').should be_a(RubyPython::RubyPyModule)
    end
  end

end

describe RubyPython, "#session" do

  it "should start interpreter" do
    RubyPython.session do
      cPickle = RubyPython.import "cPickle"
      cPickle.loads("(dp1\nS'a'\nS'n'\ns(I1\nS'2'\ntp2\nI4\ns.").rubify.should == {"a"=>"n", [1, "2"]=>4}
    end
  end

  it "should stop the interpreter" do
    RubyPython.session do
      cPickle = RubyPython.import "cPickle"
    end

    RubyPython.stop.should be_false
  end
end

describe RubyPython, "#run" do

  it "should start interpreter" do
    RubyPython.run do
      cPickle = import "cPickle"
      cPickle.loads("(dp1\nS'a'\nS'n'\ns(I1\nS'2'\ntp2\nI4\ns.").rubify.should == {"a"=>"n", [1, "2"]=>4}
    end
  end

  it "should stop the interpreter" do
    RubyPython.run do
      cPickle = import "cPickle"
    end

    RubyPython.stop.should be_false
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubypython-0.3.1 spec/rubypython_spec.rb
rubypython-0.3.0 spec/rubypython_spec.rb