Sha256: 3092812fb5ba7d2e0002261adcbd80ee43de90b383f057d779f0c64a17d5e1f9

Contents?: true

Size: 824 Bytes

Versions: 9

Compression:

Stored size: 824 Bytes

Contents

require 'model/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

9 entries across 9 versions & 1 rubygems

Version Path
ronin-1.3.0 spec/model/has_name_spec.rb
ronin-1.2.0 spec/model/has_name_spec.rb
ronin-1.1.0 spec/model/has_name_spec.rb
ronin-1.1.0.rc3 spec/model/has_name_spec.rb
ronin-1.1.0.rc2 spec/model/has_name_spec.rb
ronin-1.1.0.rc1 spec/model/has_name_spec.rb
ronin-1.0.0 spec/model/has_name_spec.rb
ronin-1.0.0.rc3 spec/model/has_name_spec.rb
ronin-1.0.0.rc2 spec/model/has_name_spec.rb