Newbie gotchas in Sarah Mei's "Outside-In BDD: How?!" Cucumber tutorial - ruby-on-rails-3

I'm trying to learn Cucumber. After poking around a bit on SO I found a link to this tutorial. It was very helpful (and I recommend it highly!), but, for a beginner like myself, a couple of the early steps were opaque. I thought I'd explain these two pitfalls here, to spare future Cucumber students the head-scratching they caused me.
The two problems both came up in this section:
Starting the fail-fix cycle
I run it using cucumber features, and it fails on the first line –
Given I go to the new book page – because cucumber doesn’t know where
the “new book page” is. So I add that to the cucumber paths helper.
when /the new book page/
new_book_path
I had trouble interpreting this section and running her code.
My first question was: where do I find the cucumber paths helper file?
Once I figured it out and ran cucumber features, I got a syntax error.
My second question was how do I debug the syntax error that her code raises? I've tried to answer these two questions below.

First Gotcha: where the heck is the `cucumber paths helper'?
First off, she talks about adding a step to the cucumber paths helper. I struggled for a while to figure out where this file was located. I couldn't find anything with a similar name in my app, and google searches didn't yield any useful results. What was going on?
It turns out that I couldn't find the file because it's not automatically generated -- you need to create it yourself. Furthermore, the name of the file is totally arbitrary: it doesn't need to be called cucumber_paths_helper. That's why my google searches were fruitless.
For her code snippet to be executed it just needs to be in some file living in the features/support folder. All of the code in this directory is executed before any cucumber tests are run. The solution? I put her code into a new file at features/support/manage_books_steps.rb.
Ok, one down...
Second Gotcha: syntax error, unexpected keyword_when
The next problem showed up when I tried to run cucumber features. I got this:
/Users/dB/myApp/features/support/manage_books_steps.rb:1: syntax error, unexpected keyword_when
when /the new book page/
^ (SyntaxError)
For some reason my system couldn't parse this code. I'm not sure why exactly, but I'm guessing that Sarah was using some gem or tool to preprocess her code that I didn't have installed, and she unfortunately didn't go into detail about her gemset in the article. (Maybe she wrote it before cucumber's training wheels came off?) In any case, after consulting some other cucumber tutorials I tried reformatting her snippet like so.
When /^I go to the new book page$/ do
visit new_book_path
end
This worked.
After getting past those two little obstacles, the rest of the tutorial was a synch.
Anyway, I hope this helps someone somewhere down the line. And thanks, Sarah, for a great tutorial.
Edits/comments/corrections are welcome.

Related

PackT book - Advanced Express Web App Dev

I am running into a MOCHA problem in reference to the book, Chapter 1, during the first run of MOCHA test. it saying that my /heartbeat is undefined and not a function. I have copied the book, and I have even backed dependencies back down to what the book used (not what is most current) and still having a failure. I have my development upto the point of the failure in the book on github here (https://github.com/EnergeticPixels/expressWebAppDev_packt.git). Can anyone help point me out my mistake??? It has to be something simple.
totally my fault. I missed a darn comma following the function name in the express/index.js file. Told ya it was a simple mistake.

Minecraft won't run. Multiple items cannot be resolved to a type

I just finished skating around that infamous "cannot load main class start" thing, and I got blindsided with a sea of errors:
A friend suggests it might have something to do with com.google, but ultimately can't help me.
I haven't made a single alteration to any of the code so far. Eclipse just started up not being able to run and stayed that way. I think there's a way to fix it but it would require making acute changes at the sight of every single error; work that could be wiped by a cleanup if I'm proved wrong.
Anyone have a clue what the issue is? Thank you for the trouble.
UPDATE: Adding guava as a library relieved the error involving com.google, but threw in a handful of others. This one class file contains 3 of the most common unresolved types I've seen scattered throughout: Logger/LogManagaer, PropertyMap, and CrashReport
Your general problems revolve around not having dependencies in the build path. Eclipse's error messages are pretty clear about this; e.g. if a package name is underlined in red and can't be found, then that means it can't be found, and the obvious solution is to add the library that provides it, so that it can be found.
In virtually all cases here, a Google search for the missing packages and classes will lead you to the packages that contain it.
For each unresolved dependency, find the library, add it to the build path, then move on.
I also suggest consulting the documentation that comes with the source code you are attempting to compile, which often simply lists the dependencies, thus saving you the trouble of hunting them down as you go.
While we could do the internet searches for you and hash this out one step at a time, it's both better and faster for you to do it yourself. Better because if you're messing around with Minecraft source, having at least a basic knowledge of how your tools work is going to help you (I also suggest some of the material at http://docs.oracle.com/javase/tutorial/). Faster because the turnaround time of typing package names into the Google search box is a heck of a lot faster than constantly updating your question here and waiting for replies.
It looks like you are missing the Google Collections package, which now is called Guava.
Download the jar file, and add it as a library.

Reference not found after switching from Debug to Release mode

I have a problem with several references in my VB.NET project.
For example I have this line of code:
Dim m As New Chilkat.Email
It comes from the library "ChilkatDotNet45.dll".
When I click on "References" and locate this dll, I can see that it has the settings "Use local copy" and "Do not include interop types".
When I switch to Release mode, the compiler tells me that "Chilkat.EMail" is not defined.
I have this problem with several DLLs, so it is not specific to Chilkat.
Can somebody tell me what I did wrong?
Thank you.
One of the standard approaches to solving any programming-related issue is trying to reduce the scope of the investigation. If you have a big project, in which something doesn't work, try to create a smaller project, and try to replicate desired functionality in it. Reduce as much as possible, down to a brand new project with maybe 5-10 lines of code in it.
If you were unable to solve your problem after making a reduced test case, now it's good time to post it on StackOverflow. I am usually reducing problems while writing a question on SO (not before, as one might think), constantly thinking "ok, is it minimized enough"; and this is how 90% of the questions never get posted - I often find a solution along the way of reducing my question to bare bones. :)
In your case, can you build a simplified project which has this problem and post a link here? We could then try switching Debug to Release on our machines and see if the we can reproduce. There are too many options to do the guesswork.

Test automation program

There is a program out there that I can't for the life of me remember the name of. I'm not sure if this is the correct forum to ask this but thought I'd give it a shot and see if anyone can help me out.
Program Description:
This program is for writing and running test automation. It allows you to write the steps of the test in English.
Example (scenario: posting stack overflow question):
Enter title 'XXX'
Enter Description
Enter tag 'X'
Click Post button
After entering the test steps in English sentences you can run the test. The test will come back yellow, saying that not all the steps are automated yet and create stub methods for each of the 4 steps mentioned above.
You can then go through the work of automating the different steps and running the tests.
Sorry if this sounds vague, but I remember looking at this piece of software last year and can't seem to find it or remember the name anymore.
Any ideas?
There's the Ruby Gem Cucumber.
That's Cucumber.
It will warn you if you have undefined scenarios or steps, and it will suggest some code snippets for those steps, as shown in this "10 min tutorial".

Using core plot with xcode 4

I am trying to use core plot with an ios app I am writing, but I am unable to build after following the instructions to set up the library for use. I am getting the following message.
'CorePlot0' does not contain a valid pid
Sorry the tutorial I used is here http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html
This has been asked (and answered) a number of times on this site alone. The most helpful suggestion on those (many) similar questions that reference the blog post you mentioned says you should read that post's comments since the post refers to older code.
If all else fails, create a new test project and try following the (comment-updated) instructions again. If it still doesn't work, update your question with much more detail regarding what you tried and where it went wrong. Include build logs, run logs, etc. - we're not mind readers.