Chronicling my experiences with ruby on rails, web application development/management.

Showing posts with label testing. Show all posts
Showing posts with label testing. Show all posts

Friday, July 10, 2009

superclass mismatch for class ModelExampleGroup - Solved

If you have been pulling your dick hair out, like i was, i thought i'd post this here, while i'm still in a rage.


Error


When you are running cucumber features, you get the following shit:
cucumber features
superclass mismatch for class ModelExampleGroup (TypeError)...


At first, i commented out the remarkable line in environment.rb. I have no idea what this gem does, And i don't want to know. Hell, I only put it there because of a railscast i think, but this gem is fucking me up, so, again, i commented it out of the environment.rb file and everyone is happy. Good riddance.


FiX?


I just installed remarkable-rails instead. i guess the README in the github repo says how to do it. I've not gotten the error since.

Friday, May 1, 2009

When in doubt... Factory it out...

Boy did i have a doozy of a day trying to get some basic tests to pass, after i added some validations to a basic rspec_scaffold. Using the barebones tests, adding the validates_presence_of and a validates_uniqueness_of both borked the test... which was fine, i expected that.


What i didn't expect was that when i commented out both validations, my create test spec method would still work. in essence, it didn't. It could have been something i did, whatever. I fixed the failing tests by simply switching to Factories, instead of fixtures, or whatever the base rspec scaffold would use in a model test.


If you are getting some weird errors, simply try to use factories instead. Try out Factory Girl by Thoughtbot for an example of one that I can say works. haven't tried too hard to get machinist to work yet, but heard good things too.

Tuesday, April 14, 2009

Struggles with webrat via cucumber

I know that this will end up being pebkac... but it still is annoying


So i have a problem. webrat is not acting how i thought it was supposed to. Ryan Bate's railscast on cucumber made this shit look so easy. And for the most part, it is.

However, when you go beyond what he had in his railscast - beginning cucumber, webrat takes me off the rails very fast.


to the Code...


all i wanted to do was select my choice from a dropdown menu. According to webrat/cucumber webrat_steps.rb file it should be
I select "option" from "field"


So in my scenario, i used the field name "tweet[style_id]" and the option "story".
I select "story" from "tweet[style-id]"
You may be wondering what that tweet[ ] business is all about, well that was the only way my scenario would go green, is if i used the label name in that style of code. Since i am not using a symbol in my
f.label :body, "I want to show this text" if you were simply using f.label :body, you wouldn't need the tweet[ ] syntax.


Updates

i did find this ruby forum post, however he simply had the wrong description text. Since my text is one word, and i copied and pasted from the view source code, i don't think that is my problemo. Maybe i should try using the label field without the quotes?

Monday, March 9, 2009

Rails Testing Confessions

Father, My name is pjammer and i have confession to make. I've made 4 web apps and didn't test one of them, in a rails sense.


That's right. Not one of my apps were tested using shoulda, coulda, woulda. Rspec was just a figment of someone's imagination, when i launched my apps, cause it sure wasn't in my mind's eye. Factory girl is a movie about some broad from the 60's and Object daddy just sounds creepy


Let me repent for my testing sins!!!


Father, I'm here today to repent for the sins of not testing my apps. I really want to learn


Learning about testing is like searching google for a future thought. Lots of ideas you can get out of it, but nothing that says "HERE IT IS MY SON".

This post won't help you either, but it should give others who want to make a lot of money, teaching other users how to write tests for rails, some kind of "IDEA" for a tell all book about testing.


The Big Idea


Father, why hath thou forsaken my learning? Learning Rails was easy... tonnes of help on blog posts, forums, etc... yet when it comes to LEARNING HOW TO TEST, doth hast left that chapter blank in thy bible


Here is what i think someone could make a mint from writing a book that steps a user through building tests from TIT to TAIL.


For instance:

  • What is testing and why it's important
  • There are four facets to testing
    • Functional Tests
    • Unit Tests
    • Integration Tests and
    • Fixtures
  • Take each testing facet above and step through each assertion and when to use each assertion and 5 or 6 real life examples for each.
  • Focus just on Test::Unit, Shoulda, and Machinist & Faker for Functional and Unit Testing, as well as fixtures
  • Lastly, use some cool visual tool like webrat or Selenium


Father, thank you. I will say my 10 hail mary's

In closing god would be happier with a book such as this, as less rails noobs and testing noobs would be praying for this kind of mundane nonesense. Leaving more time to fight the good fight.