Skip to content

Latest commit

 

History

History
243 lines (215 loc) · 13.4 KB

2014-10-13.md

File metadata and controls

243 lines (215 loc) · 13.4 KB

For week of 13 October 2014

  • Follow ups
    • Blue Aaron - Mental health talk
    • Coraline - Write/Speak code workshop
    • RT - Thank him for helping
    • Chris Se - Arlington Ruby mentorship
  • Is it Paleo?
    • search functionality (fuzzy/suggestion)
    • Depending on your goal with this, there are two possible approaches I can think of:
      1. If it's just for learning, then you might want to implement this functionality yourself, to see how it might be done.
      2. If you're more interested in it working, then do some research into how others provide search functionality and try to use one of those solutions (I don't have internet now, but I think Solr and Sphinx might provide this functionality, maybe also check ruby-toolbox to see if there's anything like this.)
    • Here are some potential requirements, choose the ones you're interested in, modify as you like, you can keep the Cucumber style and use Capybara (if you need help with this, let me know) or translate to RSpec:
      • Feature: Searching for items
          It's lunchtime, I feel the hungahz!
          I need to know if the food is Paleo, because that's my diet.
          Sometimes I'm spot-on with my typing, but this phone is small,
          my fingers slip, so on and so forth.
          
          Background:
            Given "Hamburgers" are not paleo
            And "Corn on the cob" is paleo
        
          Scenario: Exact search for a non-paleo item
            When I search for "Hamburgers"
            Then I see a "no" gif
          
          Scenario: Exact search for a paleo item
            When I search for "Corn on the cob"
            Then I see a "yes" gif
        
          Scenario: Case insensitive search
            When I search for "hamBurgers"
            Then I see a "no" gif
          
          Scenario: Search for an unknown item 
            When I search for "Power adapters"
            Then I see (what should happen here?)
          
          Scenario: Non-exact match
            When I search for "Ham Burgers"
            Then I see a "no" gif
            And I am on the "Hamburgers" page
            
          Scenario: Partial match
            When I search for "Burgers"
            Then ??
        
          Scenario: Suggest completions as I type.
            Given "Hamburgers" are not paleo
            And "Corn on the cob" is paleo
            And "Acorn" is not paleo
            When I type "co" into the search box
            Then I am suggested "Corn on the cob" and "Acorn"
        

Britney's notes from the week

Things to discuss:

  • Test quality I have 12 passing spec tests. They're all model tests. One feature test based on Josh's example above with 6 scenarios and 28 steps, all passed. Are they written well though? How much more should I test? Should I write controller tests?

  • Using data tables vs. factories in Cucumber. I started off trying to use data tables but I had trouble saving the data to then use in following steps. So I switched to factories instead.

  • Where to place factories. I wrote my spec tests before I wrote my feature tests and factories. After I passed all my feature tests I ran my spec tests again and realized two were failing because they were picking up information from the factories. The factories file is in my /features/support directory though. I don't mind my specs using the factories, but I should probably move the factories file out of /features/support so it's more apparent, right?

  • Database cleaner transaction vs truncation. At one point my scenarios weren't passing because the home page wasn't rendering links of the food being searched. The first scenario would pass, but then for the rest of the scenarios when the search field was typed into no foods appeared below it. I switched the order of the scenarios to make sure I didn't mistype and it was always the first scenario worked, but the ones below it didn't. I ended up changing the database cleaner configuration from:

Cucumber::Rails::Database.javascript_strategy = :truncation

to:

Cucumber::Rails::Database.javascript_strategy = :transaction

and that seemed to do the trick, but I still don't fully understand why. In fact from what I read using :transaction is faster but could cause threading problems. Don't really know what threading means either, though.

