github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

kpumuk / rspec-cells

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 8
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A library for testing applications that are using Cells in RSpec. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Fixe bug with integrate_views; Added ability to pass request, response and 
session parameters to the cell 
kpumuk (author)
Tue Sep 08 07:52:00 -0700 2009
commit  b1279890aa1c565c21eae69cc683cf0924c52baa
tree    9d67881a91243b206f7dee5f6087b44bcf36ef24
parent  a36c80f688cba396b93e4a1ab8cda8ec5b6cd613
rspec-cells /
name age
history
message
file History.txt Loading commit data...
file MIT-LICENSE
file README.rdoc
file Rakefile
file init.rb
directory lib/
directory spec/
directory spec_resources/
README.rdoc

Rspec Cells

This plugin allows you to test your cells easily using RSpec. Basically, it adds an example group especially for cells, with several helpers to perform cells rendering.

If you are not sure what is cells, please visit its home page:

cells.rubyforge.org/

Installation

If you’re using Rails 2.1, you can simply use "script/plugin". It will export all the code from GitHub into "vendor/plugins":

  script/plugin install git://github.com/kpumuk/rspec-cells.git

If you are using Rails prior to 2.1, use the following:

  cd vendor/plugins
  git clone git://github.com/kpumuk/rspec-cells.git
  rm -rf rspec-cells/.git
  cd ../..

To continuously track meta-tags development, it’s probably best to install it as a plugin using some vendor branch management tool like Braid:

  gem install evilchelu-braid

Using Braid to add a Rails plugin is simple:

  # (make sure you've committed everything first)
  braid add -p git://github.com/kpumuk/rspec-cells.git

  # now you should have the library in vendor/plugins/rspec-cells

After that is done, add following line into your spec_helper.rb:

  require 'spec/cells'

Usage

Put all your cells specs under spec/cells folder. Here is how spec looks like in general:

  describe VideoCell do
    integrate_views

    context '.videos' do
      it 'should initialize :videos variable' do
        params[:id] = 10
        session[:user_id] = 20
        opts[:opt] = 'value'
        result = render_cell :videos, { :videos => [] }, :slug => 'hello'
        result.should have_tag('div', :class => :videos)
      end
    end
  end

Please note: when you don’t pass a cell to describe, like this:

  describe ThingsCell do

then you must provide a cell_name within the context of your cell specs:

  describe "ThingCell" do
    cell_name :thing

In your spec you can use render_cell method to perform cell rendering.

By default rendering will not be performed, only code from cell class will be called. To do rendering, add integrate_views! statement in your describe block (just like you do for controllers).

From your spec you have access to several variables:

  • opts — options being passed to cell.
  • params — request parameters.
  • session — current session.
  • request — request object.
  • assigns — an array of cell instance variables.

Who are the authors?

This plugin has been created in Scribd.com for our internal use and then the sources were opened for other people to use. All the code in this package has been developed by Dmytro Shteflyuk for Scribd.com and is released under the MIT license. For more details, see the MIT-LICENSE file.

Credits

  • Dmytro Shteflyuk (author) <kpumuk@kpumuk.info> kpumuk.info
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server