<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Avranade</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Avranade"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Avranade"/>
	<updated>2026-05-17T09:21:33Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70589</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70589"/>
		<updated>2012-11-19T15:48:17Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implement the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://java.dzone.com/articles/design-patterns-visitor : The article explains the use of the Visitor pattern in Java. A real world analogy is given initially and then Java implementation of a Visitor pattern is explained. The author maintains a good flow and then concludes with a mention of few disadvantages of the pattern&lt;br /&gt;
&lt;br /&gt;
* http://www.javaworld.com/javatips/jw-javatip98.html : This article provides a very detailed example of a Visitor pattern implementation in Java. The author guides the reader through each step, explaining the process as he goes along&lt;br /&gt;
&lt;br /&gt;
* http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html : The article starts of by providing a brief description of the pattern, it's advantages and disadvantages and then provides a detailed example of the Visitor pattern. The flow is good and the code example is good, but the explanation of the code is not provided. However the code is quite self explanatory&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern#Java_example : Another good example of the Java implementation obtained from Wikipedia&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provide examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
Following are the links which provide examples based on Ruby&lt;br /&gt;
&lt;br /&gt;
*http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby : This link provides a good discussion about all design patterns including the Visitor pattern. Implementation is done in Ruby and there are sufficient code examples&lt;br /&gt;
&lt;br /&gt;
*https://gist.github.com/989193 : This link provides a singular example of Ruby implementation of the Visitor pattern&lt;br /&gt;
 &lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Tutorials:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk : Provides a brief explanation of the motivation behind Visitor patterns, an example, a simple UML diagram for the pattern and mentions advantages of using the pattern&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw : Similar to the example before, but provides a sample Java implementation as well&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70588</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70588"/>
		<updated>2012-11-19T15:47:14Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://java.dzone.com/articles/design-patterns-visitor : The article explains the use of the Visitor pattern in Java. A real world analogy is given initially and then Java implementation of a Visitor pattern is explained. The author maintains a good flow and then concludes with a mention of few disadvantages of the pattern&lt;br /&gt;
&lt;br /&gt;
* http://www.javaworld.com/javatips/jw-javatip98.html : This article provides a very detailed example of a Visitor pattern implementation in Java. The author guides the reader through each step, explaining the process as he goes along&lt;br /&gt;
&lt;br /&gt;
* http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html : The article starts of by providing a brief description of the pattern, it's advantages and disadvantages and then provides a detailed example of the Visitor pattern. The flow is good and the code example is good, but the explanation of the code is not provided. However the code is quite self explanatory&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern#Java_example : Another good example of the Java implementation obtained from Wikipedia&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provide examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
Following are the links which provide examples based on Ruby&lt;br /&gt;
&lt;br /&gt;
*http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby : This link provides a good discussion about all design patterns including the Visitor pattern. Implementation is done in Ruby and there are sufficient code examples&lt;br /&gt;
&lt;br /&gt;
*https://gist.github.com/989193 : This link provides a singular example of Ruby implementation of the Visitor pattern&lt;br /&gt;
 &lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Tutorials:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk : Provides a brief explanation of the motivation behind Visitor patterns, an example, a simple UML diagram for the pattern and mentions advantages of using the pattern&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw : Similar to the example before, but provides a sample Java implementation as well&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70587</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70587"/>
		<updated>2012-11-19T15:43:46Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://java.dzone.com/articles/design-patterns-visitor : The article explains the use of the Visitor pattern in Java. A real world analogy is given initially and then Java implementation of a Visitor pattern is explained. The author maintains a good flow and then concludes with a mention of few disadvantages of the pattern&lt;br /&gt;
&lt;br /&gt;
* http://www.javaworld.com/javatips/jw-javatip98.html : This article provides a very detailed example of a Visitor pattern implementation in Java. The author guides the reader through each step, explaining the process as he goes along&lt;br /&gt;
&lt;br /&gt;
* http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html : The article starts of by providing a brief description of the pattern, it's advantages and disadvantages and then provides a detailed example of the Visitor pattern. The flow is good and the code example is good, but the explanation of the code is not provided. However the code is quite self explanatory&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern#Java_example : Another good example of the Java implementation obtained from Wikipedia&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provide examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
Following are the links which provide examples based on Ruby&lt;br /&gt;
&lt;br /&gt;
*http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby : This link provides a good discussion about all design patterns including the Visitor pattern. Implementation is done in Ruby and there are sufficient code examples&lt;br /&gt;
&lt;br /&gt;
*https://gist.github.com/989193 : This link provides a singular example of Ruby implementation of the Visitor pattern&lt;br /&gt;
 &lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Tutorials:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70586</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70586"/>
		<updated>2012-11-19T15:43:06Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor : The article explains the use of the Visitor pattern in Java. A real world analogy is given initially and then Java implementation of a Visitor pattern is explained. The author maintains a good flow and then concludes with a mention of few disadvantages of the pattern&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html : This article provides a very detailed example of a Visitor pattern implementation in Java. The author guides the reader through each step, explaining the process as he goes along&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html : The article starts of by providing a brief description of the pattern, it's advantages and disadvantages and then provides a detailed example of the Visitor pattern. The flow is good and the code example is good, but the explanation of the code is not provided. However the code is quite self explanatory&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example : Another good example of the Java implementation obtained from Wikipedia&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provide examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
