Sha256: a9f80133f3e59027aa4689bc85d8021782bda6ceb2b159f0b236b6771e6e204a

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require "test_helper"

describe "Querying for functions" do

  before(:all) do
    @functions_source = RbGCCXML.parse(full_dir("headers/functions.h")).namespaces("functions")
  end

  specify "should be able to find all functions" do
    @functions_source.functions.length.should == 4
  end

  specify "can find functions by name" do
    # Short-hand finding does #find(:name => "")
    test1 = @functions_source.functions("test1")
    test1.should be_a_kind_of(RbGCCXML::Function)
    test1.name.should == "test1"

    bool = @functions_source.functions.find(:name => "bool_method")
    bool.should be_a_kind_of(RbGCCXML::Function)
    bool.name.should == "bool_method"
  end

  specify "should not have a classes finder" do
    test1 = @functions_source.functions("test1")
    lambda do
      test1.classes  
    end.should raise_error(RbGCCXML::NotQueryableException)
  end

  specify "should not have a namespaces finder" do
    test1 = @functions_source.functions("test1")
    lambda do
      test1.namespaces
    end.should raise_error(RbGCCXML::NotQueryableException)
  end

  specify "should not have a functions finder" do
    test1 = @functions_source.functions("test1")
    lambda do
      test1.functions
    end.should raise_error(RbGCCXML::NotQueryableException)
  end

  specify "can get list of arguments" do
    test1 = @functions_source.functions("test1")
    test1.arguments.length.should == 2
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbgccxml-1.0.4 spec/functions_test.rb
rbgccxml-1.0.3 spec/functions_test.rb
rbgccxml-1.0.2 spec/functions_test.rb
rbgccxml-1.0.1 spec/functions_test.rb
rbgccxml-1.0 test/functions_test.rb