Skip to content

jachenry/rspec_caching_test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rspec_caching_test

this is copy project

https://github.com/econsultancy/rspec-caching-test-plugin/blob/econsultancy-2011-08-05

Insatall

: In your Gemfile:

gem 'rspec_caching_test', require: 'false', git: 'git://github.com/kengos/rspec_caching_test.git'

: In your spec_helper.rb:

require 'rspec_caching_test'
RspecCachingTest::CacheTest.setup

with Spork:

Spork.prefork do
  # something
	
	require 'rspec_caching_test'
	RspecCachingTest::CacheTest.setup
	
	RSpec.configure do |config|
	# something
	end
end

Spork.each_run do
	# something
end

Usage:

if you use caches_page

: Controller

class ProductsController < ActionController::Base
	caches_page :index  
	def index
		# something
	end
end

: RSpec

describe "get 'index'" do
	it "should cache the page" do
		lambda { get :index }.should cache_page('/products') # this is page url
	end
end

if you use caches_action

Maybe contains bugs

: Controller

class ProductsController < ActionController::Base
  caches_action :index
  def index
    # something
  end
end

: RSpec

describe "get 'index'" do
	it "should cache the action" do
		lambda { get :index }.should cache_action(:index)
	end
end

if you use fragment

: View

<%= cache 'my_cache' do %>
	<p>my_cache</p>
<% end %>

: RSpec

describe "get 'index'" do
	it "should fragment cache" do
		lambda { get :index }.should cache_fragment('views/my_cache')
	end
end

More

: use subject

before { get :index }
subject { controller.cache_store.cached }
it { should have(3).items }
it { should be_include([xxxx, yyyy, zzzz]) }

: cache_store

before { get :index }
it { controller.cache_store.should be_kind_of RspecCachingTest::CacheTest::TestStore }

About

rspec_caching_test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published