Other happenings

  • Robots! Saw Julian on Saturday at Nova Code and Coffee. Talked robots and getting started. Wound up buying an Arduino starter kit later that day. Haven't played with it yet since I was focused on test writing, but we're planning to try some things during the Arlington Ruby on Wednesday. He should me a Ruby framework for it called artoo. I think it could be a fun way to write Ruby.

  • Resume :( Have to update my resume so I'm ready at any moment should a job opportunity arise. Want to do a full overhaul, content and formatting.

Josh's notes from the week

  • Placing url logic in models: I dislike that the model, an object which I would like to be a simple ignorant data structure (just have some attr_accessors, and not know or do anything related to the web, or even the db, ideally) has this knowledge about how it should be rendered into a url. I don't exactly know what I'd want instead, but I know that even though everyone places it there, that ideally there would be some separation. Maybe what I'd like would be for the path helpers to know to know how to turn the model into the path, so like:

    def food_path(food)
      "/foods/#{food.name||raise("No name on #{food.inspect}")}"
    end
    
Is it Paleo?
  database.yml
    got a database.yml I can use? Mine is blowing up when I try to run tests b/c I'm missing this
    typically what people do is put the real one in .gitignore, and then make a example.database.yml
    so that people can copy it to the real one and then tweak some settings
  UX
    My browser is blocking content b/c it seems to think it's a pop-up
    Site is looking good ^_^ crazy how small improvements to the design go a long way towards perception
    What about instead of a link back to the index on food_path,
      if we put the search bar into a partial and then rendered it where the link is?
  Code
    The ajax search form is really cool :)
    it's something I've typically found difficult and avoided

  Tests
    In my experience, Phantom works better than Selenium
      Selenium (at least as of the last time I set it up)
        was very difficult to set up
        required a graphical browser, so windows would pop up and do things
        and all you could do would be to sit and wait for them to finish
      Phantom
        Is very easy to set up (http://tutorials.jumpstartlab.com/topics/capybara/capybara_and_phantom.html)
        had fewer "bugs" (possibly just nuances, but meaning just less fragile)
        and ran in the background
    FactoryGirl
      How did you like this?
      I've had mixed feelings
      sometimes finding it either useful, or conceptually congruent with my thoughts
      usually finding it was not necessary (a small helper method did just fine and was much more understandable)
      on larger projects, it made it very easy to have large sets of dependencies
        (ie have to make and save lots of objects)
        which was very expensive
        and hid the problems of coupling different pieces of code together
      My mind isn't made up, just curious how you felt about it
    The Cucumber Book
      How are you liking this?
      I've not read it
      but I've really really enjoyed Matt Wynne's perspective and ability to communicate the ideas
      I find the BDD approach very inspiring, and that the people who advocate it do an excellent job
      Any ways it changed your perspective
      Any interesting insights?
      Any takeaways that have been more solid?
    The Thoughtbot blog
      lol, Thoughtbot is such a curious company.
        they do really awesome work
        they're progressive thinkers
        but they're curiously into process
        I don't really understand why
      Feature tests
        I like the ideas here quite a bit
        but I'm not pedantic about the level of abstraction
        (ie sometimes they're from the perspective of the user, sometimes they're just verifying integration)
        Maybe it's just a difference in definitions, idk
      Model tests
        I'm somewhat skeptical about these. I like this idea:
        Throw one into and out of the db, make sure all the values still match up.
        I'd probably wind up putting validations in the model b/c it's just easier since that's the default
        in which case, I'd test my validations,
        but as the needs grew, I'd likely wind up pulling them out to somewhere else.
        I'm not super keen on models having lots of query logic, so don't often need to test that stuff
        Kinda prefer to start by placing that stuff in the controller, then as needs grow, making an object to do that stuff.
        My thoughts on this aren't very consistent, though
      Controller tests
        I've settled on the same usage of controller tests as they have
      View specs
        Interesting points, I've never used view specs
        I've historically done a mix of feature tests and presenters which get tested as Ruby objects
      FactoryGirl
        All their points were good here
        but just keep in mind that FactoryGirl is a Thoughtbot product
      JS tests
        I have no idea how to do this
        If you get something viable, show me how to do it!
      Database Cleaner
        I'm just skimming this stuff, but this portion looks really interesting
        my solution to the problem they discuss right now is very hacky
        I like what they're advocating a lot, just need to try it out :)
      Mocks/stubs
        I have a love/hate relationship with these.
        At one point I was very into them and wrote my own mock lib.
        These days, I use them only when the design seems to call for it.
      Webmock
        I <3 Webmock
        Didn't read the blog they linked to, but I agree that you should stub these services
        even did it today!

vim
  How ya liking vim? I use it, but find it frustrating :P (it's just so buggy >.<)
  I thought vim adventures was a pretty cool idea
  would like to see them do more with it
  Were you able to map what you did in the game back to your usage of vim?

Things to discuss:  
  Test Quality
    Lets look through this together :)
  Data tables vs factories
    Not sure what data tables are, we can try to do it together if you want
    What kind of trouble did you have?
  Where to place factories
    Mystery Guest
      Yeah, you should make it explicitly clear that this data is getting put in there.
      ideally, you specify all the info your test depends on (so you can see it)
        (notice in the original one, we had `Given "Hamburgers" are not paleo`)
      they mention this in the Thoughtbot blog in their criticism of Fixtures,
        calling it a "Mystery Guest" http://robots.thoughtbot.com/how-we-test-rails-applications
    This isn't why you hit this, though
      It goes back to cleaning the db
      since the factories put stuff in the db, when you later ran your specs,
      that stuff was still there,
      so you need to either clean the db after Cucumber runs
      or make model tests that will pass regardless of what's already in the db
  Database Transaction vs Truncation
    I don't know this stuff either
    The Thoughtbot blog linked to a post that Avdi wrote (he was at DCamp :D)
    http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/
    Maybe we should both look into it and try to understand it better?
    One decent but not super awesome trick I've used in the past when this wasn't working right
      was to add a before or after filter, and assert that like seeds weren't getting wiped out,
      and data was getting cleaned
      Kind of a band-aid, but at least it's a helpful error (vs some test randomly failing)