Changeset 575

Show
Ignore:
Timestamp:
07/01/08 10:59:41 (3 months ago)
Author:
bbleything
Message:
  • move the responsibility for creating the @command object to the implementing specs in order to be able to properly mock the plugin object.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • linen/trunk/spec/command_infrastructure_spec.rb

    r573 r575  
    2424describe Linen::Plugin::CommandInfrastructure do 
    2525    before( :each ) do 
    26         @command_class = Class.new { include Linen::Plugin::CommandInfrastructure } 
     26        @plugin = mock( "mock plugin" ) 
     27        @plugin.stub!( :short_name ).and_return( "infrastructure_plugin" ) 
     28        @command_class = Linen::Plugin::SimpleCommand 
     29        @command = @command_class.new( @plugin, "command_infrastructure" ) {} 
    2730    end 
    2831     
  • linen/trunk/spec/shared_behaviours.rb

    r574 r575  
    2323 
    2424describe "a class that includes Linen::Plugin::CommandInfrastructure", :shared => true do 
    25     before( :each ) do 
    26         @plugin = mock( "mock plugin" ) 
    27         @plugin.stub!( :short_name ).and_return( "plugin" ) 
    28          
    29         @command = @command_class.new( @plugin, "command" ) {} 
    30     end 
    31      
    3225    describe "conforms to the Command definition API" do 
    3326        it "implements the require_confirmation directive" do 
     
    4740        it "implements the help_message directive" do 
    4841            message = "This command is used for BEES" 
    49              
    50             @command.instance_variable_get( :@help_text ).should == "No help for plugin command" 
     42            expected = "No help for #{@plugin.short_name} #{@command.name}" 
     43 
     44            @command.instance_variable_get( :@help_text ).should == expected 
    5145            @command.instance_eval { help_message message } 
    5246            @command.instance_variable_get( :@help_text ).should be( message ) 
     
    10094             
    10195            help_lines = @command.help.split( "\n" ) 
    102             help_lines.shift.should == "No help for plugin command
     96            help_lines.shift.should == "No help for #{@plugin.short_name} #{@command.name}
    10397            help_lines.shift.should == "" 
    104             help_lines.shift.should == "Usage: plugin command <a> <b> <c>" 
     98            help_lines.shift.should == "Usage: #{@plugin.short_name} #{@command.name} <a> <b> <c>" 
    10599        end 
    106100         
     
    113107            help_lines.shift.should == help_msg 
    114108            help_lines.shift.should == "" 
    115             help_lines.shift.should == "Usage: plugin sandwich <shoot> <reload> <eat>" 
     109            help_lines.shift.should == "Usage: #{@plugin.short_name} #{@command.name} <shoot> <reload> <eat>" 
    116110        end 
    117111    end