Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 2194 Bytes
1 | require File.dirname(__FILE__) + '/../spec_helper' |
2 | |
3 | describe PageContext do |
4 | dataset :pages |
5 | |
6 | before :each do |
7 | @page = pages(:radius) |
8 | @context = PageContext.new(@page) |
9 | @parser = Radius::Parser.new(@context, :tag_prefix => 'r') |
10 | end |
11 | |
12 | it 'should raise an error when it encounters a missing tag' do |
13 | lambda { @parser.parse('<r:missing />') }.should raise_error(StandardTags::TagError) |
14 | end |
15 | |
16 | it 'should initialize correctly' do |
17 | @page.should equal(@context.page) |
18 | end |
19 | |
20 | it 'should give tags access to the request' do |
21 | @context.define_tag("if_request") { |tag| tag.expand if tag.locals.page.request } |
22 | parse('<r:if_request>tada!</r:if_request>').should match(/^$/) |
23 | |
24 | @page.request = ActionController::TestRequest.new |
25 | parse('<r:if_request>tada!</r:if_request>').should include("tada!") |
26 | parse('<r:find url="/another/"><r:if_request>tada!</r:if_request></r:find>').should include("tada!") |
27 | end |
28 | |
29 | it 'should give tags access to the response' do |
30 | @context.define_tag("if_response") { |tag| tag.expand if tag.locals.page.response } |
31 | parse('<r:if_response>tada!</r:if_response>').should match(/^$/) |
32 | |
33 | @page.response = ActionController::TestResponse.new |
34 | parse('<r:if_response>tada!</r:if_response>').should include("tada!") |
35 | parse('<r:find url="/another/"><r:if_response>tada!</r:if_response></r:find>').should include("tada!") |
36 | end |
37 | |
38 | private |
39 | |
40 | def parse(input) |
41 | @parser.parse(input) |
42 | end |
43 | |
44 | end |
45 | |
46 | describe PageContext, "when errors are not being raised" do |
47 | dataset :pages |
48 | |
49 | before :each do |
50 | @page = pages(:radius) |
51 | @context = PageContext.new(@page) |
52 | @context.stub!(:raise_errors?).and_return(false) |
53 | @parser = Radius::Parser.new(@context, :tag_prefix => 'r') |
54 | end |
55 | |
56 | it 'should output an error when it encounters a missing tag' do |
57 | @parser.parse('<r:missing />').should include("undefined tag `missing'") |
58 | end |
59 | |
60 | it 'should pop the stack when an error occurs' do |
61 | @context.current_nesting.should be_empty |
62 | @context.define_tag("error") { |tag| raise "Broken!" } |
63 | @parser.parse("<r:error/>").should match(/Broken\!/) |
64 | @context.current_nesting.should be_empty |
65 | end |
66 | end |