Menu
abriraqui
  • reflexiones
  • publicaciones
  • hackership
  • experiencias
abriraqui

Hands on testing #hackership

Posted on November 19, 2013December 28, 2013

Tweet

The day started with some nice conversations, some about the hackership some about my city, which can be described as a place where you drink and eat a lot!!

Then came the morming stand up round. Yesterday I finished the tutorial so today was the day to continue with units tests for the app, that kind of day that you can not postpone anymore. Of course, it always happens to me (with coding, writing, drawing), when I have to actually start doing stuff of my own I begin procrastinating. So I wrote some emails to some of the new people I met this weekend before is too late I we will forget each other and some others pending for more than a week.

TDD comic stripeBut at some point, “real” testing had to be done, which finally is fun! 🙂

Since my idea, is to do a webcalendar based on events, the first test was event_spec.rb and it looked something like this.

require 'spec_helper'

describe Event do
it "should name be presente" do
@event= Event.new
@event.name = "Name of the event"
@event.name.should be_present
end

it "is invalid without a name" do
@event= Event.new
@event.should_not be_valid
end

it  'should be valid with type' do
@event= Event.new
@event.name = "Name of the event"
@event.type = "Workshop"
@event.should be_present
end
it "should have a location"
end

And well they passed but there was some repetition on them, so I decided to refactor them a bit, so they ended up looking like

require 'spec_helper'
describe Event do
before :each do
@event = Event.new(:name => "Printing the washing machine")
end

it "should name be presente" do
@event.name.should be_present
end

it "is invalid without a name" do
@event.should_not be_valid
end
it 'should be valid with type' do
@event.type = "Workshop"
@event.should be_present
end
it "should have a location"

end

a bit nicer, though is not well indented in this post :-/
While looking for good practices, I ended up on a page written in 2011, which of course was not the best thing to follow, so lesson learned, before reading check when was the documentation written 🙂

Then I continued adding more tests to events, and doing creating a spec for location, so tomorrow will be the time to test associations.

5 thoughts on “Hands on testing #hackership”

  1. Jaime Iniesta says:
    November 19, 2013 at 4:09 pm

    Nice 🙂

    Some tips: you can use shoulda and shoulda-matchers to simplify some common specs about validation and associations:

    https://github.com/thoughtbot/shoulda

    Also, I recommend reading these best practices:

    http://betterspecs.org/

    And some good tips by @dhh

    http://37signals.com/svn/posts/3159-testing-like-the-tsa

    Enjoy!

  2. OpPinkPower says:
    November 19, 2013 at 4:19 pm

    Hands on testing #hackership http://t.co/fC0HtDLBYr

  3. lilithlela says:
    November 19, 2013 at 4:24 pm

    RT @OpPinkPower: Hands on testing #hackership http://t.co/EbZiiZu5Pq https://t.co/1Cvw2iAVGE

  4. anonnerd says:
    November 19, 2013 at 4:33 pm

    RT @OpPinkPower: Hands on testing #hackership http://t.co/fC0HtDLBYr

  5. hacker_ship says:
    November 20, 2013 at 12:53 am

    RT @carolina: Time to put hands on testing :-)))
    http://t.co/9AcEpCKKUN @hacker_ship

Comments are closed.

©2023 abriraqui | Powered by SuperbThemes & WordPress