Sha256: c2043b9a65c4fa536a0f13d73ba96ec1b1479eae8dd41866bcc83fd40a118308

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

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

include TestConstants

describe 'RubyPython Legacy Mode Module' do
  before :all do
    require 'rubypython/legacy'
  end

  after :all do
    RubyPython::LegacyMode.teardown_legacy
  end

  describe "when required" do
    it "should enable legacy mode" do
      RubyPython.legacy_mode.should == true
    end

    [
      ["an int", "an int", AnInt],
      ["a float", "a float", AFloat],
      ["a string", "a string", AString],
      ["a list", "an array", AnArray],
      ["a tuple", "an array", AnArray],
      ["a dict", "a hash", AConvertedHash],
      ["python True", "true", true],
      ["python False", "false", false],
      ["python None", "nil", nil]
    ].each do |py_type, rb_type, output|
      it "implicitly converts #{py_type} to #{rb_type}" do
        @objects.__send__(py_type.sub(' ', '_')).should == output
      end
    end

    [
      ["proc", AProc],
      ["method", AMethod]
    ].each do |rb_type, rb_obj| 
      it "raises an exception if a #{rb_type} callback is supplied" do
        lambda do
          @objects.apply_callback(rb_obj, [1, 1])
        end.should raise_exception(RubyPython::Conversion::UnsupportedConversion)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rubypython-raspi-0.1.2 spec/legacy_spec.rb
rubypython-raspi-0.1.1 spec/legacy_spec.rb
rubypython-raspi-0.1.0 spec/legacy_spec.rb
rubypython-0.6.2 spec/legacy_spec.rb
rubypython-0.6.1 spec/legacy_spec.rb
rubypython-0.6.0 spec/legacy_spec.rb
rubypython-0.5.3 spec/legacy_spec.rb
rubypython-0.5.2 spec/legacy_spec.rb
rubypython-0.5.1 spec/legacy_spec.rb
rubypython-0.5.0 spec/legacy_spec.rb