Sent from my iPad
> On Jul 30, 2015, at 8:10 PM, Askar Karasaev <[email protected]> wrote: > > Hi Alex, > > I thought we should follow DRY concept so that I won't test one thing in more > than one method... Nope. The threshold for DRY in tests is higher, since tests have to be readable and since their targets can shift out from under them due to refactoring and normal code growth. Some people say tests should be MOIST :-) > > By "unit test", do you mean the default test of Rails? No, test and spec are synonymous. A spec is a test. A unit test tests a single unit in isolation. Even Rails model tests are not pure unit tests since they depend on a database, but they come close. Back in the day, the big distinction was between unit test and integration test -- the latter tests how a bunch of units work together but doesn't exercise every case of every unit; that's what unit tests are for. Basically, a unit test tests the code; an integration test tests the code working together with other units; a functional test tests the product. The terms and concepts are slippery but you'll get more comfortable with them with experience. > > Thanks, > Askar > >> On Thu, Jul 30, 2015 at 1:19 AM, Alex Chaffee <[email protected]> wrote: >> On Tue, Jul 28, 2015 at 8:06 PM, Askar Karasaev >> <[email protected]> wrote: >> > As I understood, I can test same things in models and feature specs, so I'm >> > wondering which is better? which is effective? >> >> Both. >> >> If I understand correctly, feature specs use Capybara which takes a >> relatively high-level pass through the app. It tests user input, HTML >> output, error handling, that sort of thing. Model specs are focused on >> a single object, so they test a wider range of scenarios, call >> individual methods, require much less setup, are faster, etc. >> >> I recommend a pyramid of test coverage: the base is unit tests >> (including model specs) -- make lots of those, fewer controller tests, >> and even fewer integration tests (including capybara). >> >> - A >> >> -- >> Alex Chaffee - [email protected] >> http://alexchaffee.com >> http://codelikethis.com >> http://twitter.com/alexch >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "rspec" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/rspec/FJcS2697KHA/unsubscribe. >> To unsubscribe from this group and all its topics, 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/CAMf%3DvNoQXZYeOG2R0TmMQzNGXrS2jGDYghnM4XdWO%3D6qcmFeVw%40mail.gmail.com. >> For more options, visit https://groups.google.com/d/optout. > > -- > 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/CAP4%3DRx-hNe%3Dg3VXiqrFBvmwZ4Wj3rOMcELtjr4OVe5ntkBkC1w%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- 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/912D3305-28B7-4617-80B2-0A9C0E92C2DB%40gmail.com. For more options, visit https://groups.google.com/d/optout.
