Created
October 26, 2012 01:05
-
-
Save dhulihan/3956411 to your computer and use it in GitHub Desktop.
Example Commander CLI Executable spec test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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