Skip to content

Instantly share code, notes, and snippets.

@dhulihan
Created October 26, 2012 01:05
Show Gist options
  • Save dhulihan/3956411 to your computer and use it in GitHub Desktop.
Save dhulihan/3956411 to your computer and use it in GitHub Desktop.
Example Commander CLI Executable spec test
#!/usr/bin/env ruby
require 'rubygems'
require 'commander/import'
program :version, "0.0.1"
command :main do |c|
c.action do |args, options|
say "This is some output"
end
end
require "spec_helper"
# Load Commander Executable
load File.expand_path("../../../bin/example", __FILE__)
# Mock terminal to silence/manipulate stdin/stdout
def mock_terminal
@input = StringIO.new
@output = StringIO.new
$terminal = HighLine.new @input, @output
end
describe "Commander Example" do
before :each do
mock_terminal
end
describe "the main command", :vcr do
before :each do
@command = command :main
end
it "should return some output" do
@command.run
@output.should == "This is some output."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment