dchelimsky / rspec-dev

Resources for rspec developers/contributors

This URL has Read+Write access

rspec-dev / example_rails_app / spec / views / people / list_view_spec.rb
100644 36 lines (28 sloc) 0.983 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require File.dirname(__FILE__) + '/../../spec_helper'
 
describe "/people/list" do
 
  before(:each) do
    @smith = mock_model(Person)
    @jones = mock_model(Person)
    @smith.stub!(:name).and_return("Joe")
    @jones.stub!(:name).and_return("Joe")
    assigns[:people] = [@smith, @jones]
  end
 
  it "should display the list of people" do
    @smith.should_receive(:name).exactly(3).times.and_return("Smith")
    @jones.should_receive(:name).exactly(3).times.and_return("Jones")
 
    # Careful - this renders 'app/views/people/list.html.erb', not 'http://localhost/people/list'
    render "/people/list"
 
    response.should have_tag('ul') do
      with_tag('li', 'Name: Smith')
      with_tag('li', 'Name: Jones')
    end
  end
 
  it "should have a <div> tag with :id => 'a" do
    render "/people/list"
    response.should have_tag('div#a')
  end
 
  it "should have a <hr> tag with :id => 'spacer" do
    render "/people/list"
    response.should have_tag('hr#spacer')
  end
end