extract Sequel test models into model files

This commit is contained in:
Thorsten Böttger 2015-07-11 22:36:07 +12:00
parent 01bd975817
commit 2652abd4ec
4 changed files with 56 additions and 48 deletions

View File

@ -0,0 +1,25 @@
db = Sequel.connect(SEQUEL_DB)
# if you want to see the statements while running the spec enable the following line
# db.loggers << Logger.new($stderr)
db.create_table(:multiples) do
primary_key :id
String :status
end
class SequelMultiple < Sequel::Model(db)
set_dataset(:multiples)
include AASM
attr_accessor :default
aasm :left, :column => :status
aasm :left do
state :alpha, :initial => true
state :beta
state :gamma
event :release do
transitions :from => [:alpha, :beta, :gamma], :to => :beta
end
end
end

View File

@ -0,0 +1,25 @@
db = Sequel.connect(SEQUEL_DB)
# if you want to see the statements while running the spec enable the following line
# db.loggers << Logger.new($stderr)
db.create_table(:simples) do
primary_key :id
String :status
end
class SequelSimple < Sequel::Model(db)
set_dataset(:simples)
include AASM
attr_accessor :default
aasm :column => :status
aasm do
state :alpha, :initial => true
state :beta
state :gamma
event :release do
transitions :from => [:alpha, :beta, :gamma], :to => :beta
end
end
end

View File

@ -9,31 +9,7 @@ describe 'sequel' do
end
before(:all) do
db = Sequel.connect(SEQUEL_DB)
# if you want to see the statements while running the spec enable the following line
# db.loggers << Logger.new($stderr)
db.create_table(:models) do
primary_key :id
String :status
end
@model = Class.new(Sequel::Model(db)) do
set_dataset(:models)
include AASM
attr_accessor :default
aasm :left, :column => :status
aasm :left do
state :alpha, :initial => true
state :beta
state :gamma
event :release do
transitions :from => [:alpha, :beta, :gamma], :to => :beta
end
end
end
@model = SequelMultiple
end
describe "instance methods" do

View File

@ -4,30 +4,12 @@ describe 'sequel' do
require 'logger'
require 'spec_helper'
Dir[File.dirname(__FILE__) + "/../../models/sequel/*.rb"].sort.each do |f|
require File.expand_path(f)
end
before(:all) do
db = Sequel.connect(SEQUEL_DB)
# if you want to see the statements while running the spec enable the following line
# db.loggers << Logger.new($stderr)
db.create_table(:models) do
primary_key :id
String :status
end
@model = Class.new(Sequel::Model(db)) do
set_dataset(:models)
attr_accessor :default
include AASM
aasm :column => :status
aasm do
state :alpha, :initial => true
state :beta
state :gamma
event :release do
transitions :from => [:alpha, :beta, :gamma], :to => :beta
end
end
end
@model = SequelSimple
end
describe "instance methods" do