Permalink
Browse files

Merge pull request #50 from ggilder/fix-spec-ordering-bug

Fix spec ordering bug
  • Loading branch information...
2 parents d508d49 + 1a1cef9 commit fbddc41db6a01751a0add1dc54488db5bd2a363f @ggilder ggilder committed Dec 27, 2012
Showing with 34 additions and 12 deletions.
  1. +1 −1 Rakefile
  2. +12 −6 spec/runner_spec.rb
  3. +21 −5 spec/spec_helper.rb
View
@@ -4,7 +4,7 @@ require "bundler/gem_tasks"
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.verbose = false
- t.rspec_opts = '--color'
+ t.rspec_opts = '--color --order random'
end
task :default => :spec
View
@@ -353,18 +353,24 @@
describe "#valid_command_names_from" do
it "should return array of valid command names" do
- command('foo bar') {}
- command('foo bar foo') {}
- command_runner.valid_command_names_from('foo', 'bar', 'foo').sort.should eq(['foo bar', 'foo bar foo'])
+ new_command_runner do
+ command('foo bar') {}
+ command('foo bar foo') {}
+ command_runner.valid_command_names_from('foo', 'bar', 'foo').sort.should eq(['foo bar', 'foo bar foo'])
+ end
end
it "should return empty array when no possible command names exist" do
- command_runner.valid_command_names_from('fake', 'command', 'name').should eq([])
+ new_command_runner do
+ command_runner.valid_command_names_from('fake', 'command', 'name').should eq([])
+ end
end
it "should match exact commands only" do
- command('foo') {}
- command_runner.valid_command_names_from('foobar').should eq([])
+ new_command_runner do
+ command('foo') {}
+ command_runner.valid_command_names_from('foobar').should eq([])
+ end
end
end
View
@@ -1,13 +1,29 @@
require 'rubygems'
+require 'stringio'
require 'simplecov'
SimpleCov.start
-# prevent paging (through less) from actually occurring in test environment
-ENV['PAGER'] = 'cat'
-
+# Unshift so that local files load instead of something in gems
$:.unshift File.dirname(__FILE__) + '/../lib'
-require 'commander/import'
-require 'stringio'
+
+# This basically replicates the behavior of `require 'commander/import'`
+# but without adding an `at_exit` hook, which interferes with exit code
+require 'commander'
+require 'commander/delegates'
+
+include Commander::UI
+include Commander::UI::AskForClass
+include Commander::Delegates
+
+# prevent paging from actually occurring in test environment
+
+module Commander
+ module UI
+ def enable_paging
+ return
+ end
+ end
+end
# Mock terminal IO streams so we can spec against them

0 comments on commit fbddc41

Please sign in to comment.