#46 √ resolved
Ardekantur

Sinatra and rpsec options don't play well together

Reported by Ardekantur | November 7th, 2008 @ 08:18 AM | in 0.9.0 Hoboken

You can use --color, --reverse, and I'm sure a slew of other command line arguments to rspec. The end result is that RSpec thinks the options -- which work fine on other, non-Sinatra-integrated specs -- don't exist.

This same phenomenon occurs if we link in the latest git commit of Sinatra (d389d27 at the time of writing), or if we send the options to RSpec through a Rake task:


desc "Run all specs"
Spec::Rake::SpecTask.new(:spec) do |t|
   t.spec_opts = ['--color'] # considered invalid
   t.spec_files = FileList['spec/*.rb']
end

I have no idea how I'd write a spec for this, so I wrote a test case instead, which can be pulled and run like so:


git clone git://gist.github.com/22895.git sinatra-rspec-test
cd sinatra-rspec-test
spec --color app_spec.rb

Comments and changes to this ticket

  • Ryan Tomayko

    Ryan Tomayko November 7th, 2008 @ 12:12 PM

    • → Assigned user changed from “Blake Mizerany” to “Ryan Tomayko”

    Good bug. And it's actually a wider problem than just rspec. I imagine you'd get the same behavior with rcov or any other tool that required sinatra.

    The issue is caused by Sinatra naively parsing command line options the first time it's initialized. There's actually a special case (L951 in sinatra.rb) for the gem command because running gem install sinatra --test would fail.

    I'll take a look and see if we can limit command line option parsing to situations where we're more sure a sinatra app file is being run directly (by check $0 for an .rb extension, for example).

  • Ryan Tomayko

    Ryan Tomayko November 7th, 2008 @ 12:12 PM

    • → State changed from “new” to “open”
  • Ryan Tomayko

    Ryan Tomayko December 30th, 2008 @ 02:42 AM

    • → Milestone changed from “0.3.0 Sammy” to “0.9.0 Hoboken”
    • → State changed from “open” to “resolved”

    This has been resolved with a bunch of other top-level app related problems on the hoboken branch. I have no intention of attempting to backport those changes to 0.3.x.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags