Skip to content

Commit

Permalink
Use FactoryGirl i.o. dataset in PageContextSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
jomz committed Feb 8, 2014
1 parent c059697 commit 473c191
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions spec/models/page_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe PageContext do
#dataset :pages

before :each do
@page = pages(:radius)
@page = FactoryGirl.build(:home)
@context = PageContext.new(@page)
@parser = Radius::Parser.new(@context, :tag_prefix => 'r')
@context = @parser.context
Expand All @@ -22,16 +20,17 @@
@context.define_tag("if_request") { |tag| tag.expand if tag.locals.page.request }
parse('<r:if_request>tada!</r:if_request>').should match(/^$/)

@page.request = ActionController::TestRequest.new
@page.request = ActionDispatch::TestRequest.new
parse('<r:if_request>tada!</r:if_request>').should include("tada!")
parse('<r:find url="/another/"><r:if_request>tada!</r:if_request></r:find>').should include("tada!")
end

it 'should give tags access to the response' do
@page.save!
@context.define_tag("if_response") { |tag| tag.expand if tag.locals.page.response }
parse('<r:if_response>tada!</r:if_response>').should match(/^$/)

@page.response = ActionController::TestResponse.new
@page.response = ActionDispatch::TestRequest.new
parse('<r:if_response>tada!</r:if_response>').should include("tada!")
parse('<r:find url="/another/"><r:if_response>tada!</r:if_response></r:find>').should include("tada!")
end
Expand All @@ -45,13 +44,11 @@ def parse(input)
end

describe PageContext, "when errors are not being raised" do
#dataset :pages

before :each do
@page = pages(:radius)
@page = FactoryGirl.build(:home)
@context = PageContext.new(@page)
@parser = Radius::Parser.new(@context, :tag_prefix => 'r')
@parser.context.stub!(:raise_errors?).and_return(false)
@parser.context.stub(:raise_errors?).and_return(false)
@context = @parser.context
end

Expand Down

0 comments on commit 473c191

Please sign in to comment.