Changeset 567

Show
Ignore:
Timestamp:
06/25/08 11:40:08 (3 months ago)
Author:
bbleything
Message:

source:linen/trunk/Rakefile

  • Only generate coverage if you run the rcov task

source:linen/trunk/spec/spec_helper.rb
source:linen/trunk/lib/linen/spec_matchers.rb

  • put the ArgumentMatchers? custom rspec matcher module in lib. This gives users of Linen access to these matchers when testing their own applications
  • add a note describing why the CompletionMatchers? module is not also being moved

source:linen/trunk/spec/argument_spec.rb

  • require spec_matchers
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • linen/trunk/Rakefile

    r564 r567  
    4646### Run the specifications 
    4747Spec::Rake::SpecTask.new do |r|  
    48     r.rcov      = true 
    49     r.rcov_dir  = 'coverage' 
    5048    r.libs      = SPEC_FILES 
    5149    r.spec_opts = %w(--format specdoc --color) 
    5250end 
    5351 
     52### Run the specifications and generate coverage information 
     53Spec::Rake::SpecTask.new( :rcov ) do |r|  
     54    r.rcov      = true 
     55    r.rcov_dir  = 'coverage' 
     56    r.libs      = SPEC_FILES 
     57end 
    5458 
    5559desc "Clean pkg, coverage, and rdoc; remove .bak files" 
  • linen/trunk/spec/argument_spec.rb

    r566 r567  
    2020require File.join(File.dirname(__FILE__),"spec_helper.rb") 
    2121require 'linen/argument' 
     22require 'linen/spec_matchers' 
    2223 
    2324describe "A Linen::Plugin::Argument" do 
  • linen/trunk/spec/spec_helper.rb

    r566 r567  
    3333##################################################################################### 
    3434 
    35 ### ArgumentMatchers 
    36 ### 
    37 ### These matchers are used to test argument handling. 
    38 ### 
    39 ###  * ValidationMatcher -- lets us check for acceptance and rejection of input values 
    40 module ArgumentMatchers 
    41     class ValidationMatcher 
    42         def initialize( input, mode = :accept ) 
    43             @input = input 
    44             @mode  = mode 
    45         end 
    46          
    47         def matches?( argument ) 
    48             @argument = argument 
    49              
    50             begin 
    51                 argument.process( @input ) 
    52             rescue Linen::Plugin::ArgumentError 
    53                 result = :rejected 
    54                 # the exception means the argument was rejected, so return true 
    55                 # in reject mode and false in accept mode. 
    56                 return true if @mode == :reject 
    57                 return false 
    58             else 
    59                 # no exception means the argument was accepted 
    60                 return false if @mode == :reject 
    61                 return true 
    62             end 
    63         end 
    64          
    65         def failure_message 
    66             "expected argument #{@argument} to accept '#{@input}', but it was rejected." 
    67         end 
    68          
    69         def negative_failure_message 
    70             "expected argument #{@argument} to reject '#{@input}', but it was accepted." 
    71         end 
    72     end 
    73      
    74     def accept( input ) 
    75         ArgumentMatchers::ValidationMatcher.new( input, :accept ) 
    76     end 
    77      
    78     def reject( input ) 
    79         ArgumentMatchers::ValidationMatcher.new( input, :reject ) 
    80     end 
    81 end 
    82  
    8335### CompletionMatchers 
    8436### 
     
    8840###  * SuggestCandidatesMatcher -- lets us do completing( 'foo' ).should suggest_candidates( ary ) 
    8941###  * 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. 
    9046module CompletionMatchers 
    9147    # helper method to save some typing.  We don't care that this returns 
     
    180136    end 
    181137end 
    182