Friday, July 26, 2013

Hierarchy of Exceptions

Week 2 Day 9

Pass the Test

Hierarchy of Exceptions

Run tests: $ rspec spec/bundle_i_spec.rb
I got the test to pass after feeling like the ground beneath me had shifted. I was hanging onto a thread of barely even knowing what I was trying to do.
Hint 1 - Jessica @jendiamond I talked to Andre and he says this spec goes in spec/other/cli_dispatch_spec.rb. Please move it to there! It is a CLI Dispatch because the command line interface is trying to forward the argument 'i' to the proper command.
Hint 2 - Joyce The order matters. The hierarchy of code.
"So remember, your application errors should be subclasses of StandardError and if you want to catch everything, just stick will plain old “rescue => ex”. Your application will behave better for it.

Direct descendants of Exception:

NoMemoryError
ScriptError
StandardError
SignalException
fatal
SystemExit

Direct descendants of StandardError:

SystemStackError
LocalJumpError
IOError
RegexpError
ZeroDivisionError
ThreadError
SystemCallError
SecurityError
RuntimeError
NameError
RangeError
IndexError
ArgumentError
TypeError

I got it to pass!

$ rspec spec/bundle_i_spec.rb
Run options:
include {:focused=>true}
exclude {:ruby=>"1.8", :realworld=>true, :sudo=>true}
All examples were filtered out; ignoring {:focused=>true}
bundle i error
should not raise an error
Finished in 1.31 seconds
1 example, 0 failures

Other Things I Learned

  • empty? is a method some objects respond to. You need to check the documentation for each case. For example, and empty array is one that is not nil (it is an array right?) and has no elements. An empty string is one that is not nil (it is a string right?) and has no bytes, nothing.
  • I did this yesterday; I now realize why this is important.
    irb: StandardError.ancestors => [StandardError, Exception, Object, Kernel, BasicObject]
Before it was fixed it looked like this
bundle i
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:405:innormalize_task_name': Ambiguous task i matches [init, inject, install] (ArgumentError) from /var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:321:indispatch'
from /var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:instart' from /var/lib/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:20:inblock in '
from /var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:inwith_friendly_errors' from /var/lib/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:20:in' from /usr/local/bin/bundle:19:in load' from /usr/local/bin/bundle:19:in'
should not raise an error (FAILED - 1)
Previously when I ran the test $ rspec spec/bundle_i_spec.rb it looked like this:
Failures:
1) bundle i error should not raise an error
Failure/Error: expect(err).to be_empty
expected empty? to return true, got false
# ./spec/bundle_i_spec.rb:6:in `block (2 levels) in '
Finished in 1.16 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/bundle_i_spec.rb:4 # bundle i error should not raise an error

Wednesday, July 24, 2013

Grep

We are working on a Bundler Issues

https://github.com/bundler/bundler/issues/2550

grep
We did grep searches to help us find out what our problem with the testing is. We located a bundler.ui.error and went down the rabbit hole to find out what it meant. We used grep in the command line to search for "def ui" because the convention in Ruby is that the name of the Class is the name of the file which makes it much easier to search. After narrowing it down Jessica eventually found that Bundler handles testing differently then how rspec usually works in other projects. Our searching helped her figure out that the problem was not in what we were doing.

grep -r "def ui" .      grep -r recursive "whatever you are searching for" where(in this case all  ".")

http://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/

Here is the code I came up with so far with the help of Jessica & the other test files.

Our task: Create a test where "bundle i " does not raise an error
______________________________________

require "spec_helper"
describe "bundle i error" do
   it "should not raise an error" do
     bundle " i "
     expect(err).to be_empty
  end
end
_______________________________________

Create a test that prints a friendly message
_______________________________________

require "spec_helper"
  describe "bundler stuff" do
    it "should explain that bundler needs a specific argument" do
      bundle "i"
      expect(out).to match(/Ambiguous argument. Use bundle --help for a list of commands./i)
    end
end
_______________________________________

These are not working quite right yet but it is what I have so far.

