Overall I liked this book However if you have worked with rspec before you re going to end up skimming a lot of this book as the basics are thoroughly covered Also if you don t have a strong background in TDD then I think some of the book s message is lost on you All in all then there s a niche here that limits the appeal of this book On top of that the material will age quickly the cucumber stuff already has and I suspect in a year or two s time the book s content will have some significant gaps or shortcomings Partly due to the nature of the project and partly because you can smell the bleeding edge of design here.The prose has the characteristic PragProg hallmarks the editors are really good at PragProg I think in that it is simple, direct and pleasant to read there s no feeling of being talked down to or suffering through the written equivalent of muzak the authors build through the concepts with some neat examples and give a good feel for the cycle of development that they re expounding There were tips and tricks I learnt as I followed along and the repetition helped cement the learning.In conclusion, buy it now, read it now or leave it forever is my advice. Solid introduction to the subjects of writing Test Behavior driven code Like any programming book that s than a week old, it s a bit dated ie RSpec now use expect instead of should methods But overall, as someone new to the subject, I got a lot out of it The big lesson I came away with as a developer and somewhat related to life in general Red, green, refactor I love the concept of call the method you wish you had , watch it fail red because that method doesn t exist, then write the method just to get it to work and don t worry about writing Good code be a duct tape developer green , and then make the code elegant under the protection of tests that make sure you don t break anything refactor I love this idea of giving yourself permission to write bad code in the short term Part of what makes coding hard is feeling like there s a better way to do it Of course there is And this system allows you to find that way using the net of tests. Ta ksi ka nie jest o RSpecu, ani o Cucumberze Ta ksi ka nie jest o Ruby m Ta ksi ka nie jest nawet o BDD To wszystko tylko narz dzia.No, the meme is than any one of those things The meme is asynergistic witches brew of some of the most contagious and effectiveideas of the past two decades The meme is.Dare I say it The meme is Craftsmanship.Na przyk adzie Cucmbera, Rspeca i Ruby ego oczywi cie autorzy przedstawiaj zawi o ci testowania wg filozofii BDD Jedne rozdzia y s lepsze, inne gorsze wyra nie wida pi ra r nych autor w , niekt re wydaj si niekompletne ca o jest jednak solidnym wprowadzeniem do tematu.By soft powstawa lepszy, a nam y o si dostatniej. It s a good book, although currently quite dated.All examples use the should notation, while current best practices use the expect notation. The book is or less a duplex book The first part of the book gives a decent introduction to Behavior Driven Development and how Cucumber and RSpec ideally are used in context of BDD as a methodology The value of this book lies in those chapters It s important to understand the context in which tools were born and the ideas behind them If you leave those bits and pieces out, you ll easily end up with a narrowed view of them, that doesn t seem to add much value Like DHHs view of Cucumber as a heavy integration testing framework or RSpec as a noisy test unit replacement I can only recommend spending some time with the ideas behind BDD or Specification By Example for that matter because I think agile teams greatly benefit from the side effects of those practices Be it living documentation, a shared understanding, improved communication and collaboration or implicit knowledge transfer And this book does quite a good job of explaining those ideas in the context of actual code I also like that they pick up the discussion of what to test and how to test different parts of an application Surprisingly few development teams have a well defined out testing strategy for their application that plays well with their development process The second part is or less a reference on RSpec, Cucumber and RSpec Rails Mostly stuff that is also available online in the documentation of those tools If you ve worked with RSpec or Cucumber before, you won t learn much new in those chapters, but it s a solid reference. BDD Behaviour Driven Development Acceptance Test Driven Planning is one of three practices of BDD Itis an extension of Acceptance Test Driven Development The difference between ATDP and ATDD is simple ATDD specifies thatwe write acceptance tests before we write code, but it doesn t specifywhen we should write them.ATDP specifies that the acceptance tests are agreed on during or pos sibly before, but no later than, an iteration planning meeting This lets us consider the acceptance criteria in our estimates, which improves our ability to plan iterations, which is why it s called Acceptance Test Driven Planning The Scenario keyword is followed by a string and then a series of steps Each step begins with any of five keywords Given, When, Then, And, and But Given steps represent the state of the world before an event When steps represent the event Then steps represent the expected outcomes And and But steps take on the quality of the previous step In the start game scenario, the And step is a second Then a second expected outcome 111 Perhaps you re wondering why we d want to do exploratory testing if we ve already tested the app Well, we haven t Remember that BDD isa design practice, not a testing practice We re using executable exam ples of how we want the application to behave 112 We were able to refactor with confidence because we ran the specs between each step, so we always knew right away when we introduced a problem We looked at two structural refactorings in detail Extract Method and Extract Class We also talked about a few specific code smells Temporary Variable, Long Method, and Large Class 121 You Can Always Roll BackThings don t always work out quite this cleanly Sometimes we ll try toexperiment like this and run into failure after failure after failure.When that happens to you, and it will, don t let it go on too long before rolling back to the last point at which all examples were passing Then you can proceed forward again in smaller steps 125 How Traditional Projects FailTraditional projects fail for all sorts of reasons A good way to identify the different failure modes is to ask your project manager what keeps them up at night It s nice to do this from time to time anyway it helps their self esteem It is likely your project manager will come up with a list of fears similar to ours 127 Now, because we are responsible adults, we have a Testing phase where we test the software to make sure it does what it was supposed to do This phase contains activities with names like user acceptance testing or performance testing to emphasize that we are getting closer to the users now and the final delivery 131 The Agile ManifestoWe are uncovering better ways of developing software by doing it andhelping others do it Through this work we have come to value Individuals and interactions over processes and tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding to change over following a planThat is, while there is value in the things on the right, we value the things on the left 136 Getting software into formally controlled environments puts us at odds with the corporate governance structures But if we can t get into production frequently, there is arguably little value in all the other stuff It may still be useful for the team s benefit, but software doesn t start making money until it s in production Remember, we want to be writing software that matters 139 Three principles of BDD Enough is enough Up front planning, analysis, and design all havea diminishing return We shouldn t do less than we need to getstarted, but any than that is wasted effort This also appliesto process automation Have an automated build and deployment,but avoid trying to automate everything Deliver stakeholder value If you are doing something that isn t either delivering value or increasing your ability to deliver value, stop doing it, and do something else instead It s all behavior Whether at the code level, the application level, or beyond, we can use the same thinking and the same linguistic constructs to describe behavior at any level of granularity 144 Many people use the words feature and story interchangeably,but there is a subtle difference A feature is something thatdelivers cohesive value to a stakeholder A story is a piece ofdemonstrable functionality that shouldn t take than a fewdays to implement So, the feature is useful from the pointof view of the stakeholder, and the story is useful from thepoint of view of the team delivering the feature 146 A story consists of a number of components A title so we know which story are we talking about A narrative that tells us what the story is about Acceptance criteria so we know when we are done.Regarding narrative the most common format for this is known as the Connextra format, after the company where it was first used as a stakeholder , I want feature so that benefit 147 We use the slightly artificial structure of givens, events, and outcomes to describe these scenarios This doesn t mean that every scenario has exactly one Given, When, and Then in that order Rather, it means that each step is either setting something up in a known state a given or exercising some behavior an event or verifying something happened an outcome Trying to do than one of these in a single step usually ends up in confusion. Behaviour Driven Development BDD Gives You The Best Of Test Driven Development, Domain Driven Design, And Acceptance Test Driven Planning Techniques, So You Can Create Better Software With Self Documenting, Executable Tests That Bring Users And Developers Together With A Common Language Get The Most Out Of BDD In Ruby With The RSpec Book, Written By The Lead Developer Of RSpec, David Chelimsky You Ll Get Started Right Away With RSpec And Cucumber By Developing A Simple Game, Using Cucumber To Express High Level Requirements In Language Your Customer Understands, And RSpec To Express Granular Requirements That Focus On The Behavior Of Individual Objects In The System You Ll Learn How To Use Test Doubles Mocks And Stubs To Control The Environment And Focus The RSpec Examples On One Object At A Time, And How To Customize RSpec To Speak In The Language Of Your Domain You Ll Develop Rails Applications And Use Companion Tools Such As Webrat And Selenium To Express Requirements For Web Applications Both In Memory And In The Browser And You Ll Learn To Specify Rails Views, Controllers, And Models, Each In Complete Isolation From The Other Whether You Re Developing Applications, Frameworks, Or The Libraries That Power Them, The RSpec Book Will Help You Write Better Code, Better Tests, And Deliver Better Software To Happier Users A fabulous book about RSpec, a testing framework for the Ruby programming language Actually, this book is about much than just RSpec it s also about a bunch of other tools Cucumber, Webrat, and Selenium I rolled my eyes when I first saw this, but as I read it I saw that each of these are pieces to a much greater puzzle Behavior Driven Development BDD in Ruby.I rolled my eyes at that too, because it just seemed like a fancy name for Test Driven Development, and it kind of is The only real difference is semantics, but what a difference semantics make I really saw how this paradigm and these tools take TDD to a whole new level As I made my way through this book, traditional testing tools seemed archaic by comparison RSpec is very sophisticated and expressive Isn t that what Ruby is all about I rolled my eyes at Cucumber too Cucumber is a mostly free form text language for writing specs and expectations for an overall system As just a programming tool, it s unnecessary, but this book helped me appreciate how Cucumber bridges the gap between the developers and the client boss producer etc Finally, the non techies can get their hands dirty and spell out exactly what they expect, and it can be programatically confirmed No wishy washy specs and arm waving This book made me a BDD convert Yes, I did a lot of eye rolling at first I prefer tools to be as simple as possible, but no simpler A good case must be made to add fancy features to something that is tried and true This book made a very good case. I have mixed opinions on this book On the one hand, there s a lot of solid theory here on the philosophy and practice of TDD and a lot of solid practical instruction in implementing Rspec in a Rails app However, the book is so unbearably out of date that trying to follow along with their code is a challenge The early parts explaining Cucumber and Rspec in Ruby script were pretty straightforward with a couple of agonizing syntax differences that took hours of research to discover However, toward the end of the book as they started diving into Rspec in an actual application the syntax and approach differed so wildly from the current version that I had to put the book down and follow tutorials on the internet to vaguely reproduce the results indicated Of course, the publishers will tell you that you should simply use the same version of Rails and Rspec that the book uses, but what good does it do me to learn how to run tests in a Rails app that old Basically, solid theory but all of the specifics need to be updated, and it s a shame that there isn t a recent book about Rspec. I read some parts and skimmed other parts The discussion around BDD is really interesting and looks to be really useful as part of a continuous delivery pipeline I skimmed over the Ruby specific portions probably the last half of the book only because I m currently working on a project with Flash front end and a Java back end I suspect we ll end up using cuke4duke in concert with Cucumber to get our UAT automated The ability to use the tests as documentation for system functionality looks like it will be very useful I d probably would ve rated the book higher if I was a Ruby developer because the authors are very good at pointing out the various land mines as well as discussing the pros and cons of different approaches to certain problems.
Is a well-known author, some of his books are a fascination for readers like in the
- 426 pages
- The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends
- David Chelimsky
- 19 March 2019 David Chelimsky