[Kde-bindings] problem with calling signals in block associated with Class.new and rspec
Stefano Crocco
stefano.crocco at alice.it
Sun Nov 23 14:51:22 UTC 2008
I wanted to write a method which generates a Qt::Object-derived class which
defines signals determined at runtime. The definition of the method is the
following:
def MyModule.create *sigs
Class.new(Qt::Object) do
signals( *sigs)
end
end
This is called this way:
MyModule.create 's1(QString)', 's2(QObject*, QPoint)'
and returns a new class, derived from Qt::Object, which has the two signals
passed as argument.
When used by itself, this method works correctly, and returns a class which,
has a 's1' and a 's2' method among its instance methods. The problem is that I
want to test this code using RSpec. I do something like this:
describe 'MyModule.create' do
it 'should work' do
cls = MyModule::Signaler.create 's1()', 's2(QString)', 's3(QObject*)'
cls.instance_methods.should include('s1')
cls.instance_methods.should include('s2')
cls.instance_methods.should include('s3')
end
end
but it doesn't work. Indeed, looking at the contents of cls.instance_methods,
one can see that 's1', 's2' and 's3' aren't there. Now, I know it's very
likely you won't know RSpec and its internals, but I was wandering if you know
of some edge cases which can lead to the above behaviour. I tried to look at
the source for the signals method in the qtruby4.rb file, but I couldn't find
any hint on what may be failing.
Thanks in advance
Stefano
More information about the Kde-bindings
mailing list