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

Showing posts with label cucumber. Show all posts
Showing posts with label cucumber. 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.

Wednesday, June 24, 2009

Populating Select menus in Cucumber

From the easy when you finally know what you are doing, column....


How the hell do you setup a select menu in a feature?


Well, it turns out it's easy. Not obvious to me, as nothing is in this testing BDD world, however. Basically For every select menu you want to use in a feature, you must create a Background scenario to populate that select menu before every feature is ran


Here's the code


Feature: Manage Driver lineup as an admin
In order to manage all drivers
As an admin
I want to be able to create and edit a list of drivers.

Background:
Given I create a series "Nascar"

Scenario: Login as admin
Given I am logged in as an admin
When I go to the admin homepage
And I follow "New Driver"
When I fill in "Name" with "Darryl Waltrip"
And I select "Nascar" from "Series"
And I press "Create"
Then I should see "New Driver saved succesfully"

Nascar and all other known shit in the code above is copyright of their respective entities. I am just using it as an example, so chilax


Now in the background step you can just create the list of series(as i have it) using factories as so...


Given /^I create a series "([^\"]*)"$/ do |arg1|
Factory(:league, :name => arg1)
end


Enjoy. yes it was easy, just no one told me how to do it, so i thought i'd see if i could help another soul out.

Monday, June 22, 2009

Important Cucumber step that must not be missed!

Ok, this may just be an aha moment for myself, but i always thought that when i looked at ryan's screencasts on Cucumber we're overly weird. That's right, i said it.


Now, why were they weird? Well, he started out his steps by including the following kind of Given statements:
Given I have zero articles
# or
Given I have an article named "Cheese"


Without this step at this time, there is no way to follow a article_path("blah") link at all. In my simple mind's eye, i thought there would be.


Lessoned Learned?


Stop being a moron and setup your Given statement to either start with a record or two for the model you are trying to BDD against, or make sure NONE exist, to start with a clean slate.