Error when using stub for unit testing

L Lisa Tassone 3 years 6 months ago
2 1 0

Hi there,

I'm in the process of creating unit tests and have got it up and running according to the rhodes documentation (which is rather sparse). I've got some tests working and am now onto a few more complicated tests and am trying to stub a module method. When I do the only error I get is Not implemented: only eval of block is supported. After searching the Rhodes source files it's something to do with its implementation of eval. I've tried removing the error exception in the source code and rebuilding (using rhosimulator as I have for my other tests) and I still get the error, so obviously it is ignoring my changes. I've tried cleaning the project etc but it doesn't seem to make any difference. I'm also checked to see how Rhodes do their own testing and they seem to be using stub in the same way.

This is the code:

require "./helpers/full_sync"
class Dummy
  include FullSync
end

describe "FullSync" do

  before :each do
  @Dummy = Dummy.new
  end

  describe ".perform_full_sync" do
       context "No data to upload" do
            it "should set Rho::RhoConfig.syncStatus to #{SYNC_STATUS_REQUESTING_DATA}" do
                 @Dummy.stub!(:check_data_to_upload).and_return(0)
                 @Dummy.perform_full_sync
                  etc etc
            end
       end
  end
end

What am I doing wrong?

Please Register or Login to post a reply

1 Replies

A Alex Epifanov

Hi Lisa,

quoting my answer at Zendesk:

"Rhosimulator is shipped prebuilt and changing source code of Ruby VM ( which I suppose you did ) will not apply changes to it. You can try however 'enable_eval=1' setting in rhoconfig.txt which seems to workaround an exception you get."

Regards,
Alex.

CONTACT
Can’t find what you’re looking for?