[rspec-users] found some inconsistently behavior on its method.

Nori Hamamoto norisuke3 at gmail.com
Fri Jan 14 01:19:07 EST 2011


Hi there,

I've just started using rspec and rspec-rails (both are the newest version
on git repository).
I met some inconsistently behavior on it method and its method.
The following is the way to reproduce it:

command line:

> script/generate spec_controller product show

Modify a file spec/products_controller_spec.rb like the following:

require 'spec_helper'

describe ProductsController do
 describe Array do
   subject { Array.new }
   it { should be_empty }
   its(:size) { should == 0 }
 end
end

Then, when I run spec, the first example (it { should be_empty }) pass the
test, but not the second one(its(:size){ should == 0 }).
How so?

I've found a similar issue:

describe 10 do
  it { should == 10 }
  its(:to_s) { should == "10" }
end

The first one passes, but not for the second one.
Is this a bug on rspec 1.3.1?

Another example:

describe Array do
  its(:empty?) { should be_true } # pass
end

describe [] do
  its(:empty?) { should be_true } # not pass
end

The first one passes the test where as the second one doesn't pass.
So, what's going on on its method??

Thank you,
norisuke3 at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110114/9b5cc3b1/attachment.html>


More information about the rspec-users mailing list