Sha256: a84c59526853db4028d104442c43a0a6fd77513715a28ee6f7f7163a992e817d

Contents?: true

Size: 1.42 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
ronin-1.0.0.pre3 spec/model/has_description_spec.rb
ronin-1.0.0.pre2 spec/model/has_description_spec.rb
ronin-1.0.0.pre1 spec/model/has_description_spec.rb