Sha256: 2d63574ab15ed1514befeaed8242c5f9302dc3a62b8991516fafe07fedb1312f

Contents?: true

Size: 818 Bytes

Versions: 7

Compression:

Stored size: 818 Bytes

Contents

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

require 'ronin/model/has_name'

describe Model::HasName do
  subject { NamedModel }

  before(:all) { subject.auto_migrate! }

  it "should include Ronin::Model" do
    subject.ancestors.should include(Model)
  end

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

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

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

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

    resources = subject.named('foo')

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ronin-1.5.0 spec/model/has_name_spec.rb
ronin-1.5.0.rc2 spec/model/has_name_spec.rb
ronin-1.5.0.rc1 spec/model/has_name_spec.rb
ronin-1.4.1 spec/model/has_name_spec.rb
ronin-1.4.0 spec/model/has_name_spec.rb
ronin-1.4.0.rc2 spec/model/has_name_spec.rb
ronin-1.4.0.rc1 spec/model/has_name_spec.rb