Changeset 757
- Timestamp:
- 02/23/08 12:14:48 (6 months ago)
- Files:
-
- trunk/radiant/app/models/page_context.rb (modified) (2 diffs)
- trunk/radiant/spec/models/page_context_spec.rb (modified) (3 diffs)
- trunk/radiant/test/unit/page_context_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/radiant/app/models/page_context.rb
r628 r757 18 18 super 19 19 rescue Exception => e 20 raise e if testing?20 raise e if raise_errors? 21 21 @tag_binding_stack.pop unless @tag_binding_stack.last == binding 22 22 render_error_message(e.message) … … 40 40 end 41 41 42 def testing?43 RAILS_ENV == 'test'42 def raise_errors? 43 RAILS_ENV != 'production' 44 44 end 45 45 trunk/radiant/spec/models/page_context_spec.rb
r653 r757 10 10 @parser = Radius::Parser.new(@context, :tag_prefix => 'r') 11 11 end 12 12 13 it 'should raise an error when it encounters a missing tag' do 14 lambda { @parser.parse('<r:missing />') }.should raise_error(StandardTags::TagError) 15 end 16 13 17 it 'should initialize correctly' do 14 18 @page.should equal(@context.page) 15 end16 17 it 'should output an error when it encounters a missing tag' do18 lambda { parse('<r:missing />') }.should raise_error(StandardTags::TagError)19 def @context.testing?; false end20 parse('<r:missing />').should include("undefined tag `missing'")21 19 end 22 20 … … 38 36 parse('<r:find url="/another/"><r:if_response>tada!</r:if_response></r:find>').should include("tada!") 39 37 end 40 41 it 'should pop the stack when an error occurs' do42 @context.current_nesting.should be_empty43 @context.define_tag("error") { |tag| raise "Broken!" }44 def @context.testing?(); false; end45 parse("<r:error/>").should match(/Broken\!/)46 @context.current_nesting.should be_empty47 end48 38 49 39 private … … 54 44 55 45 end 46 47 describe PageContext, "when errors are not being raised" do 48 scenario :pages 49 test_helper :pages 50 51 before :each do 52 @page = pages(:radius) 53 @context = PageContext.new(@page) 54 @context.stub!(:raise_errors?).and_return(false) 55 @parser = Radius::Parser.new(@context, :tag_prefix => 'r') 56 end 57 58 it 'should output an error when it encounters a missing tag' do 59 @parser.parse('<r:missing />').should include("undefined tag `missing'") 60 end 61 62 it 'should pop the stack when an error occurs' do 63 @context.current_nesting.should be_empty 64 @context.define_tag("error") { |tag| raise "Broken!" } 65 @parser.parse("<r:error/>").should match(/Broken\!/) 66 @context.current_nesting.should be_empty 67 end 68 end trunk/radiant/test/unit/page_context_test.rb
r569 r757 13 13 def test_initialize 14 14 assert_equal(@page, @context.page) 15 end16 17 def test_tag_missing18 assert_raises(StandardTags::TagError) { @parser.parse '<r:missing />' }19 def @context.testing?() false end20 assert_parse_output_match "undefined tag `missing'", '<r:missing />'21 15 end 22 16 … … 43 37 end 44 38 45 def test_exception_pops_stack46 assert_equal '', @context.current_nesting47 @context.define_tag("error") {|tag| raise "Broken!"}48 def @context.testing?(); false; end49 assert_parse_output_match /Broken\!/, "<r:error/>"50 assert_equal '', @context.current_nesting51 end52 53 39 private 54 40
