Sha256: 7168799d8af48ce4001333cccce1a5f004a2be59d9552273e00954cb1a489b52

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

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

describe Rupy do
  include RubyPythonStartStop

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

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

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

end

describe Rupy, "#session" do

  it "should start interpreter" do
    Rupy.session do
      cPickle = Rupy.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
    Rupy.session do
      cPickle = Rupy.import "cPickle"
    end

    Rupy.stop.should be_false
  end
end

describe Rupy, "#run" do

  it "should start interpreter" do
    Rupy.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
    Rupy.run do
      cPickle = import "cPickle"
    end

    Rupy.stop.should be_false
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rupy-0.4.2 spec/rubypython_spec.rb
rupy-0.4.1 spec/rubypython_spec.rb
rupy-0.4.0 ./spec/rubypython_spec.rb