1 Reply Latest reply on Aug 19, 2016 11:05 AM by Alex Epifanov

    Error when using stub for unit testing

    Lisa Tassone

      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?