Following are the links which provide examples based on Ruby&lt;br /&gt;
&lt;br /&gt;
*http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby : This link provides a good discussion about all design patterns including the Visitor pattern. Implementation is done in Ruby and there are sufficient code examples&lt;br /&gt;
&lt;br /&gt;
*https://gist.github.com/989193 : This link provides a singular example of Ruby implementation of the Visitor pattern&lt;br /&gt;
 &lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Tutorials:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70579</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70579"/>
		<updated>2012-11-19T12:55:31Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provide examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
Following are the links which provide examples based on Ruby&lt;br /&gt;
&lt;br /&gt;
*http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby : This link provides a good discussion about all design patterns including the Visitor pattern. Implementation is done in Ruby and there are sufficient code examples&lt;br /&gt;
&lt;br /&gt;
*https://gist.github.com/989193 : This link provides a singular example of Ruby implementation of the Visitor pattern&lt;br /&gt;
 &lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Tutorials:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70554</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70554"/>
		<updated>2012-11-19T07:44:22Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provide examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
*http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
Following are the links which provide examples based on Ruby&lt;br /&gt;
&lt;br /&gt;
*http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby : This link provides a good discussion about all design patterns including the Visitor pattern. Implementation is done in Ruby and there are sufficient code examples&lt;br /&gt;
&lt;br /&gt;
*https://gist.github.com/989193 : This link provides a singular example of Ruby implementation of the Visitor pattern&lt;br /&gt;
 &lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Tutorials:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70553</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70553"/>
		<updated>2012-11-19T07:40:06Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
*http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
==Links to Video Lectures:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70552</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70552"/>
		<updated>2012-11-19T07:39:47Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
*http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links to Video Lectures:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70551</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70551"/>
		<updated>2012-11-19T07:39:30Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
*http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links to Video Lectures:==&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70550</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70550"/>
		<updated>2012-11-19T07:31:47Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html : One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor : This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx : Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 : A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
*http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html : This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/ : The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html : The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70549</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70549"/>
		<updated>2012-11-19T07:30:31Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html &lt;br /&gt;
This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html &lt;br /&gt;
One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor &lt;br /&gt;
This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx &lt;br /&gt;
Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 &lt;br /&gt;
A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
*http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html &lt;br /&gt;
This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70548</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70548"/>
		<updated>2012-11-19T07:30:09Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html &lt;br /&gt;
This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html &lt;br /&gt;
One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor &lt;br /&gt;
This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx &lt;br /&gt;
Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 &lt;br /&gt;
A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html &lt;br /&gt;
This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70547</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70547"/>
		<updated>2012-11-19T07:29:02Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html &lt;br /&gt;
This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html &lt;br /&gt;
One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor &lt;br /&gt;
This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx &lt;br /&gt;
Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 &lt;br /&gt;
A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : &lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
** http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html &lt;br /&gt;
This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70546</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70546"/>
		<updated>2012-11-19T07:27:00Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html &lt;br /&gt;
This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html &lt;br /&gt;
One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor &lt;br /&gt;
This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx &lt;br /&gt;
Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 &lt;br /&gt;
A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html &lt;br /&gt;
This page explains visitor pattern in detail from the basics till implementation using C++. It has implementation details and also discusses issues that could possibly arise when using the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
The author sets up the explanation by using the example of an Abstract syntax tree traversal. A brief comparison is also provided about the differences in a Java implementation and a Python implementation for the same.&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
The author presents a similar example as the link before. A point to note about this link, is that there is sufficient amount of code, but not enough explanation. However, the code is still useful.&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70545</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70545"/>
		<updated>2012-11-19T07:12:53Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html &lt;br /&gt;
This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern &lt;br /&gt;
Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html &lt;br /&gt;
One of the top visited sites for design pattern basics , oodesign.com has good introduction, examples and implementation details. Sample code is also available for the reader. The article is good not only from the point of view of explaining the motivation behind Visitor patterns, but also because it follows a good flow in setting up the topic, explanation using examples and concluding with a brief summary&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor &lt;br /&gt;
This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx &lt;br /&gt;
Simple introductory page which describes and talks about the pattern in short. It is a very 'bare-bones' reference article, but is a good introductory piece&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1 A comparison is provided between the 'before' and 'after' code based on the Visitor pattern implementation. This link and the next couple of links are part of the same discussion provided here : http://sourcemaking.com/design_patterns/visitor&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html &lt;br /&gt;
This page explains visitor pattern in detail from the basics upto implementation using C++ as language. It has implementation details and also have discussed issues that arise. &lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70544</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70544"/>
		<updated>2012-11-19T06:58:33Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
