Sha256: 79108ba9014c6afd828e33b62a02cb177231f2c8cff6499f4c9733c6d31ff122

Contents?: true

Size: 1.79 KB

Versions: 24

Compression:

Stored size: 1.79 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'

describe "include_text" do

  it "should have a helpful description" do
    matcher = include_text("foo bar")
    matcher.description.should == 'include text "foo bar"'
  end

  it 'should match if the text is contained' do
    matcher = include_text('big piece')
    matcher.matches?('I am a big piece of text').should be_true
  end

  it 'should not match if text is not contained' do
    matcher = include_text('foo bar')
    matcher.matches?('hello world').should be_false
  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 incorrect text" do
        post 'text_action'
        lambda {
          response.should include_text("the accordian guy")
        }.should fail_with("expected to find \"the accordian guy\" in \"this is the text for this action\"")
      end

      it "should pass using should_not with incorrect text" do
        post 'text_action'
        response.should_not include_text("the accordian guy")
      end

      it "should fail when a template is rendered" do
        get '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\"/)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
cavalle-rspec-rails-1.2.2.0.1 spec/spec/rails/matchers/include_text_spec.rb
cavalle-rspec-rails-1.2.2.0.2 spec/spec/rails/matchers/include_text_spec.rb
cavalle-rspec-rails-1.2.3.1 spec/spec/rails/matchers/include_text_spec.rb
cavalle-rspec-rails-1.2.4.0.1 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.1 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.13 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.2 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.3 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.4 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.5 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.6 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.7 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.8 spec/spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.99.9 spec/spec/rails/matchers/include_text_spec.rb
mcmire-rspec-rails-1.1.99.9 spec/spec/rails/matchers/include_text_spec.rb
rspec-rails-1.2.7 spec/spec/rails/matchers/include_text_spec.rb
rspec-rails-1.2.7.1 spec/spec/rails/matchers/include_text_spec.rb
rspec-rails-1.2.0 spec/spec/rails/matchers/include_text_spec.rb
rspec-rails-1.2.1 spec/spec/rails/matchers/include_text_spec.rb
rspec-rails-1.2.5 spec/spec/rails/matchers/include_text_spec.rb