seattlerb / hoe

Hoe is a rake/rubygems helper for project Rakefiles. It helps you manage, maintain, and release your project and includes a dynamic plug-in system allowing for easy extensibility. Hoe ships with plug-ins for all your usual project tasks including rdoc generation, testing, packaging, deployment, and announcement.

Home Page:http://www.zenspider.com/projects/hoe.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

capture_io of minitest not working with minitest/spec

millisami opened this issue · comments

This was actually started here http://www.ruby-forum.com/topic/4405021#new

And since Ryan said that was not the place to put that issue, I'm filing it here coz its weird.

When I run the spec via ruby spec/launcher_spec.rb way, it works. But when I run via rake provided by the hoe sow scaffold and running the spec via just rake, it errors out saying:

 3) Launchcloud check the capture_io cmd
     Failure/Error: out, err = capture_io do
     NoMethodError:
       undefined method `capture_io' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000100c425b0>
     # ./spec/launchcloud_spec.rb:28:in `block (2 levels) in <top (required)>'

Following is the Rakefile

# -*- ruby -*-

require 'rubygems'
require 'hoe'

# Hoe.plugin :compiler
# Hoe.plugin :gem_prelude_sucks
# Hoe.plugin :inline
# Hoe.plugin :bundler
Hoe.plugin :minitest
# Hoe.plugin :doofus
# Hoe.plugin :git
# Hoe.plugin :racc
# Hoe.plugin :rcov
# Hoe.plugin :rubyforge

Hoe.spec 'launchcloud' do
  # HEY! If you fill these out in ~/.hoe_template/Rakefile.erb then
  # you'll never have to touch them again!
  # (delete this comment too, of course)

  developer('Millisami', 'millisami@gmail.com')

  # self.rubyforge_name = 'launchcloudx' # if different than 'launchcloud'
end

# vim: syntax=ruby

And this is the spec file:

gem 'minitest'
require "minitest/autorun"
require_relative "../lib/launchcloud"

describe Launchcloud do

  let(:runner) { Launchcloud::Runner.new }

  it "works" do
    x = capture_io do
      puts "hi"
    end
    p x
  end
end

But if run that same spec with the ruby command ruby spec/launchcloud_spec.rb, it works:

Run options: --seed 51232

# Running tests:

S["hi\n", ""]
..

How to make it work with the Hoe rake command?

OK. So... you're writing minitest/spec code and then hoe is trying to run it under rspec? Ah. OK. I see. You have rspec installed as well and it is picking up your minitest/spec files and trying to run them as rspec files.

Looking at the code more... I see what is going on. hoe's test setup allows for both ((test/unit or minitest/_) and rspec). As such, minitest/_files need to go in the test directory.spec is reserved for rspec.

I have a small patch to go in to make the test task pick up spec_*.rb and *_spec.rb files in the test dir. Until that goes out, your files will need to have "_test.rb", not "_spec.rb". That should go out as soon as I test this tho.

You don't even need to wait for my release. Set your test_globs variable to find your spec files.

Fixed and released. Thanks!

Thanks.

I moved the spec/*_spec.rb files into test/*_spec.rb and it works.

But if I were to set the test_globs variable to find my spec files, where and how to set this var?

On Aug 21, 2012, at 02:04 , millisami notifications@github.com wrote:

Thanks.

I moved the spec/__spec.rb files into test/__spec.rb and it works.

But if I were to set the test_globs variable to find my spec files, where and how to set this var?

It still needs to be in the test dir. test_globs is a Hoe spec variable. You set it in your Hoe.spec block.

ri Hoe.test_globs for more details.