Changeset 567
- Timestamp:
- 06/25/08 11:40:08 (3 months ago)
- Files:
-
- linen/trunk/Rakefile (modified) (1 diff)
- linen/trunk/lib/linen/spec_matchers.rb (added)
- linen/trunk/spec/argument_spec.rb (modified) (1 diff)
- linen/trunk/spec/spec_helper.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
linen/trunk/Rakefile
r564 r567 46 46 ### Run the specifications 47 47 Spec::Rake::SpecTask.new do |r| 48 r.rcov = true49 r.rcov_dir = 'coverage'50 48 r.libs = SPEC_FILES 51 49 r.spec_opts = %w(--format specdoc --color) 52 50 end 53 51 52 ### Run the specifications and generate coverage information 53 Spec::Rake::SpecTask.new( :rcov ) do |r| 54 r.rcov = true 55 r.rcov_dir = 'coverage' 56 r.libs = SPEC_FILES 57 end 54 58 55 59 desc "Clean pkg, coverage, and rdoc; remove .bak files" linen/trunk/spec/argument_spec.rb
r566 r567 20 20 require File.join(File.dirname(__FILE__),"spec_helper.rb") 21 21 require 'linen/argument' 22 require 'linen/spec_matchers' 22 23 23 24 describe "A Linen::Plugin::Argument" do linen/trunk/spec/spec_helper.rb
r566 r567 33 33 ##################################################################################### 34 34 35 ### ArgumentMatchers36 ###37 ### These matchers are used to test argument handling.38 ###39 ### * ValidationMatcher -- lets us check for acceptance and rejection of input values40 module ArgumentMatchers41 class ValidationMatcher42 def initialize( input, mode = :accept )43 @input = input44 @mode = mode45 end46 47 def matches?( argument )48 @argument = argument49 50 begin51 argument.process( @input )52 rescue Linen::Plugin::ArgumentError53 result = :rejected54 # the exception means the argument was rejected, so return true55 # in reject mode and false in accept mode.56 return true if @mode == :reject57 return false58 else59 # no exception means the argument was accepted60 return false if @mode == :reject61 return true62 end63 end64 65 def failure_message66 "expected argument #{@argument} to accept '#{@input}', but it was rejected."67 end68 69 def negative_failure_message70 "expected argument #{@argument} to reject '#{@input}', but it was accepted."71 end72 end73 74 def accept( input )75 ArgumentMatchers::ValidationMatcher.new( input, :accept )76 end77 78 def reject( input )79 ArgumentMatchers::ValidationMatcher.new( input, :reject )80 end81 end82 83 35 ### CompletionMatchers 84 36 ### … … 88 40 ### * SuggestCandidatesMatcher -- lets us do completing( 'foo' ).should suggest_candidates( ary ) 89 41 ### * ExpandToMatcher -- lets us do completing( 'foo' ).should expand_to( result ) 42 ### 43 ### Note: because these matchers are specific to the CLI handler, they are not 44 ### included in the spec_matchers.rb file exported to consumers of the Linen 45 ### library. 90 46 module CompletionMatchers 91 47 # helper method to save some typing. We don't care that this returns … … 180 136 end 181 137 end 182
