Permalink
Browse files

Merge pull request #1 from drichert/master

Improve README readability
  • Loading branch information...
2 parents e6bb3d4 + ef2e7c3 commit 3feb1ab23d6136da1a80b5e753beb6b314eedb0c Kengo Suzuki committed Mar 20, 2012
Showing with 88 additions and 66 deletions.
  1. +88 −66 README.md
View
@@ -6,102 +6,124 @@ https://github.com/econsultancy/rspec-caching-test-plugin/blob/econsultancy-2011
## Insatall
-: In your Gemfile:
+In your Gemfile:
- gem 'rspec_caching_test', require: 'false', git: 'git://github.com/kengos/rspec_caching_test.git'
+```ruby
+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
+In your spec_helper.rb:
+```ruby
+require 'rspec_caching_test'
+RspecCachingTest::CacheTest.setup
+```
with Spork:
- Spork.prefork do
- # something
+```ruby
+Spork.prefork do
+ # something
- require 'rspec_caching_test'
- RspecCachingTest::CacheTest.setup
+ require 'rspec_caching_test'
+ RspecCachingTest::CacheTest.setup
- RSpec.configure do |config|
- # something
- end
- end
+ RSpec.configure do |config|
+ # something
+ end
+end
- Spork.each_run do
- # something
- 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
+Controller:
- describe "get 'index'" do
- it "should cache the page" do
- lambda { get :index }.should cache_page('/products') # this is page url
- end
- end
+```ruby
+class ProductsController < ActionController::Base
+ caches_page :index
+
+ def index
+ # something
+ end
+end
+```
+
+RSpec:
+
+```ruby
+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
+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
+```ruby
+class ProductsController < ActionController::Base
+ caches_action :index
+
+ def index
+ # something
+ end
+end
+```
+
+RSpec:
+
+```ruby
+describe "get 'index'" do
+ it "should cache the action" do
+ lambda { get :index }.should cache_action(:index)
+ end
+end
+```
### if you use fragment
-: View
+View:
- <%= cache 'my_cache' do %>
- <p>my_cache</p>
- <% end %>
+```erb
+<%= cache 'my_cache' do %>
+ <p>my_cache</p>
+<% end %>
+```
-: RSpec
+RSpec:
- describe "get 'index'" do
- it "should fragment cache" do
- lambda { get :index }.should cache_fragment('views/my_cache')
- end
- end
+```ruby
+describe "get 'index'" do
+ it "should fragment cache" do
+ lambda { get :index }.should cache_fragment('views/my_cache')
+ end
+end
+```
## More
-: use subject
+use subject:
- before { get :index }
- subject { controller.cache_store.cached }
- it { should have(3).items }
- it { should be_include([xxxx, yyyy, zzzz]) }
-
-: cache_store
+```ruby
+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 }
+```ruby
+before { get :index }
+it { controller.cache_store.should be_kind_of RspecCachingTest::CacheTest::TestStore }
+```

0 comments on commit 3feb1ab

Please sign in to comment.