The Purpose of this article is to act as a &amp;quot;directory of sites&amp;quot;, or a simple quick jump page for the reader. The effort is to try and collect good sources (blog posts, forum chats, general articles etc.) which deal with the Visitor pattern and to make this available to the readers with summary. The readers can then explore the links provided, to understand certain topics that they are interested in. Readers are also encouraged to edit the document in case they are able to contribute good material.&lt;br /&gt;
Since this is just a quick jump page, there will be an apparent lack of examples. This is in line with the requirements given in the writeup, since we are re-directing you to pages where you will get plenty of information.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, the Visitor Pattern is a way of decoupling algorithms to be performed by an object. The way to do this is to create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
For more information on the Visitor pattern, you can visit the following links&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html : This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern : Wikipedia provides a good condensed view on the topic of the Visitor pattern. &lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
Now that some information is present about what the Visitor pattern is and what it should do, let us explore the motivation behind using the Visitor pattern. Some links are provided for the reader to explore the topic and a brief summary is presented to guide the reader&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern - Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html - One of the top visited sites for design pattern basics to implementation, oodesign.com has good introduction, implementation details.&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx - Simple introductory page which describes and talks about the pattern in short.&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
&lt;br /&gt;
* This page explains visitor pattern in detail from the basics upto implementation using C++ as language. It has implementation details and also have discussed issues that arise. http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70542</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w51 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w51_aa&amp;diff=70542"/>
		<updated>2012-11-19T06:43:28Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Visitor Pattern, Directory of sites=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
