Sha256: 761bd48f2de4b0e8ff919ecc2679d229c3d7d18b08545db65f69eb55389e92ad

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

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

include TestConstants

describe 'Callbacks' do
  {
    'procs' => AProc,
    'methods' => AMethod,
  }.each do |rb_type, rb_object|
    it "accepts #{rb_type} as functions" do
      [
        [2, 2],
        ["a", "Word"],
        [ [1, 2], [3, 4] ]
      ].each do |args|
        @objects.apply_callback(rb_object, args).should == rb_object.call(*args)
      end
    end
  end

  [
    ["an int", AnInt],
    ["a float", AFloat],
    ["a string", AString],
    ["a string with nulls", AStringWithNULLs],
    ["an array", AnArray],
    ["an array", AnArray],
    ["a hash", AConvertedHash],
    ["true", true],
    ["false", false],
    ["nil", nil]
  ].each do |rb_type, rb_value|
    it "is able to return #{rb_type}" do
      callback = Proc.new do 
        rb_value
      end

      @objects.apply_callback(callback, []).should == rb_value
    end
  end

  it "is able to be stored by python variables" do
    mockObject = @objects.RubyPythonMockObject.new
    mockObject.callback = AProc
  end

  it "is callable as a python instance variable" do
    mockObject = @objects.RubyPythonMockObject.new
    mockObject.callback = AProc
    mockObject.callback(2, 2).rubify.should == 4
  end

end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
lokeshh_rubypython-0.7.1 spec/callback_spec.rb
lokeshh_rubypython-0.7 spec/callback_spec.rb
rubypython-0.6.4 spec/callback_spec.rb
rubypython-0.6.3 spec/callback_spec.rb
rubypython-raspi-0.1.2 spec/callback_spec.rb
rubypython-raspi-0.1.1 spec/callback_spec.rb
rubypython-raspi-0.1.0 spec/callback_spec.rb
rubypython-0.6.2 spec/callback_spec.rb
rubypython-0.6.1 spec/callback_spec.rb
rubypython-0.6.0 spec/callback_spec.rb
rubypython-0.5.3 spec/callback_spec.rb
rubypython-0.5.2 spec/callback_spec.rb
rubypython-0.5.1 spec/callback_spec.rb
rubypython-0.5.0 spec/callback_spec.rb