Sha256: 9eaccaa07b68a6449901136a6f1dee7bb0dea7fefd4767bb9af58cbdbb870110

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'model/spec_helper'
require 'model/models/described_model'

require 'ronin/model/has_description'

describe Model::HasDescription do
  subject { DescribedModel }

  before(:all) do
    subject.auto_migrate!
  end

  it "should define a description property" do
    subject.properties.should be_named(:description)
  end

  describe "#description" do
    let(:resource) { DescribedModel.new }

    it "should allow the setting of the description" do
      resource.description = 'test one'
      resource.description.should == 'test one'
    end

    it "should strip leading and tailing white-space" do
      resource.description = %{   test two    }

      resource.description.should == 'test two'
    end

    it "should strip leading and tailing white-space from each line" do
      resource.description = %{
        test
        three
      }

      resource.description.should == "test\nthree"
    end

    it "should preserve non-bordering empty lines" do
      resource.description = %{
        test

        four
      }

      resource.description.should == "test\n\nfour"
    end
  end

  it "should be able to find resources with similar descriptions" do
    subject.create!(:description => 'foo one')
    subject.create!(:description => 'foo bar two')

    models = subject.describing('foo')

    models.length.should == 2
    models[0].description.should == 'foo one'
    models[1].description.should == 'foo bar two'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-1.0.0.rc1 spec/model/has_description_spec.rb
ronin-1.0.0.pre4 spec/model/has_description_spec.rb