require "administrate/field/ckeditor" describe Administrate::Field::Ckeditor do let(:page) { :show } let(:data) { "
This is an exciting piece of data!
" } 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