Monday, July 22, 2013

Success with Pull request

Great. So I had removed the .swp files and the correct pull request had not been merged. Once it was it all worked great and I have my jdlinks feature branch up now as well as the changes to my page:
http://rgsocbundler.github.io/jen-diamond/index.html
So many links.



Sunday, July 21, 2013

Removing .swp files in Git

I am still having a problem doing my pull request. 
I deleted the .swp files using the rm *.swp in both my jdlink branch and the source branch just in case. My git log shows that I did

jen@cinquecento:~/Desktop/railsgirls/rgsocbundler.github.io$ git diff d8e7 ad76
diff --git a/source/.2013-06-30-hello-world.html.markdown.swp b/source/.2013-06-30-hello-world.htm
deleted file mode 100644
index b542810..0000000
Binary files a/source/.2013-06-30-hello-world.html.markdown.swp and /dev/null differ
diff --git a/source/.2013-07-16-week1-day1.html.markdown.swp b/source/.2013-07-16-week1-day1.html.
deleted file mode 100644
index 13229d4..0000000
Binary files a/source/.2013-07-16-week1-day1.html.markdown.swp and /dev/null differ
diff --git a/source/.index.html.erb.swp b/source/.index.html.erb.swp
deleted file mode 100644
index 3089049..0000000

Actually I just noticed that this says that here I am on the source branch but I also definitely deleted the .swp files on my jdlinks branch. I think it's a problem with my pull request.

Wednesday, July 17, 2013

Git

Lars and I had some crazy potent juice this morning. I went to Station Pharmacy for a coffee.

Joyce and I posted in the Rails Girls IRC channel and setup campfire to chat with the Bundler team.

Then we worked on Git we:
    •    Created new issues on Github
    •    Fixed issues on our blog
    •    Closed issues
    •    Watched Peepcode Git Screencast
    •    Learn about Branching and Collaborating
    •    Created Branches
    •    Created a Pull Requests

Lunch- Kale Salad with tomatoes  and walnuts & Fennel Salad
I came home and cooked until midnight to come down after my first cup of coffee in weeks.

Tuesday, July 16, 2013

First Official Day of Rail Girls Summer of Code

I woke up early and excited. I made juice then Lars and I drove across town together for my first official day of Rail Girls Summer of Code.

It was a successful first day. We set up our desks and got to work. First I realized that because I just switched computers last night/this morning from my other ThinkPad to my new super speedy, solid state drive ThinkPad that I had to re-install Rails and Bundler.

When I tried to install bundler I kept getting an error: This post helped me solve it: http://rubygems.org/pages/download

My next problem: installing node.js  
my error: 
sudo apt-get install node.js 
Reading package lists... Done 
Building dependency tree Reading state information... Done 
E: Unable to locate package node.js 
E: Couldn't find any package by regex 'node.js'

sudo install node.js 
install: missing destination file operand after `node.js' 
Try `install --help' for more information.

Answer: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint

Then we started creating our Team Blog in Github Pages with the Middleman Gem. Jessica set up all the directions in the Read Me file. 
Of interest: .gitignore files https://help.github.com/articles/ignoring-files 
I need to set up a global ignore file so my swp files don't get uploaded when I do an add . to git.

Joyce and I updated our bios on the blog and created separate pages for the link "Read More" to go to.

The day went by so quickly that it felt like we didn't get much done. but I guess we did. I posted our first log in our Team Blog and Lars came to pick me up.

Once we finally were home I made a delicious dinner, chilled out for a while and fell asleep.

The rest of our team blogging will be done at: https://github.com/RGSoCBundler/rgsocbundler.github.io

Thursday, July 11, 2013

PaaS - Platform as a Service

While reading some articles from this week's Ruby Weekly I ran into some unfamiliar terms.

PaaS -  Platform as a Service (PaaS) is a way to rent hardware, operating systems, storage and network capacity over the Internet. The service delivery model allows the customer to rent virtualized servers and associated services for running existing applications or developing and testing new ones.