Browse files

Use FactoryGirl i.o. dataset in PageContextSpec

  • Loading branch information...
1 parent c059697 commit 473c191cc5eb1e4134a1fc44bb82fe94b2a70dc9 @jomz jomz committed Feb 8, 2014
Showing with 6 additions and 9 deletions.
  1. +6 −9 spec/models/page_context_spec.rb
View
15 spec/models/page_context_spec.rb
@@ -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
@@ -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
@@ -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

0 comments on commit 473c191

Please sign in to comment.