Rspec-rails: undefined method `its' for ..

Created on 13 Dec 2013  路  10Comments  路  Source: rspec/rspec-rails

Hello, just installed 'rspec-rails', '~> 3.0.0.beta' on my new Rails 4.0.2 project and I am getting undefined method its when I am trying something like

let(:user) { .... }
subject { user }

context '.....' do
  before {
    user.something = 'anything'
  }
  its(:valid?) { should be_true }
end

Did you guys renamed this method? Is it a bug?

It does work nicely when I use standard it block. But it's for :baby:. I would like to use the its block again.

Thank you

Most helpful comment

Hey guys, I just found this issue string after bashing my head against the wall as to why I couldn't use its anymore. It would be very helpful if you mentioned the separate 'its' gem in the readme!

README's aren't generally the place to list APIs that have been removed or moved in to another gem. We've gone out of our way to help users learn that it's been moved, though:

All 10 comments

We extracted this into rspec-its, you need to add that gem to your Gemfile gem 'rspec-its', '~> 3.0.0.pre' and then require it require 'rspec/its'

Just found it a minute ago. Thank you!

anyway the correct version is: gem 'rspec-its', '~> 0.0.1.pre'

I'm getting cannot load such file -- rspec/its

My Gemfile.lock looks like this

rspec-collection_matchers (0.0.2)
      rspec-expectations (>= 2.99.0.beta1)
    rspec-core (3.0.0.beta1)
      rspec-support (= 3.0.0.beta1)
    rspec-expectations (3.0.0.beta1)
      diff-lcs (>= 1.1.3, < 2.0)
      rspec-support (= 3.0.0.beta1)
    rspec-its (0.0.1.pre)
    rspec-mocks (3.0.0.beta1)
      rspec-support (= 3.0.0.beta1)
    rspec-rails (3.0.0.beta1)
      actionpack (>= 3.0)
      activemodel (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-collection_matchers
      rspec-core (= 3.0.0.beta1)
      rspec-expectations (= 3.0.0.beta1)
      rspec-mocks (= 3.0.0.beta1)
    rspec-support (3.0.0.beta1)

I'm using Rails 4.0.1 and Ruby 2.1.0

Never mind, upgraded rspec-its to 1.0.0.pre and it's working now

I have rspec-its gem installed but still getting the above error

in Gemfile

gem 'rspec-rails', '~> 3.0.0.beta'
gem 'rspec-its', '~> 0.0.1.pre'

error

undefined method `its' for RSpec::ExampleGroups::Payment_2::PgRefNum:Class   
(NoMethodError)

for code

describe "#pg_ref_num" do
  its(:pg_ref_num) { should be_empty }
  ...
end

Per the installation instructions you need to require it before your specs are loaded.

ah. Well that's a stupid mistake from me. Thanks.

Hey guys, I just found this issue string after bashing my head against the wall as to why I couldn't use its anymore. It would be very helpful if you mentioned the separate 'its' gem in the readme!

Hey guys, I just found this issue string after bashing my head against the wall as to why I couldn't use its anymore. It would be very helpful if you mentioned the separate 'its' gem in the readme!

README's aren't generally the place to list APIs that have been removed or moved in to another gem. We've gone out of our way to help users learn that it's been moved, though:

Was this page helpful?
0 / 5 - 0 ratings