Sha256: 28ddbfe64fff98e3cd2d2f537f641b99cb3a88f13855756a9c094dcf20182354

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

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

describe "Sniffles::Text" do
  before(:all) do
    class Klass
      include Sniffles::Text
      attr_accessor :doc
    end
    
    @klass = Klass.new
    @text = "This is multi-line\ntext."
    @klass.parse @text
  end
  
  describe "#parse" do
    it "should take text and return a string" do
      @klass.doc.should eq @text
    end
  end
  
  describe "#match?" do
    context "does match" do
      it "should return true" do
        @klass.match?(/is/).should eq true
      end
    end
    
    context "does not match" do
      it "should return false" do
        @klass.match?(/foobar/).should eq false
      end
    end
  end
  
  describe "#capture" do
    context "match" do
      it "should return the first captured string" do
        @klass.capture(/(multi\-line)/).should eq "multi-line"
      end
    end
    
    context "no match" do
      it "should return false" do
        @klass.capture(/(foobar)/).should eq false
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sniffles-0.2.0 spec/sniffles/text_spec.rb
sniffles-0.1.5 spec/sniffles/text_spec.rb
sniffles-0.1.4 spec/sniffles/text_spec.rb
sniffles-0.1.3 spec/sniffles/text_spec.rb
sniffles-0.1.2 spec/sniffles/text_spec.rb
sniffles-0.1.1 spec/sniffles/text_spec.rb
sniffles-0.1.0.1 spec/sniffles/text_spec.rb
sniffles-0.1.0 spec/sniffles/text_spec.rb