changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
3describe "have_text" do
4
5 describe "where target is a Regexp" do
6 it 'should should match submitted text using a regexp' do
7 string = 'foo'
8 string.should have_text(/fo*/)
9 end
10 end
11
12 describe "where target is a String" do
13 it 'should match submitted text using a string' do
14 string = 'foo'
15 string.should have_text('foo')
16 end
17 end
18
19end
20
21describe "have_text",
22 :type => :controller do
23 ['isolation','integration'].each do |mode|
24 if mode == 'integration'
25 integrate_views
26 end
27
28 describe "where target is a response (in #{mode} mode)" do
29 controller_name :render_spec
30
31 it "should pass with exactly matching text" do
32 post 'text_action'
33 response.should have_text("this is the text for this action")
34 end
35
36 it "should pass with matching text (using Regexp)" do
37 post 'text_action'
38 response.should have_text(/is the text/)
39 end
40
41 it "should fail with matching text" do
42 post 'text_action'
43 lambda {
44 response.should have_text("this is NOT the text for this action")
45 }.should fail_with("expected \"this is NOT the text for this action\", got \"this is the text for this action\"")
46 end
47
48 it "should fail when a template is rendered" do
49 post 'some_action'
50 lambda {
51 response.should have_text("this is the text for this action")
52 }.should fail_with(/expected \"this is the text for this action\", got .*/)
53 end
54
55 it "should pass using should_not with incorrect text" do
56 post 'text_action'
57 response.should_not have_text("the accordian guy")
58 end
59 end
60 end
61end
62