[rspec-users] old crumbly rspec

David Chelimsky dchelimsky at gmail.com
Wed May 26 17:46:13 EDT 2010


On May 26, 2010, at 4:05 PM, Nadal wrote:

> As David said, there is no difference between "it" and "specify". One
> of them is alias of other one. However semantically you can use them
> differently.
> 
> The two examples given below are same. However second one reads
> better. I like to use specify when I have explicitly created a
> subject. Implicit subjects read better with it.
> 
> describe User do
>  context "create a user" do
>    subject { User.create(:email => 'second at example.com') }
>    it { subject.id.should_not be_nil}
>  end
> end
> 
> describe User do
>  context "create a user" do
>    subject { User.create(:email => 'second at example.com') }
>    specify { subject.id.should_not be_nil}
>  end
> end
> 

In this case you can also use "its":

describe User do
  context "create a user" do
    subject { User.create(:email => 'second at example.com') }
    its(:id) { should_not be_nil}
  end
end

That doesn't always work out well, depending on how deep you need to dig into the subject, but it can work well in some cases.

Cheers,
David

> On May 26, 4:29 pm, David Chelimsky <dchelim... at gmail.com> wrote:
>> On May 26, 2010, at 3:23 PM, Tim Walker wrote:
>> 
>>> What is the functional difference between "it" and "specify"
>> 
>> None.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Thanks!
>> 
>>> Tim
>> 
>>> On Tue, May 25, 2010 at 5:18 PM, Matt Wynne <m... at mattwynne.net> wrote:
>>>> Cursory look at that blog post seems like it's covered most of what's in
>>>> this talk, but worth mentioning anyway, it's good:
>>>> http://pure-rspec-rubynation.heroku.com/
>>>> http://video2010.scottishrubyconference.com/show_video/3/1
>>>> On 24 May 2010, at 10:33, Andrew Premdas wrote:
>> 
>>>> Hi List,
>>>> Being pretty lazy here, but I figure you can help very quickly and others
>>>> might benefit from the results. I write old crumbly rspec (see
>>>> gisthttp://gist.github.com/411689), and I would like to improve, can you
>>>> take my crumbly spec and make it shiny?
>>>> Also if you can post any links to recent relevant blog articles that would
>>>> be much appreciated
>>>> Best one I can find at the moment is:
>>>> http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
>>>> TIA
>>>> Andrew
>>>> _______________________________________________
>>>> rspec-users mailing list
>>>> rspec-us... at rubyforge.org
>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>> 
>>>> _______________________________________________
>>>> rspec-users mailing list
>>>> rspec-us... at rubyforge.org
>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>> 
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-us... at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>> 
>> _______________________________________________
>> rspec-users mailing list
>> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list