mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
extract Sequel test models into model files
This commit is contained in:
parent
01bd975817
commit
2652abd4ec
4 changed files with 56 additions and 48 deletions
25
spec/models/sequel/sequel_multiple.rb
Normal file
25
spec/models/sequel/sequel_multiple.rb
Normal 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
|
25
spec/models/sequel/sequel_simple.rb
Normal file
25
spec/models/sequel/sequel_simple.rb
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue