File: singular_table_names_spec.rb

package info (click to toggle)
ruby-sequel 5.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,408 kB
  • sloc: ruby: 113,747; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require_relative "spec_helper"

describe "singular_table_names plugin" do
  before do
    @c = Class.new(Sequel::Model)
    @c.plugin :singular_table_names
  end
  after do
    Object.send(:remove_const, :Foo)
  end

  it "should use the singular form of model name for table name" do
    class ::Foo < @c; end
    Foo.table_name.must_equal :foo
  end

  it "should handle namespaced models using single form of last component of model name" do
    module ::Foo; end
    class Foo::Bar < @c; end
    Foo::Bar.table_name.must_equal :bar
  end
end