Changeset 718

Show
Ignore:
Timestamp:
10/05/07 21:49:48 (1 year ago)
Author:
iv..@gweezlebur.com
Message:

Add assert_elements-based Hpricot selector and Rspec matcher

After a call to request() in a spec, you can use elements(), element(), tags(), and tag() as documented in the original assert_select.

You can also, at any time in a spec, say @string.should have_css_selector("//div") (have_css_selector is also aliased to select)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app_generators/merb/templates/spec/spec_helper.rb

    r642 r718  
    33require File.join(MERB_ROOT, 'config', 'merb_init') 
    44 
    5  
     5require 'merb/test/helper' 
     6require 'merb/test/rspec' 
    67 
    78### METHODS BELOW THIS LINE SHOULD BE EXTRACTED TO MERB ITSELF 
    8 require 'merb/test/helper' 
    9  
    10 # require 'merb/test/rspec' 
  • trunk/lib/merb/test/helper.rb

    r701 r718  
    11require 'merb/test/fake_request' 
    2  
     2require 'merb/test/hpricot' 
     3include HpricotTestHelper 
    34 
    45# Create a FakeRequest suitable for passing to Controller.build 
     
    1819 
    1920def request(verb, path) 
    20   res = StringIO.new 
    21   request = Merb::Test::FakeRequest.with(path, :request_method => (verb.to_s.upcase rescue 'GET')) 
     21  response = StringIO.new 
     22  @request = Merb::Test::FakeRequest.with(path, :request_method => (verb.to_s.upcase rescue 'GET')) 
    2223   
    23   yield request if block_given? 
     24  yield @request if block_given? 
    2425   
    25   Merb::Dispatcher.handle request, res 
     26  @controller, @action = Merb::Dispatcher.handle @request, response 
    2627end 
    2728