[rspec-users] Data-wise context combination for controller speccing

Costa Shapiro costa at mouldwarp.com
Wed Jul 21 15:58:21 EDT 2010

Thank you very much for your valuable feedback.

First, the example is a toy example of course, while the idea of
mixing-matching contexts is not. Note that it would be a totally
backward-compatible enhancement to rspec, and that a developer would still
be in full control of what gets mixed-matched.

Then, the subject might been confusing (not to mention the unsuccessful
suggested syntax), as the idea is not necessarily coupled with data
I accept the criticism about over-mocking, and even more than that, I find
mocking AR extremely tedious, that's why I've initially thought of coming up
with something like http://github.com/costa/rspec-orm (there will be a
separate mail on that, please don't comment it here just yet).

I hope I'll bring some sort of POC -- which will be working for me at least
-- soon. Any comments or suggestions are more than welcome.


On 19 July 2010 11:12, Wincent Colaiuta <win at wincent.com> wrote:

> El 19/07/2010, a las 16:20, Phillip Koebbe escribió:
> > On 2010-07-19 5:38 AM, Wincent Colaiuta wrote:
> >> I don't necessarily think so. Matt says you can probably do this right
> now by using macros. I don't actually know what he means by that, but I do
> know that there are cases where I sometimes want a bunch of nearly identical
> specs, and I generate them in code using enumeration or some other means;
> ie. dumb example:
> >>
> >>    [:foo, :bar, :baz].do |thing|
> >>      describe "#{thing} dimensions" do
> >>        it 'has length' do
> >>          thing.to_s.length.should>  0
> >>        end
> >>      end
> >>    end
> >>
> >
> > Glad to see I'm not the only one that does this. :)
> Yeah, I think it's a legitimate technique, as long as you don't get too
> carried away with it.
> I use it, for example, for some code quality specs:
>  Wincent::SOURCE_FILES.each do |file|
>    describe file do
>      it 'contains no trailing whitespace' do
>        file.should_not have_trailing_whitespace
>      end
>      it 'contains no tabs' do
>        file.should_not contain_tabs
>      end
>      it 'has a newline at the end' do
>        file.should have_newline_at_end_of_file
>      end
>    end
>  end
> Cheers,
> Wincent
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100721/6238cc0e/attachment.html>

More information about the rspec-users mailing list