Thursday, November 7, 2013

Notes - Rails Tutorial Chapter 3.2 - Integration Tests vs. Unit Tests

Integration Tests vs. Unit Tests

Unit Tests

A unit test is a test written by the programmer to verify that a relatively small piece of code is doing what it is intended to do. They are narrow in scope, they should be easy to write and execute, and their effectiveness depends on what the programmer considers to be useful. The tests are intended for the use of the programmer, they are not directly useful to anybody else, though, if they do their job, testers and users downstream should benefit from seeing less bugs.   ~ Nathan Hughes

Integration Tests

An integration test is done to demonstrate that different pieces of the system work together. Integration tests cover whole applications, and they require much more effort to put together. They usually require resources like database instances and hardware to be allocated for them. The integration tests do a more convincing job of demonstrating the system works (especially to non-programmers) than a set of unit tests can, at least to the extent the integration test environment resembles production.
Actually "integration test" gets used for a wide variety of things, from full-on system tests against an environment made to resemble production to any test that uses a resource (like a database or queue) that isn't mocked out.

Wednesday, November 6, 2013

Cal Tech & POODR Ch 1 & 2

Yesterday I started re-reading Practical Object-Oriented Design with Ruby by Sandi Metz. I got through half of Chapter 2. I didn't re-read Chapter 1 because I remember the main ideas from it.

Chapter 2 starts out with a bicycle. A good way to start if you ask me. There is talk about gearing. I never really thought that much about this. I put my bike in a low gear for going up the hill and a large gear for going down the hill. But what does that really mean mechanically? Fixed gear people talk about their gear ratios but I always tuned those conversations out because I am too clumsy for a fixie. I do have a single gear bike but I have no idea what the ratio is. It just goes. And the people who have 2 different sized wheels are just taking it to another level that I have previously been uninterested in.

Sandi Metz has made me think about all of this stuff. The most I can say is at least I knew it existed so that is something. 

We are trying to figure out the gear ratio of a bike.

Friday, October 25, 2013

My Bundler Feature was Merged

My PR to Bundler  was merged!
This fixes the issue: Warn if the same gem (same version) is added twice. bundler/bundler-features#22

Try it out: Open a Gemfile in on of your projects and duplicate one of your gems.
do a bundle install
You should get a warning telling you that you have a duplicated gem and what it is.
This is the warning you'll see:

"Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later."
Yay!!

Wednesday, October 23, 2013

New Relic Rocks

So I am here in San Francisco for the Future Stack Conference because New Relic gave Rails Girls a scholarship. Someone else was supposed to come but she couldn't make it and I was next on the list. So New Relic paid for me to fly here, sent a car for me; a fancy, shiny, black car which dropped me off for a 3 night stay at the Grand Hyatt Hotel in Union Sq. My room is amazing. Then I got an amazing goody bag with a cool Future Stack tote, t-shirt, stickers, other swag and a generous food stipend. Wow. I won the scholarship lottery.

I walked around Union Sq. for hours today shopping for the perfect scarf. The first one I found is the one I ended up buying many hours later. I got a nice lunch and dinner. Now am in my pajamas relaxing and getting ready for the long day and night tomorrow.

Tuesday, October 22, 2013

Github Pages

http://jendiamond.github.io/

Wow, I can't believe that it is finally up! I had an incredible burst of focused energy and in my own house and at my desk even.

I was having a hard time getting the blog to publish and after a while I realized that the layout was not correct. I fixed that and it posted. Then I continued onward to styling and adding pages. I was so happy and proud of myself when it finally worked. There are so few of these moments amidst the struggle that I make sure I acknowledge them.

I am leaving for the Future Stack conference tomorrow morning so I am going to hit the hay.

Hooray!!! Hooray!!! Hooray!!!

Thursday, October 17, 2013

Model View Controller Explanation

Model The classes which are used to store and manipulate state, typically in a database of some kind.

View The user interface bits (in this case, HTML) necessary to render the model to the user.

Controller The brains of the application. The controller decides what the user's input was, how the model needs to change as a result of that input, and which resulting view should be used.


Let's use some of this to make a simple little text editor:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
filename = ARGV.first
script = $0

puts "We're going to erase #{filename}."
puts "If you don't want that, hit CTRL-C (^C)."
puts "If you do want that, hit RETURN."

print "? "
STDIN.gets

puts "Opening the file..."
target = File.open(filename, 'w')

puts "Truncating the file.  Goodbye!"
target.truncate(target.size)

puts "Now I'm going to ask you for three lines."

print "line 1: "; line1 = STDIN.gets.chomp()
print "line 2: "; line2 = STDIN.gets.chomp()
print "line 3: "; line3 = STDIN.gets.chomp()

puts "I'm going to write these to the file."

target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")

puts "And finally, we close it."
target.close()

Notes - Rails Tutorial Chapter 3.1

Sent PR to Bundler  hopefully it will get closed soon.
This fixes the issue: Warn if the same gem (same version) is added twice. bundler/bundler-features#22

To create the static views I am mainly in the app/controllers and the app/views directories

The config directory is where Rails collects files needed for the application configuration.

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
end

New in Rails 4
  • Previous versions of Rails used PUT in place of PATCH, and Rails 4.0 still supports this usage, but PATCH matches the intended HTTP usage better and is preferred for new applications. So GET, POST, PUT, DELETE is now GET, POST, PATCH, DELETE.

    Idempotence  is the property of certain operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application. It literally means "(the quality of having) the same power", from idem + potence (same + power).