Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6861

Show
Ignore:
Timestamp:
05/26/07 17:29:23 (2 years ago)
Author:
marcel
Message:

Add support for assert_select_rjs with :show and :hide. #7780 [dchelimsky]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6860 r6861  
    11*SVN* 
     2 
     3* Add support for assert_select_rjs with :show and :hide. #7780 [dchelimsky] 
    24 
    35* Make assert_select's failure messages clearer about what failed. #7779 [dchelimsky] 
  • trunk/actionpack/lib/action_controller/assertions/selector_assertions.rb

    r6860 r6861  
    326326      # 
    327327      # Use the first argument to narrow down assertions to only statements 
    328       # of that type. Possible values are +:replace+, +:replace_html+, +:remove+ and 
    329       # +:insert_html+. 
     328      # of that type. Possible values are +:replace+, +:replace_html+, +:show+, 
     329      # +:hide+, +:toggle+, +:remove+ and +:insert_html+. 
    330330      # 
    331331      # Use the argument +:insert+ followed by an insertion position to narrow 
     
    415415            when :chained_replace, :chained_replace_html 
    416416              Regexp.new("\\$\\(\"#{id}\"\\)#{statement}\\(#{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE) 
    417             when :remove 
     417            when :remove, :show, :hide, :toggle 
    418418              Regexp.new("#{statement}\\(\"#{id}\"\\)") 
    419419            else 
     
    424424        matches = nil 
    425425        case rjs_type 
    426           when :remove 
     426          when :remove, :show, :hide, :toggle 
    427427            matches = @response.body.match(pattern) 
    428428          else 
     
    435435        end 
    436436        if matches 
    437           if block_given? && rjs_type != :remove 
     437          if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type) 
    438438            begin 
    439439              in_scope, @selected = @selected, matches 
     
    542542            :chained_replace_html => /\.update/, 
    543543            :remove               => /Element\.remove/, 
     544            :show                 => /Element\.show/, 
     545            :hide                 => /Element\.hide/, 
     546            :toggle                 => /Element\.toggle/ 
    544547          } 
    545548          RJS_INSERTIONS = [:top, :bottom, :before, :after] 
  • trunk/actionpack/test/controller/assert_select_test.rb

    r6860 r6861  
    453453  end 
    454454 
     455  # Simple show 
     456  def test_assert_select_rjs_for_show 
     457    render_rjs do |page| 
     458      page.show "test1" 
     459    end 
     460 
     461    assert_select_rjs :show, "test1" 
     462  end 
     463 
     464  def test_assert_select_rjs_for_show_ignores_block 
     465    render_rjs do |page| 
     466      page.show "test1" 
     467    end 
     468 
     469    assert_nothing_raised do 
     470      assert_select_rjs :show, "test1" do 
     471        assert_select "p" 
     472      end 
     473    end 
     474  end 
     475   
     476  # Simple hide 
     477  def test_assert_select_rjs_for_hide 
     478    render_rjs do |page| 
     479      page.hide "test1" 
     480    end 
     481 
     482    assert_select_rjs :hide, "test1" 
     483  end 
     484 
     485  def test_assert_select_rjs_for_hide_ignores_block 
     486    render_rjs do |page| 
     487      page.hide "test1" 
     488    end 
     489 
     490    assert_nothing_raised do 
     491      assert_select_rjs :hide, "test1" do 
     492        assert_select "p" 
     493      end 
     494    end 
     495  end 
     496   
     497  # Simple toggle 
     498  def test_assert_select_rjs_for_toggle 
     499    render_rjs do |page| 
     500      page.toggle "test1" 
     501    end 
     502 
     503    assert_select_rjs :toggle, "test1" 
     504  end 
     505 
     506  def test_assert_select_rjs_for_toggle_ignores_block 
     507    render_rjs do |page| 
     508      page.toggle "test1" 
     509    end 
     510 
     511    assert_nothing_raised do 
     512      assert_select_rjs :toggle, "test1" do 
     513        assert_select "p" 
     514      end 
     515    end 
     516  end 
     517   
    455518  # Non-positioned insert. 
    456519  def test_assert_select_rjs_for_nonpositioned_insert 
     
    499562    end 
    500563  end 
    501  
    502  
     564   
    503565  # Simple selection from a single result. 
    504566  def test_nested_assert_select_rjs_with_single_result