Hint needed to migrate rspec code

32 views
Skip to first unread message

hartmut bischoff

unread,
Feb 28, 2018, 4:13:21 PM2/28/18
to rspec
Hi everyone,

I am updating ib-ruby (https://github.com/ib-ruby/ib-ruby)
Some Code is written for Rspec 2 (I think), and  does not run anymore.

How to fix this:
describe IB::Bar,
         :props =>
             {:open => 1.31,
              :high => 1.35,
              :trades => 50,
              :time => "20120312  15:41:09",
             },

         :human =>
             "<Bar: 20120312  15:41:09 wap 1.32 OHLC 1.31 1.35 1.3 1.33 trades 50 vol 20000 gaps true>",

         :errors =>
             {:close => ["is not a number"],
              :volume => ["is not a number"]},

         :assigns =>
             {:has_gaps => {[1, true] => true, [0, false] => false},

              [:open, :high, :low, :close, :volume] =>
                  {[:foo, 'BAR', nil] => /is not a number/}
             } do # AKA IB::Bar

  it_behaves_like 'Model with invalid defaults'
  it_behaves_like 'Self-equal Model'
end

It gives a bunch of errors, like

  6) IB::Bar behaves like Model with invalid defaults instantiation with properties behaves like Model instantiated with properties auto-assigns all properties given to initializer
     Failure/Error:
       props.each do |name, value|
         # p name, subject.send(name), value
         subject.send(name).should == value
       end
    
       `example` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
     Shared Example Group: "Model instantiated with properties" called from ./spec/model_helper.rb:179
     Shared Example Group: "Model with invalid defaults" called from ./spec/models/ib/bar_spec.rb:33
     # (eval):2:in `rescue in props'
     # (eval):2:in `props'
     # ./spec/model_helper.rb:220:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     #   `metadata` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
     #   (eval):2:in `props'

Is there an easy way, to make the tests valid again  or do I have to write it new from stretch?

Thanks in advance

hartmut

Myron Marston

unread,
Feb 28, 2018, 4:14:09 PM2/28/18
to rs...@googlegroups.com
Please follow our RSpec 2 -> 3 upgrade guide:


If that doesn't work, let us know.

Thanks,
Myron



--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscribe@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/da2fafd4-6f1a-46de-8f0f-01ba89cb9f74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages