trailblazer / rspec-cells

Spec your Cells.
http://cells.rubyforge.org
MIT License
62 stars 48 forks source link

Fix up template #18

Closed banyan closed 12 years ago

banyan commented 12 years ago

Hi @apotonick.

I was really impressed by your presentation at Sapporo Ruby Kaigi, and I've started to use Cells, It's awesome!

Anyway, This pull request is for:

  1. Fixing up template
  2. Use Capybara syntax if it were using

What do you think of it? Belows are output example of $ rails g cell cart foo bar.

before:

require 'spec_helper'

describe CartCell do
  context "cell rendering" do  

    context "rendering foo" do
      subject { render_cell(:cart, :foo) }

      it { should have_selector("h1", :content => "Cart#foo") }
      it { should have_selector("p", :content => "Find me in app/cells/cart/foo.html") }
    end 

    context "rendering bar" do
      subject { render_cell(:cart, :bar) }

      it { should have_selector("h1", :content => "Cart#bar") }
      it { should have_selector("p", :content => "Find me in app/cells/cart/bar.html") }
    end 

  end 

  context "cell instance" do  
    subject { cell(:cart) } 

    it { should respond_to(:foo) }

    it { should respond_to(:bar) }

  end 
end

after:

require 'spec_helper'

describe CartCell do

  context "cell instance" do
    subject { cell(:cart) }

    it { should respond_to(:foo) }
    it { should respond_to(:bar) }
  end 

  context "cell rendering" do
    context "rendering foo" do
      subject { render_cell(:cart, :foo) }

      it { should have_selector("h1", :text => "Cart#foo") }
      it { should have_selector("p", :text => "Find me in app/cells/cart/foo.html") }
    end 

    context "rendering bar" do
      subject { render_cell(:cart, :bar) }

      it { should have_selector("h1", :text => "Cart#bar") }
      it { should have_selector("p", :text => "Find me in app/cells/cart/bar.html") }
    end 
  end 

end