Skip to content

Commit

Permalink
grrr, rspec + autotest is pain
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Dec 24, 2010
1 parent 26b5a51 commit 4d3ff1c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
Empty file added .rspec
Empty file.
2 changes: 1 addition & 1 deletion bin/vimgolf
Expand Up @@ -3,7 +3,7 @@
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)

require 'vimgolf/cli'
require 'vimgolf'

begin
VimGolf::CLI.start
Expand Down
5 changes: 2 additions & 3 deletions lib/vimgolf.rb
@@ -1,3 +1,2 @@
module Vimgolf
# Your code goes here...
end
require 'thor'
require 'vimgolf/cli'
2 changes: 0 additions & 2 deletions lib/vimgolf/cli.rb
@@ -1,5 +1,3 @@
require 'thor'

module VimGolf
class Error
end
Expand Down
17 changes: 17 additions & 0 deletions spec/cli_spec.rb
@@ -0,0 +1,17 @@
require "helper"

describe VimGolf do
it "provides VimGolf errors" do
VimGolf::Error.should be
end

it "provides a help prompt" do
out = capture_stdout do
VimGolf::CLI.start(["help"])
end

out.should include("setup")
out.should include("launch")
end

end
26 changes: 26 additions & 0 deletions spec/helper.rb
@@ -0,0 +1,26 @@
require 'rubygems'
require 'bundler/setup'

require 'rspec'
require 'lib/vimgolf'


module Kernel
def capture_stdio(input = nil, &block)
require 'stringio'
org_stdin, $stdin = $stdin, StringIO.new(input) if input
org_stdout, $stdout = $stdout, StringIO.new
yield
return @out = $stdout.string
ensure
$stdout = org_stdout
$stdin = org_stdin
end
alias capture_stdout capture_stdio
end

RSpec.configure do |config|
# config.include RSpec::Helpers
# config.include RSpec::GitRepo
# config.extend RSpec::Helpers::SemanticNames
end
4 changes: 3 additions & 1 deletion vimgolf.gemspec
Expand Up @@ -13,7 +13,9 @@ Gem::Specification.new do |s|
s.description = s.summary

s.rubyforge_project = "vimgolf"
s.add_dependency = "thor"
s.add_dependency "thor"

s.add_development_dependency "rspec"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down

0 comments on commit 4d3ff1c

Please sign in to comment.