In Object Oriented Programming, visitor pattern is a way of decoupling algorithms to be performed by an object. The way to do this is create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.&lt;br /&gt;
&lt;br /&gt;
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html This page can provide more introductory information on visitor pattern&lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
* http://en.wikipedia.org/wiki/Visitor_pattern - Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.&lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html - One of the top visited sites for design pattern basics to implementation, oodesign.com has good introduction, implementation details.&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.&lt;br /&gt;
&lt;br /&gt;
* http://www.dofactory.com/Patterns/PatternVisitor.aspx - Simple introductory page which describes and talks about the pattern in short.&lt;br /&gt;
==Visitor Pattern in Java==&lt;br /&gt;
(1) http://java.dzone.com/articles/design-patterns-visitor&lt;br /&gt;
(2) http://www.javaworld.com/javatips/jw-javatip98.html&lt;br /&gt;
(3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html&lt;br /&gt;
(4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in C++==&lt;br /&gt;
Following are the links which provides examples based on C++:&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/1&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/3&lt;br /&gt;
&lt;br /&gt;
* http://sourcemaking.com/design_patterns/visitor/cpp/2&lt;br /&gt;
&lt;br /&gt;
* This page explains visitor pattern in detail from the basics upto implementation using C++ as language. It has implementation details and also have discussed issues that arise. http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Python==&lt;br /&gt;
Following are two links which provide good examples of implementation of visitor patterns in python:&lt;br /&gt;
&lt;br /&gt;
* https://chris-lamb.co.uk/2006/12/08/visitor-pattern-in-python/&lt;br /&gt;
&lt;br /&gt;
* http://curtis.schlak.com/2012/01/04/python-visitor-pattern-helper.html&lt;br /&gt;
&lt;br /&gt;
==Visitor Pattern in Ruby==&lt;br /&gt;
(1) https://gist.github.com/989193&lt;br /&gt;
(2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby&lt;br /&gt;
&lt;br /&gt;
==Advantages==&lt;br /&gt;
* This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html&lt;br /&gt;
&lt;br /&gt;
* The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability&lt;br /&gt;
&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
* http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/ This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. &lt;br /&gt;
&lt;br /&gt;
* http://www.oodesign.com/visitor-pattern.html This page describes issues with visitor pattern in section Specific problems and implementation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Video Lecture:&lt;br /&gt;
(1) https://www.youtube.com/watch?v=mTJodk3vfdk&lt;br /&gt;
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&amp;amp;feature=related&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes1.jpg&amp;diff=69055</id>
		<title>File:RottenPotatoes1.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes1.jpg&amp;diff=69055"/>
		<updated>2012-10-27T17:53:41Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Cucumber Test with Features and Scenarios&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes2.jpg&amp;diff=69054</id>
		<title>File:RottenPotatoes2.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes2.jpg&amp;diff=69054"/>
		<updated>2012-10-27T17:53:35Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Step for Home Page Passes&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes3.jpg&amp;diff=69053</id>
		<title>File:RottenPotatoes3.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes3.jpg&amp;diff=69053"/>
		<updated>2012-10-27T17:53:27Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes4.jpg&amp;diff=69052</id>
		<title>File:RottenPotatoes4.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes4.jpg&amp;diff=69052"/>
		<updated>2012-10-27T17:53:20Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes5.jpg&amp;diff=69051</id>
		<title>File:RottenPotatoes5.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:RottenPotatoes5.jpg&amp;diff=69051"/>
		<updated>2012-10-27T17:53:09Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Storyboard.jpg&amp;diff=69050</id>
		<title>File:Storyboard.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Storyboard.jpg&amp;diff=69050"/>
		<updated>2012-10-27T17:52:51Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Storyboard for the User Story&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BackgroundCucumber.jpg&amp;diff=69049</id>
		<title>File:BackgroundCucumber.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BackgroundCucumber.jpg&amp;diff=69049"/>
		<updated>2012-10-27T17:52:21Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cucumber Background&lt;br /&gt;
&lt;br /&gt;
Source : https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69048</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69048"/>
		<updated>2012-10-27T17:51:41Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note : &amp;lt;/b&amp;gt;All images used in this article have been taken from screen captures of Coursera video lectures available [https://class.coursera.org/saas-2012-003/class/index here]. All content is owned by original authors and there is no copyright infringement intended. References have been provided in the image descriptions wherever necessary&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Storyboard#Software Storyboard] is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) Source : https://class.coursera.org/saas-2012-003/class/index ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) https://class.coursera.org/saas-2012-003/class/index ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) https://class.coursera.org/saas-2012-003/class/index]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) https://class.coursera.org/saas-2012-003/class/index]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the [http://en.wikipedia.org/wiki/HAML HAML] for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) https://class.coursera.org/saas-2012-003/class/index]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) https://class.coursera.org/saas-2012-003/class/index]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) https://class.coursera.org/saas-2012-003/class/index]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69047</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69047"/>
		<updated>2012-10-27T17:50:15Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note : &amp;lt;/b&amp;gt;All images used in this article have been taken from screen captures of Coursera video lectures available [https://class.coursera.org/saas-2012-003/class/index here]. All content is owned by original authors and there is no copyright infringement intended. References have been provided in the image descriptions wherever necessary&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Storyboard#Software Storyboard] is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) Source : https://class.coursera.org/saas-2012-003/class/index ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the [http://en.wikipedia.org/wiki/HAML HAML] for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Storyboard.jpg&amp;diff=69046</id>
		<title>File:Storyboard.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Storyboard.jpg&amp;diff=69046"/>
		<updated>2012-10-27T17:49:33Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Storyboard for the User Story&lt;br /&gt;
&lt;br /&gt;
https://class.coursera.org/saas-2012-003/class/index&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69045</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69045"/>
		<updated>2012-10-27T17:46:39Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note : &amp;lt;/b&amp;gt;All images used in this article have been taken from screen captures of Coursera video lectures available [https://class.coursera.org/saas-2012-003/class/index here]. All content is owned by original authors and there is no copyright infringement intended. References have been provided in the image descriptions wherever necessary&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Storyboard#Software Storyboard] is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the [http://en.wikipedia.org/wiki/HAML HAML] for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69044</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69044"/>
		<updated>2012-10-27T17:45:49Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Note : &amp;lt;/b&amp;gt;All images used in this article have been taken from screen captures of Coursera video lectures available [here]. All content is owned by original authors and there is no copyright infringement intended. References have been provided in the image descriptions wherever necessary&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Storyboard#Software Storyboard] is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the [http://en.wikipedia.org/wiki/HAML HAML] for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69043</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69043"/>
		<updated>2012-10-27T17:40:44Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Storyboard#Software Storyboard] is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the [http://en.wikipedia.org/wiki/HAML HAML] for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69042</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69042"/>
		<updated>2012-10-27T17:39:56Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Storyboard#Software Storyboard] is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69041</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69041"/>
		<updated>2012-10-27T17:38:53Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning [http://en.wikipedia.org/wiki/Test-driven_development Test-Driven Development (TDD)]. Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The Storyboard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. E.g. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. E.g. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action.&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY principle]. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69040</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69040"/>
		<updated>2012-10-27T17:30:09Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped. (Click Image to expand) ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69039</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=69039"/>
		<updated>2012-10-27T17:28:06Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the  [http://www.themoviedb.org/ TMDb database] rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior-Driven Development (BDD)] basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68941</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68941"/>
		<updated>2012-10-27T02:56:16Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68937</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68937"/>
		<updated>2012-10-27T02:54:13Z</updated>

		<summary type="html">&lt;p&gt;Avranade: /* Further Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68934</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68934"/>
		<updated>2012-10-27T02:53:31Z</updated>

		<summary type="html">&lt;p&gt;Avranade: /* Further Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test Railscast on testing in Capybara] : Railscast on testing in Capybara.&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs Capybara and Cucumber] : Capybara and Cucumber.&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd The Truth about BDD] : The Truth about BDD.&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html BDD and RSpec] : BDD and RSpec.&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/ Cucumber and Capybara for Rails] : Cucumber and Capybara for Rails.&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/ Smelly Cucumbers] : Smelly Cucumbers.&lt;br /&gt;
[http://cukes.info/ Cucumber] : Cucumber.&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber Beginning with Cucumber] : Testing with Cucumber.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68930</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68930"/>
		<updated>2012-10-27T02:52:01Z</updated>

		<summary type="html">&lt;p&gt;Avranade: /* Further Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara Capybara] : Capybara introduction .&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test] : Railscast on testing in Capybara.&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs] : Capybara and Cucumber.&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd] : The Truth about BDD.&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html] : BDD and RSpec.&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/] : Cucumber and Capybara for Rails.&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/] : Smelly Cucumbers&lt;br /&gt;
[http://cukes.info/] : Cucumber&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber] : Testing with Cucumber&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68928</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68928"/>
		<updated>2012-10-27T02:49:53Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara] : Capybara.&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test] : Railscast on testing in Capybara.&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs] : Capybara and Cucumber.&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd] : The Truth about BDD.&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html] : BDD and RSpec.&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/] : Cucumber and Capybara for Rails.&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/] : Smelly Cucumbers&lt;br /&gt;
[http://cukes.info/] : Cucumber&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber] : Testing with Cucumber&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68922</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68922"/>
		<updated>2012-10-27T02:46:55Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
===The StoryBoard===&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad&amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
===Elaboration of the User Story===&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara] : Capybara&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test] : Railscast on testing in Capybara&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs] : Capybara and Cucumber&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd] : The Truth about BDD&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html] : BDD and RSpec&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/] : Cucumber and Capybara for Rails&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/] : Smelly Cucumbers&lt;br /&gt;
[http://cukes.info/] : Cucumber&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber] : Testing with Cucumber&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68920</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68920"/>
		<updated>2012-10-27T02:45:43Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
[https://github.com/jnicklas/capybara] : Capybara&lt;br /&gt;
[http://railscasts.com/episodes/275-how-i-test] : Railscast on testing in Capybara&lt;br /&gt;
[http://expertiza.csc.ncsu.edu/wiki/index.php/CSC/ECE_517_Fall_2012/ch1b_1w71_gs] : Capybara and Cucumber&lt;br /&gt;
[http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd] : The Truth about BDD&lt;br /&gt;
[http://benmabey.com/2008/05/10/slides-and-code-from-my-bddrspec-presentation.html] : BDD and RSpec&lt;br /&gt;
[http://www.allenwei.cn/cucumber-capybara-what-we-need-for-rails-integration-test/] : Cucumber and Capybara for Rails&lt;br /&gt;
[http://rubysource.com/smelly-cucumbers/] : Smelly Cucumbers&lt;br /&gt;
[http://cukes.info/] : Cucumber&lt;br /&gt;
[http://railscasts.com/episodes/155-beginning-with-cucumber] : Testing with Cucumber&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68913</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68913"/>
		<updated>2012-10-27T02:36:27Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
In summary, this article demonstrates the BDD/Cucumber test behaviour with the help of examples. It discusses the enhancement of Rotten Potatoes webpage for implementing a new feature, which is addition of a new movie by looking up the TMDb database rather than manually entering the movie name. This includes designing a Lo-Fi UI, writing scenarios and step definitions, even writing new methods for successfully executing the test cases using Cucumber. The article also introduces and explains the concept of Background in Cucumber, which helps in DRYing out the repeated code in scenarios of the same feature. The next chapter will discuss the TDD/RSpec behaviour and the approach to make all the scenarios pass. &lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68911</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68911"/>
		<updated>2012-10-27T02:35:35Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:BackgroundCucumber.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BackgroundCucumber.jpg&amp;diff=68907</id>
		<title>File:BackgroundCucumber.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BackgroundCucumber.jpg&amp;diff=68907"/>
		<updated>2012-10-27T02:33:41Z</updated>

		<summary type="html">&lt;p&gt;Avranade: Cucumber Background&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cucumber Background&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68902</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68902"/>
		<updated>2012-10-27T02:31:58Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
The actual code and logic for implementation of this action (search_tmdb) is discussed in later lectures which discuss the TDD (Test Driven Development) process&lt;br /&gt;
&lt;br /&gt;
So far we have considered the Sad path scenario. &lt;br /&gt;
 &lt;br /&gt;
Let us consider the happy path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add existing movie (happy path)&lt;br /&gt;
 &lt;br /&gt;
  When I fill in &amp;quot;Search Terms&amp;quot; with &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
  Then I should be on the RottenPotatoes home page&lt;br /&gt;
  And I should see &amp;quot;Inception&amp;quot;&lt;br /&gt;
  And I should see &amp;quot;PG-13&amp;quot;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For implementation of this, instead of the hard coded Controller method, an actual controller method will have to written which searches TMDb and returns the details of the movie which will then be added to the Rotten Potatoes database. (However, this implementation is out of scope for our article. Further details of this can be found in the TDD lectures of this series.)&lt;br /&gt;
&lt;br /&gt;
Now, the Happy and the Sad paths have some code in common which violates the DRY principle. So, to make it DRY, Cucumber offers a solution called Background &amp;lt;ref&amp;gt;Background in Cucumber, https://github.com/cucumber/cucumber/wiki/Background&amp;lt;/ref&amp;gt;. The steps which are common to both the paths are written in Background and those steps will run in the background before all the other scenarios. No matter what scenario one runs, the steps in the Background will run first, which will DRY out the code. This also helps in reducing the effort in case any steps leading up to the scenarios (setup) are to be modified. The tester will only have to change the code in one location. In this example there is only one happy path and sad path scenario  i.e. only two scenarios. However, in real world examples, there would be a larger list of scenarios which could have the same ‘setup’. The advantages of the Background facility are more pronounced in this case. &lt;br /&gt;
[[File:Background.jpg|200 px|thumb|center|The Cucumber Background ]]&lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68892</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68892"/>
		<updated>2012-10-27T02:24:09Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Test shown above has 6 steps (The logic and code for implementing this is provided in the TDD lectures in the Coursera series). &lt;br /&gt;
[[File:RottenPotatoes1.jpg|200 px|thumb|center|The Cucumber Test with Features and Scenarios ]]&lt;br /&gt;
&lt;br /&gt;
*First the test checks if the user is on the Home Page, viz. the Home page for the application exists. &lt;br /&gt;
*Next, it checks for presence of the link to “Search TMDb for movie”. The test essentially simulates what a normal user would do when testing the application manually. &lt;br /&gt;
*In the third step, the test populates the form for the Search, with a movie name that is not present in the TMDb (since this is a sad path implementation, the search should essentially fail.)&lt;br /&gt;
*Next, the test checks (simulates) if the link can be clicked. &lt;br /&gt;
*As a consequence of this, the user should navigate to the Rotten Potatoes home page. &lt;br /&gt;
*For a Sad path, the user is shown a message mentioning that there was no match, on the home page itself. &lt;br /&gt;
&lt;br /&gt;
When we run the test, since there is already a home page, the first step of the scenario passes. &lt;br /&gt;
[[File:RottenPotatoes2.jpg|200 px|thumb|center|Step for Home Page Passes. (Click Image to expand) ]]&lt;br /&gt;
In the second step of the scenario, there is no link on the view for adding a new movie. Hence the second step fails and the following steps are skipped. &lt;br /&gt;
[[File:RottenPotatoes3.jpg|200 px|thumb|center|However Step for the &amp;quot;search_tmdb&amp;quot; link fails and others after that are skipped ]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we add the link for the “search_tmdb” action. For this, the HAML for Search TMDb page should contain the following:&lt;br /&gt;
%h1 Search TMDb for a movie&lt;br /&gt;
 &lt;br /&gt;
= form_tag :action =&amp;gt; 'search_tmdb' do&lt;br /&gt;
 &lt;br /&gt;
  %label{:for =&amp;gt; 'search_terms'} Search Terms&lt;br /&gt;
  = text_field_tag 'search_terms'&lt;br /&gt;
  = submit_tag 'Search TMDb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are added into the end of &amp;lt;code&amp;gt;app/views/movies/index.html.haml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two lines in the above code will be expanded into the HTML code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;label for='search_terms'&amp;gt;Search Terms&amp;lt;/label&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input id=&amp;quot;search_terms&amp;quot; name=&amp;quot;search_terms&amp;quot;type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now there is a page and a link in place for the test. On running the test using Cucumber again, the test fails again. This is because there is still no method defined in the controller (movies_controller.rb) for actually searching in TMDb.&lt;br /&gt;
&lt;br /&gt;
[[File:RottenPotatoes4.jpg|200 px|thumb|center|The Link for search_tmdb is added to the view, but there is no method for search_tmdb in controller. Also there is no route. Hence these steps fail or are skipped ]] &lt;br /&gt;
&lt;br /&gt;
However the video tutorial in this discussion considers only the sad path scenario. To test this Sad path implementation, a dummy/fake method is defined in the movies_controller.rb which fails everytime, i.e. the search for the movie in TMDb never returns a match. &lt;br /&gt;
 &lt;br /&gt;
So, the following code for the fake controller method is added to the movies_controller.rb:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def search_tmdb&lt;br /&gt;
  # hardwire to simulate failure&lt;br /&gt;
  flash[:warning] = &amp;quot;'#{params[:search_terms]}' was not found in TMDb.&amp;quot;&lt;br /&gt;
  redirect_to movies_path&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and since a new method has been added, we need to add a route to this controller method too. The following route is added to routes.db, just before or just after &amp;lt;code&amp;gt;‘resources :movies’&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Route that posts 'Search TMDb' form&lt;br /&gt;
post '/movies/search_tmdb'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, on running the test again using Cucumber, every time the method is called, it returns a failure message (since it is hard-coded). This implies that the sad path implementation passed. &lt;br /&gt;
[[File:RottenPotatoes5.jpg|200 px|thumb|center|Dummy method added to controller for 'search_tmdb' and then a route is also added. The dummy method fails everytime thereby satisfying the sad path scenario ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68757</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68757"/>
		<updated>2012-10-27T01:25:50Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Topical References ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68751</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68751"/>
		<updated>2012-10-27T01:24:10Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
==Happy Path, Sad Path and Bad path &amp;lt;ref&amp;gt;http://www.nishantverma.com/2010/03/test-case-paths-happy-sad-bad.html&lt;br /&gt;
&amp;lt;/ref&amp;gt;==&lt;br /&gt;
Many of us are aware of the test cases being categorized as Positive or Negative test cases. Similarly, for testing using Rails Cucumber, the tests cases are being categorized as Happy, Sad of Bad. A test case that results in a positive result is called a Happy Path. Ex. On entering correct username and password on login page, the application logs the user in. &lt;br /&gt;
A test case that yields no result is called a Sad Path. Ex. Entering invalid username or password on login page, which normally returns an ‘Incorrect username or password’ message&lt;br /&gt;
A test case to handle an exceptional condition or situation, which the system should handle elegantly and show some message to the user is a Bad Path. E.g. Uploading image size exceeds a limited amount. User can then take corrective action&lt;br /&gt;
&lt;br /&gt;
==Elaboration of the User Story==&lt;br /&gt;
Let us consider the sad path scenario for the Search TMDb User Story Feature.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
Feature: User can add movie by searching in The Movie Database(TMDb)&lt;br /&gt;
 &lt;br /&gt;
User Story:&lt;br /&gt;
As a movie fan&lt;br /&gt;
So that I can add new movies without manual tedium&lt;br /&gt;
I want to add movies by looking up their details in TMDb&lt;br /&gt;
 &lt;br /&gt;
Scenario: Try to add non-existent movie (sad path)&lt;br /&gt;
 &lt;br /&gt;
Given I am on the RottenPotatoes home page&lt;br /&gt;
Then I should see &amp;quot;Search TMDb for a movie&amp;quot;&lt;br /&gt;
When I ﬁll in &amp;quot;Search Terms&amp;quot; with &amp;quot;Movie That Does Not Exist&amp;quot;&lt;br /&gt;
And I press &amp;quot;Search TMDb&amp;quot;&lt;br /&gt;
Then I should be on the RottenPotatoes home page&lt;br /&gt;
And I should see &amp;quot;'Movie That Does Not Exist' was not found in TMDb.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68738</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68738"/>
		<updated>2012-10-27T01:20:52Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Closure_(computer_science) Wikipedia - Closures] : everything there is to know about Closures on one page.&lt;br /&gt;
&lt;br /&gt;
[http://weblog.raganwald.com/2007/01/closures-and-higher-order-functions.html Reg Braithwaite - Closures and Higher-Order Functions] : gives Ruby examples of specialized Closures.&lt;br /&gt;
&lt;br /&gt;
[http://ruby.runpaint.org/closures Closures in Ruby] : gives a detailed explanation of Closures in Ruby.&lt;br /&gt;
&lt;br /&gt;
[http://msdn.microsoft.com/en-us/magazine/ee309512.aspx MSDN Magazine - Functional Programming .NET Development] : examples of functional style with Closures in C#.&lt;br /&gt;
&lt;br /&gt;
[http://www.randomhacks.net/articles/2007/02/01/some-useful-closures-in-ruby Eric Kidd - Some useful closures, in Ruby] : demonstrates more examples of curried and specialized Closures in Ruby.&lt;br /&gt;
&lt;br /&gt;
[http://onestepback.org/articles/invitationtoruby/reason4.html Jim Weirich - Top Ten Reasons I Like Ruby - Blocks and Closures] : provides several examples of how Closures can be useful in Ruby.&lt;br /&gt;
&lt;br /&gt;
[http://csharpindepth.com/Articles/Chapter5/Closures.aspx C# in Depth - The Beauty of Closures] : demonstrates Closures in C#.&lt;br /&gt;
&lt;br /&gt;
[http://martinfowler.com/bliki/Closure.html Martin Fowler - Closure] : provides a basic definition of Closures and gives a few very basic &lt;br /&gt;
examples. &lt;br /&gt;
&lt;br /&gt;
[http://jibbering.com/faq/notes/closures Javascript Closures] : demonstrates Javascript Closures in callbacks.&lt;br /&gt;
&lt;br /&gt;
[http://www.skorks.com/2010/05/closures-a-simple-explanation-using-ruby/ Alan Skorkin - Closures - A Simple Explanation] : gives a high-level overview of Closures using Ruby examples.&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-cb01097/index.html IBM Developerworks - Crossing borders : Closures] : gives Ruby examples where Closures are useful.&lt;br /&gt;
&lt;br /&gt;
[http://samdanielson.com/2007/9/6/an-introduction-to-closures-in-ruby Sam Danielson - An Introduction to Closures in Ruby] : high-level overview of using Closures in Ruby.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68736</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w26 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w26_aj&amp;diff=68736"/>
		<updated>2012-10-27T01:20:31Z</updated>

		<summary type="html">&lt;p&gt;Avranade: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SaaS 4.6 Enhancing Rotten Potatoes again=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The article is intended to be an accompaniment to the SaaS video lecture 4.6  titled “Enhancing Rotten Potatoes again” &amp;lt;ref name=&amp;quot;video&amp;quot;&amp;gt;Enhancing Rotten Potatoes again, http://www.youtube.com/watch?v=2l9uLw3y6J8&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;, part of the SaaS video lecture series for the Software Engineering for SaaS hosted on the Coursera learning network. &amp;lt;ref&amp;gt;Coursera, https://www.coursera.org/&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;The Rotten Potatoes webpage, designed in the previous lectures is enhanced for implementing a new feature to add a new movie by looking up the TMDb database&amp;lt;ref&amp;gt; TMDb — The Movie Database, http://www.themoviedb.org/&amp;lt;/ref&amp;gt; rather than manually entering the movie name. The flow of this article is as follows : &lt;br /&gt;
&lt;br /&gt;
*The scope of discussion &lt;br /&gt;
*Brief description of the storyboard used for the Lo-Fi UI design discussed in previous lectures in the video lecture series,&lt;br /&gt;
*Explanation of Sad path, Happy Path and Bad Path&lt;br /&gt;
*Description of the User Story developed in the video lecture &lt;br /&gt;
*Elaboration of the test scenarios written for the particular User story (including scenarios for happy and sad paths) in Cucumber&lt;br /&gt;
*Explanation of the Background facility in Cucumber&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The scope of this article is limited only to the scope covered in the video lecture. The lecture builds upon Behavior-Driven Development (BDD) basics discussed in the video lectures before it and sets the reader up for upcoming lectures concerning Test-Driven Development (TDD). Hence for the purpose of this article, it is assumed that the reader has already read the material and watched the video lectures before this one in the series. Hence the setup for Cucumber, Capybara and BDD basics are excluded from this article. The resources dealing with these can be found in the SaaS lectures 4.1 to 4.5 in the series. Similarly, the theory and implementation of TDD as well as further discussion on BDD is excluded from the scope of this article. More details on these can be found in lectures 4.7 to 5.11 of the SaaS lecture series .&amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A Brief Recap==&lt;br /&gt;
Behavior-Driven Development (BDD) is a specialized development process which concentrates more on the behavioral aspects of the application as against the actual implementation of the application. &amp;lt;ref&amp;gt;Software Engineering for SaaS, https://class.coursera.org/saas-2012-003/class/index &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Storyboards are used to show how UI changes based on user actions. Even if it is tedious to draw sketches and storyboards, it helps build a ‘bigger picture’ understanding of the flow of the application for the non-technical stakeholders.&lt;br /&gt;
 &lt;br /&gt;
Cucumber is one of the shining tools of Rails that is used for testing purposes. It acts as a halfway between the customer and the developer by converting user stories of 3x5 cards into tests.&lt;br /&gt;
These tests act as Acceptance tests for ensuring the satisfaction of the customer. Also, the tests act as Integration tests that ensures the communication between modules is consistent and correct&lt;br /&gt;
&lt;br /&gt;
==The User Story==&lt;br /&gt;
The aim of the User story described in the video is to add a new feature to the Rotten Potatoes web page, to add a new movie to the movies list on Rotten Potatoes page. But, for adding the movie to the list, it populates the data from TMDb rather than entering the information by hand. This is aimed at reducing repetitive work since the TMDb already has a good database of movies. &lt;br /&gt;
To do so, the ability to search TMDb from Rotten Potatoes home page needs to be incorporated in the webpage. Users can then search in TMDb if the movie is present in it and then its details can be imported into Rotten Potatoes. For integrating this feature into the application, first, a Lo-Fi UI and Storyboard is designed, which is described next.&lt;br /&gt;
&lt;br /&gt;
==The StoryBoard==&lt;br /&gt;
The Storyboard is to be interpreted as follows&lt;br /&gt;
When a person wants to add a new movie to the Movies list on Rotten Potatoes, he/she will enter the new movie name and click “Search”. The controller method should search the TMDb database for the given movie. If a match is found, i.e. the movie is present in the TMDb, then the “Match” page is displayed. If there is no match, otherwise “No Match” page is displayed. These two scenarios, are the Happy Path and Sad Path implementations respectively. &lt;br /&gt;
[[File:Storyboard.jpg|200 px|thumb|Center|The Storyboard for the User Story. (Click Image to expand) ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Closure_(computer_science) Wikipedia - Closures] : everything there is to know about Closures on one page.&lt;br /&gt;
&lt;br /&gt;
[http://weblog.raganwald.com/2007/01/closures-and-higher-order-functions.html Reg Braithwaite - Closures and Higher-Order Functions] : gives Ruby examples of specialized Closures.&lt;br /&gt;
&lt;br /&gt;
[http://ruby.runpaint.org/closures Closures in Ruby] : gives a detailed explanation of Closures in Ruby.&lt;br /&gt;
&lt;br /&gt;
[http://msdn.microsoft.com/en-us/magazine/ee309512.aspx MSDN Magazine - Functional Programming .NET Development] : examples of functional style with Closures in C#.&lt;br /&gt;
&lt;br /&gt;
[http://www.randomhacks.net/articles/2007/02/01/some-useful-closures-in-ruby Eric Kidd - Some useful closures, in Ruby] : demonstrates more examples of curried and specialized Closures in Ruby.&lt;br /&gt;
&lt;br /&gt;
[http://onestepback.org/articles/invitationtoruby/reason4.html Jim Weirich - Top Ten Reasons I Like Ruby - Blocks and Closures] : provides several examples of how Closures can be useful in Ruby.&lt;br /&gt;
&lt;br /&gt;
[http://csharpindepth.com/Articles/Chapter5/Closures.aspx C# in Depth - The Beauty of Closures] : demonstrates Closures in C#.&lt;br /&gt;
&lt;br /&gt;
[http://martinfowler.com/bliki/Closure.html Martin Fowler - Closure] : provides a basic definition of Closures and gives a few very basic &lt;br /&gt;
examples. &lt;br /&gt;
&lt;br /&gt;
[http://jibbering.com/faq/notes/closures Javascript Closures] : demonstrates Javascript Closures in callbacks.&lt;br /&gt;
&lt;br /&gt;
[http://www.skorks.com/2010/05/closures-a-simple-explanation-using-ruby/ Alan Skorkin - Closures - A Simple Explanation] : gives a high-level overview of Closures using Ruby examples.&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-cb01097/index.html IBM Developerworks - Crossing borders : Closures] : gives Ruby examples where Closures are useful.&lt;br /&gt;
&lt;br /&gt;
[http://samdanielson.com/2007/9/6/an-introduction-to-closures-in-ruby Sam Danielson - An Introduction to Closures in Ruby] : high-level overview of using Closures in Ruby.&lt;/div&gt;</summary>
		<author><name>Avranade</name></author>
	</entry>
</feed>