Changeset 734

Show
Ignore:
Timestamp:
10/09/07 18:09:01 (1 year ago)
Author:
has.s..@gmail.com
Message:

Removed the TagMatchers? from the merb_helpers plugin. Have been moved to the framework in [733]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/merb_helpers/specs/merb_helpers_spec.rb

    r732 r734  
    8383describe "text_field (basic)" do 
    8484  it "should return a basic text field based on the values passed in" do 
    85     text_field(:name => "foo", :value => "bar").should == "<input type=\"text\" name=\"foo\" value=\"bar\"/>"   
     85    text_field(:name => "foo", :value => "bar").should match_tag( :input, :type => "text", :name => "foo", :value => "bar") 
    8686  end 
    8787end 
     
    104104 
    105105describe "checkbox_field (basic)" do 
    106   include TagMatchers 
    107    
    108106  it "should return a basic checkbox based on the values passed in" do 
    109107    checkbox_field(:name => "foo", :checked => "checked").should match_tag(:input, :class => "checkbox", :name => "foo", :checked => "checked") 
     
    133131 
    134132describe "hidden_field (basic)" do 
    135   include TagMatchers 
    136133   
    137134  it "should return a basic checkbox based on the values passed in" do 
     
    158155 
    159156describe "radio button (basic)" do 
    160   include TagMatchers 
    161157  it "should should return a basic radio button based on the values passed in" do 
    162158    radio_field(:name => "foo", :value => "bar").should match_tag(:input, :type => "radio", :name => "foo", :value => "bar") 
     
    178174 
    179175describe "text area (basic)" do 
    180   include TagMatchers 
     176  # include TagMatchers 
    181177  it "should should return a basic text area based on the values passed in" do 
    182178    text_area_field("foo", :name => "foo").should match_tag(:textarea, :name => "foo") 
  • plugins/merb_helpers/specs/spec_helper.rb

    r731 r734  
    33require 'rubygems' 
    44require 'merb' 
    5  
    6 module TagMatchers 
    7   class MatchTag 
    8     def initialize(name, attrs) 
    9       @name, @attrs = name, attrs 
    10     end 
    11  
    12     def matches?(target) 
    13       @errors = [] 
    14       unless target.include?("<#{@name}") 
    15         @errors << "Expected a <#{@name}>, but was #{target}" 
    16       end 
    17       @attrs.each do |attr, val| 
    18         unless target.include?("#{attr}=\"#{val}\"") 
    19           @errors << "Expected #{attr}=\"#{val}\", but was #{target}" 
    20         end 
    21       end 
    22       @errors.size == 0 
    23     end 
    24      
    25     def failure_message 
    26       @errors[0] 
    27     end 
    28   end 
    29    
    30   class NotMatchTag 
    31     def initialize(attrs) 
    32       @attrs = attrs 
    33     end 
    34      
    35     def matches?(target) 
    36       @errors = [] 
    37       @attrs.each do |attr, val| 
    38         if target.include?("#{attr}=\"#{val}\"") 
    39           @errors << "Should not include #{attr}=\"#{val}\", but was #{target}" 
    40         end 
    41       end 
    42       @errors.size == 0 
    43     end 
    44      
    45     def failure_message 
    46       @errors[0] 
    47     end 
    48   end 
    49    
    50   def match_tag(name, attrs) 
    51     MatchTag.new(name, attrs) 
    52   end 
    53   def not_match_tag(attrs) 
    54     NotMatchTag.new(attrs) 
    55   end 
    56 end 
     5require 'merb/test/rspec' 
    576 
    587class FakeModel 
     
    12675end 
    12776 
     77 
     78   
     79 
    12880describe "FakeBufferConsumer", :shared => true do 
    129   include TagMatchers 
    13081   
    13182  before :each do