Sha256: 769e5932be01d7d131afda5fc9a35af87654bbc60bb86e5ca0a5472b4f50da12

Contents?: true

Size: 720 Bytes

Versions: 5

Compression:

Stored size: 720 Bytes

Contents

require 'model/spec_helper'
require 'model/models/named_model'

require 'ronin/model/has_name'

describe Model::HasName do
  subject { NamedModel }

  before(:all) do
    subject.auto_migrate!
  end

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

  it "should require a name" do
    model = subject.new
    model.should_not be_valid

    model.name = 'foo'
    model.should be_valid
  end

  it "should be able to find resources with similar names" do
    subject.create!(:name => 'foo1')
    subject.create!(:name => 'foo2')

    models = subject.named('foo')

    models.length.should == 2
    models[0].name.should == 'foo1'
    models[1].name.should == 'foo2'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ronin-1.0.0.rc1 spec/model/has_name_spec.rb
ronin-1.0.0.pre4 spec/model/has_name_spec.rb
ronin-1.0.0.pre3 spec/model/has_name_spec.rb
ronin-1.0.0.pre2 spec/model/has_name_spec.rb
ronin-1.0.0.pre1 spec/model/has_name_spec.rb