Methods
S
T
Instance Public methods
segment()
# File rails/actionpack/test/controller/routing_test.rb, line 598
def segment
  unless @segment
    @segment = ROUTING::DynamicSegment.new
    @segment.key = :a
  end
  @segment
end
test_default_local_name()
# File rails/actionpack/test/controller/routing_test.rb, line 620
def test_default_local_name
  assert_equal 'a_value', segment.local_name,
    "Unexpected name -- all value_check tests will fail!"
end
test_expiry_should_not_trigger_once_expired()
# File rails/actionpack/test/controller/routing_test.rb, line 679
def test_expiry_should_not_trigger_once_expired
  expired = true
  hash = merged = {:a => 2, :b => 3}
  options = {:b => 3}
  expire_on = Hash.new { raise 'No!!!' }
  
  eval(segment.expiry_statement)
rescue RuntimeError
  flunk "Expiry check should not have occured!"
end
test_expiry_should_occur_according_to_expire_on()
# File rails/actionpack/test/controller/routing_test.rb, line 690
def test_expiry_should_occur_according_to_expire_on
  expired = false
  hash = merged = {:a => 2, :b => 3}
  options = {:b => 3}
  
  expire_on = {:b => true, :a => false}
  eval(segment.expiry_statement)
  assert !expired
  assert_equal({:a => 2, :b => 3}, hash)
  
  expire_on = {:b => true, :a => true}
  eval(segment.expiry_statement)
  assert expired
  assert_equal({:b => 3}, hash)
end
test_extract_value()
# File rails/actionpack/test/controller/routing_test.rb, line 606
def test_extract_value
  s = ROUTING::DynamicSegment.new
  s.key = :a
  
  hash = {:a => '10', :b => '20'}
  assert_equal '10', eval(s.extract_value)
  
  hash = {:b => '20'}
  assert_equal nil, eval(s.extract_value)
  
  s.default = '20'
  assert_equal '20', eval(s.extract_value)
end
test_extraction_code_should_accept_value_and_set_local()
# File rails/actionpack/test/controller/routing_test.rb, line 725
def test_extraction_code_should_accept_value_and_set_local
  hash = merged = {:a => 'Hi', :b => '3'}
  options = {:b => '3'}
  a_value = nil
  expired = true

  eval(segment.extraction_code)
  assert_equal 'Hi', a_value
end
test_extraction_code_should_perform_expiry()
# File rails/actionpack/test/controller/routing_test.rb, line 746
def test_extraction_code_should_perform_expiry
  expired = false
  hash = merged = {:a => 'Hi', :b => '3'}
  options = {:b => '3'}
  expire_on = {:a => true}
  a_value = nil
  
  eval(segment.extraction_code)
  assert_equal 'Hi', a_value
  assert expired
  assert_equal options, hash
end
test_extraction_code_should_return_on_mismatch()
# File rails/actionpack/test/controller/routing_test.rb, line 715
def test_extraction_code_should_return_on_mismatch
  segment.regexp = %r\d+/
  hash = merged = {:a => 'Hi', :b => '3'}
  options = {:b => '3'}
  a_value = nil
  
  # Local jump because of return inside eval.
  assert_raises(LocalJumpError) { eval(segment.extraction_code) }
end
test_extraction_code_should_return_on_nil()
# File rails/actionpack/test/controller/routing_test.rb, line 706
def test_extraction_code_should_return_on_nil
  hash = merged = {:b => 3}
  options = {:b => 3}
  a_value = nil
  
  # Local jump because of return inside eval.
  assert_raises(LocalJumpError) { eval(segment.extraction_code) }
end
test_extraction_should_work_without_value_check()
# File rails/actionpack/test/controller/routing_test.rb, line 735
def test_extraction_should_work_without_value_check
  segment.default = 'hi'
  hash = merged = {:b => '3'}
  options = {:b => '3'}
  a_value = nil
  expired = true
  
  eval(segment.extraction_code)
  assert_equal 'hi', a_value
end
test_interpolation_chunk_should_replace_value()
# File rails/actionpack/test/controller/routing_test.rb, line 759
def test_interpolation_chunk_should_replace_value
  a_value = 'Hi'
  assert_equal a_value, eval(%Q("#{segment.interpolation_chunk}"))
end
test_optional_regexp_value_check_should_accept_nil()
# File rails/actionpack/test/controller/routing_test.rb, line 636
def test_optional_regexp_value_check_should_accept_nil
  segment.regexp = %r\d+/
  segment.is_optional = true
  a_value = nil
  assert eval(segment.value_check)
end
test_optional_value_needs_no_check()
# File rails/actionpack/test/controller/routing_test.rb, line 665
def test_optional_value_needs_no_check
  segment.is_optional = true
  a_value = nil
  assert_equal nil, segment.value_check
end
test_presence_value_check()
# File rails/actionpack/test/controller/routing_test.rb, line 625
def test_presence_value_check
  a_value = 10
  assert eval(segment.value_check)
end
test_regexp_chunk_should_return_string()
# File rails/actionpack/test/controller/routing_test.rb, line 776
def test_regexp_chunk_should_return_string
  segment.regexp = %r\d+/
  assert_kind_of String, segment.regexp_chunk
end
test_regexp_value_check_accepts_match()
# File rails/actionpack/test/controller/routing_test.rb, line 653
def test_regexp_value_check_accepts_match
  segment.regexp = %r\d+/
  
  a_value = "30"
  assert eval(segment.value_check)
end
test_regexp_value_check_rejects_nil()
# File rails/actionpack/test/controller/routing_test.rb, line 630
def test_regexp_value_check_rejects_nil
  segment.regexp = %r\d+/
  a_value = nil
  assert ! eval(segment.value_check)
end
test_regexp_value_check_rejects_no_match()
# File rails/actionpack/test/controller/routing_test.rb, line 643
def test_regexp_value_check_rejects_no_match
  segment.regexp = %r\d+/
  
  a_value = "Hello20World"
  assert ! eval(segment.value_check)
  
  a_value = "20Hi"
  assert ! eval(segment.value_check)
end
test_regexp_value_check_should_accept_match_with_default()
# File rails/actionpack/test/controller/routing_test.rb, line 671
def test_regexp_value_check_should_accept_match_with_default
  segment.regexp = %r\d+/
  segment.default = '200'
  
  a_value = '100'
  assert eval(segment.value_check)
end
test_value_check_fails_on_nil()
# File rails/actionpack/test/controller/routing_test.rb, line 660
def test_value_check_fails_on_nil
  a_value = nil
  assert ! eval(segment.value_check)
end
test_value_regexp_should_be_nil_without_regexp()
# File rails/actionpack/test/controller/routing_test.rb, line 764
def test_value_regexp_should_be_nil_without_regexp
  assert_equal nil, segment.value_regexp
end
test_value_regexp_should_match_exacly()
# File rails/actionpack/test/controller/routing_test.rb, line 768
def test_value_regexp_should_match_exacly
  segment.regexp = %r\d+/
  assert_no_match segment.value_regexp, "Hello 10 World"
  assert_no_match segment.value_regexp, "Hello 10"
  assert_no_match segment.value_regexp, "10 World"
  assert_match segment.value_regexp, "10"
end