mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
844f9c3f3b
- Added command rails generate aasm NAME [COLUMN_NAME] - #205 - #220
33 lines
969 B
Ruby
33 lines
969 B
Ruby
require 'spec_helper'
|
|
require 'generator_spec'
|
|
require 'generators/mongoid/aasm_generator'
|
|
|
|
begin
|
|
require "mongoid"
|
|
|
|
describe Mongoid::Generators::AASMGenerator, type: :generator do
|
|
destination File.expand_path("../../../tmp", __FILE__)
|
|
|
|
before(:all) do
|
|
prepare_destination
|
|
end
|
|
|
|
it "creates model with aasm block for default column_name" do
|
|
run_generator %w(user)
|
|
assert_file "app/models/user.rb", /include AASM\n\n aasm do\n end\n/
|
|
end
|
|
|
|
it "creates model with aasm block for custom column_name" do
|
|
run_generator %w(user state)
|
|
assert_file "app/models/user.rb", /aasm :column => 'state' do\n end\n/
|
|
end
|
|
|
|
it "creates model with aasm block for namespaced model" do
|
|
run_generator %w(Admin::User state)
|
|
assert_file "app/models/admin/user.rb", /aasm :column => 'state' do\n end\n/
|
|
end
|
|
|
|
end
|
|
rescue LoadError
|
|
puts "Not running Mongoid specs because mongoid gem is not installed!!!"
|
|
end
|