On Friday, August 1, 2014 5:46:02 PM UTC-7, Kelly Stannard wrote: > > So, as we all know, we shouldn't use subject > <http://www.google.com/url?q=http%3A%2F%2Fblog.davidchelimsky.net%2Fblog%2F2012%2F05%2F13%2Fspec-smell-explicit-use-of-subject%2F&sa=D&sntz=1&usg=AFQjCNHthJxbMphFXn5fk_hk2oLX1ZsK7Q> > . >
I wouldn't say that. I would say that as David explained in the article, `subject` is rarely the best name for a particular object in a test, and using a more-intention revealing test will generally make your tests more clear and readable. But `subject` exists and has a completely valid purpose. Using it is fine, but please understand how it works and what tradeoffs you are making. > But what if you really like one liner syntax? > That's fine; the one liner syntax is the primary reason `subject` even exists. I personally use the one liner syntax very, very rarely, but I've also seen it used well. I think it works well with shoulda's matchers, for example. Or in mustermann: https://github.com/rkh/mustermann/blob/v0.2.0/spec/template_spec.rb It works quite well for cases like that. So if you like the one-liner syntax, understand how it works, and get benefit from it, then use it! This is just the basics and I am looking for feedback and more feature > ideas. Currently I am trying to figure out passing blocks and how #let fits > in. > > rspec-advanced_subject > <https://github.com/kwstannard/rspec-advanced_subject> > > Your gem looks interesting; thanks for sharing :). 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/96be219c-5895-4150-a494-29e17440e77f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
