extract Sequel test models into model files
This commit is contained in:
parent
01bd975817
commit
2652abd4ec
|
@ -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
|
|
@ -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
|
|
@ -9,31 +9,7 @@ describe 'sequel' do
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:all) do
|
before(:all) do
|
||||||
db = Sequel.connect(SEQUEL_DB)
|
@model = SequelMultiple
|
||||||
|
|
||||||
# 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "instance methods" do
|
describe "instance methods" do
|
||||||
|
|
|
@ -4,30 +4,12 @@ describe 'sequel' do
|
||||||
require 'logger'
|
require 'logger'
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
|
Dir[File.dirname(__FILE__) + "/../../models/sequel/*.rb"].sort.each do |f|
|
||||||
|
require File.expand_path(f)
|
||||||
|
end
|
||||||
|
|
||||||
before(:all) do
|
before(:all) do
|
||||||
db = Sequel.connect(SEQUEL_DB)
|
@model = SequelSimple
|
||||||
|
|
||||||
# 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "instance methods" do
|
describe "instance methods" do
|
||||||
|
|
Loading…
Reference in New Issue