Sha256: a29cdd27eafd4830a98df876304afa44dd6276c106bd425c452d9326e7b76b27

Contents?: true

Size: 779 Bytes

Versions: 7

Compression:

Stored size: 779 Bytes

Contents

require "administrate/field/ckeditor"

describe Administrate::Field::Ckeditor do
  
  let(:page) { :show }
  let(:data) { "<h1>Hello!</h1>\n<p>This is an exciting piece of data!</p>" }
  subject { Administrate::Field::Ckeditor.new(:relation, "/a.jpg", page) }
  before(:each) do
    allow(subject).to receive(:data).and_return(data)
    allow(subject).to receive(:truncation_length).and_return(10)
  end
    
  describe "#to_partial_path" do
    it "returns a partial based on the page being rendered" do
      expect(subject.to_partial_path).to eq("/fields/ckeditor/#{page}")
    end
  end
  
  describe '#truncate_stripped' do
    it 'strips out HTML and truncates to the truncation length' do
      expect(subject.truncate_stripped).to eq("Hello!\nThis")
    end
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
administrate-field-ckeditor-0.0.9 spec/lib/administrate/field/ckeditor_spec.rb
administrate-field-ckeditor-0.0.8 spec/lib/administrate/field/ckeditor_spec.rb
administrate-field-ckeditor-0.0.7 spec/lib/administrate/field/ckeditor_spec.rb
administrate-field-ckeditor-0.0.6 spec/lib/administrate/field/ckeditor_spec.rb
administrate-field-ckeditor-0.0.5 spec/lib/administrate/field/ckeditor_spec.rb
administrate-field-ckeditor-0.0.4 spec/lib/administrate/field/ckeditor_spec.rb
administrate-field-ckeditor-0.0.3 spec/lib/administrate/field/ckeditor_spec.rb