Sha256: a4f8d942aa8ddac751c3d7d5f9bcf45316bdc06dcc0396d9f7cfd26873aa808b

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe BBCoder do

  subject { BBCoder.new("[p]Text and now [b]bolded.[/b][/p]") }

  context "#configuration" do
    it "should return the same object for multiple calls" do
      BBCoder.configuration.should == BBCoder.configuration
    end
  end

  context "#buffer" do
    it "should return the same object for multiple calls" do
      subject.buffer.should == subject.buffer
    end
  end

  context "#configure" do
    it "should fail without a block" do
      lambda { BBCoder.configure }.should raise_error
    end

    it "should instance_eval the block onto configuration" do
      block = Proc.new { tag :p }
      mock(BBCoder).configuration.stub!.instance_eval(&block)
      BBCoder.configure(&block)
    end
  end

  context "#initialize" do
    it "should split tags up properly" do
      subject.raw.should == ["[p]", "Text and now ", "[b]", "bolded.", "[/b]", "[/p]"]
    end
  end

  context "#parse" do
    it "should loop through raw elements and join the buffer" do
      mock(subject).raw.stub!.each {nil}
      mock(subject).buffer.stub!.join {"output"}

      subject.parse
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
bbcoder-0.1.5 spec/base_spec.rb
airsprite-1.0 spec/base_spec.rb
bbcoder-0.1.4 spec/base_spec.rb
bbcoder-0.1.3 spec/base_spec.rb
bbcoder-0.1.2 spec/base_spec.rb
bbcoder-0.1.1 spec/base_spec.rb
bbcoder-0.1.0 spec/base_spec.rb