We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Textmate bundle for RSpec.
Clone URL: git://github.com/dchelimsky/rspec-tmbundle.git
commit  6f2c4cf4741bef610bc23982b2c9fcf6d96d8b07
tree    71921ca205a730f1377f95999301ca91a33cf903
parent  b6468839603b24d8635b3c6d39bf4a5819a487d4
rspec-tmbundle / rspec_on_rails / spec / rails / matchers / include_text_spec.rb
100644 65 lines (51 sloc) 1.928 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
 
describe "include_text" do
 
  describe "where target is a String" do
    it 'should match submitted text using a string' do
      string = 'foo'
      string.should include_text('foo')
    end
 
    it 'should match if the text is contained' do
      string = 'I am a big piece of text'
      string.should include_text('big piece')
    end
 
    it 'should not match if text is not contained' do
      string = 'I am a big piece of text'
      string.should_not include_text('corey')
    end
  end
 
end
 
describe "include_text", :type => :controller do
  ['isolation','integration'].each do |mode|
    if mode == 'integration'
      integrate_views
    end
 
    describe "where target is a response (in #{mode} mode)" do
      controller_name :render_spec
 
      it "should pass with exactly matching text" do
        post 'text_action'
        response.should include_text("this is the text for this action")
      end
 
      it 'should pass with substring matching text' do
        post 'text_action'
        response.should include_text('text for this')
      end
 
      it "should fail with matching text" do
        post 'text_action'
        lambda {
          response.should include_text("this is NOT the text for this action")
        }.should fail_with("expected to find \"this is NOT the text for this action\" in \"this is the text for this action\"")
      end
 
      it "should fail when a template is rendered" do
        post 'some_action'
        lambda {
          response.should include_text("this is the text for this action")
        }.should fail_with(/expected to find \"this is the text for this action\" in \"render_spec\/some_action\"/)
      end
 
      it "should pass using should_not with incorrect text" do
        post 'text_action'
        response.should_not include_text("the accordian guy")
      end
    end
  end
end