Sha256: 0b3ecf18803fe8656cbfac75b2485642752c95cd67751b613c62abcc2cc2a260

Contents?: true

Size: 1.81 KB

Versions: 31

Compression:

Stored size: 1.81 KB

Contents

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 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

31 entries across 31 versions & 6 rubygems

Version Path
dchelimsky-rspec-rails-1.1.10 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.11.1 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.11.2 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.11.3 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.11 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.6 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.7 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.8 spec/rails/matchers/include_text_spec.rb
dchelimsky-rspec-rails-1.1.9 spec/rails/matchers/include_text_spec.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb