Posts tagged as:

test

Run your tests faster with parallel_tests gem using all the cores you have on your computer.

Download
Download (iPhone & iPod)

{ 0 comments }

I was setting up a new project/gem that interfaces with Project Honeypot. While I was setting it up, I ran into a couple of problems running my specs. The first one, I hit this error while running ‘bundle exec spec spec’:

/usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.2/lib/bundler/shared_helpers.rb:137:in `bin_path': can't find executable spec (Gem::Exception)
	from /usr/local/bin/spec:19

What this means is that the spec gem doesn’t have an executable called ‘spec.’ This confused me since all of the previous versions had been run with a ‘spec’ command. As it turns out, in RSpec 2.0.x, the command to run your specs is ‘rspec,’ not ‘spec.’ So a ‘bundle exec rspec spec’ got around that error.

The next issue I got was an undefined constant error for ‘Spec::Runner.’ Here is my spec_helper where I was referencing Spec::Runner.

require "rubygems"
require "bundler/setup"
require "rspec"
require "flexmock"
require File.dirname(__FILE__) + "/../lib/project_honeypot"

Spec::Runner.configure do |config|
  config.mock_with :flexmock
end

So, RSpec has changed the configuration setup to use RSpec instead of Spec::Runner and it worked like a charm.

You can check out the respository I was working in at http://github.com/charlesmaxwood/project_honeypot.

{ 0 comments }


Shoulda is a framework that sits on top of Test::Unit and adds a ton of nice features like macro’s, nested context, and the ability to create custom tests in a block-based DSL.
Download 160.2 MB
Download (iphone & ipod) 71.9 MB

{ 15 comments }

Last week, my development team and I ran across a problem with a library we had written several months before that parsed spreadsheets given to us by one of our clients and inserted the data provided into the database. At the time we weren’t sure what the problem was. We decided to run the tests and two frustratingly useless things occurred. First, all of the tests passed. Second, the test suite took 3 hours to run.

Here’s what we had done in our “unit tests.” We had placed several of these spreadsheets as examples into our fixtures folder. Then, we had created the importer object and told it to import. We then checked the results. These tests take a long time, specifically because an import can sometimes take 15 minutes depending on the amount of data we need to import. So, how do you fix something like that? Here are some ideas.

[click to continue…]

{ 5 comments }

Having used both Test::Unit and RSpec, I have to agree with Jim Weirich: the difference between the two is primarily semantics. It seems to me that functionally, they are both equally capable of verifying and specifying code. However, the way in which you write the tests—the semantics—is the primary difference between the two. That being the case, I prefer the semantics of RSpec.
[click to continue…]

{ 6 comments }