spec/generators/gallery_generator_spec.rb in adminpanel-1.2.8 vs spec/generators/gallery_generator_spec.rb in adminpanel-1.2.9
- old
+ new
@@ -1,53 +1,49 @@
require 'spec_helper'
+require 'generators/adminpanel/gallery/gallery_generator'
-describe "adminpanel:gallery" do
+describe Adminpanel::Generators::GalleryGenerator do
+ destination File.expand_path("../../dummy/tmp", __FILE__)
- with_args :Product do
- it 'should generate the model' do
- subject.should generate('app/models/adminpanel/productfile.rb'){ |content|
- content.should =~ /attr_accessible :product_id, :file/ &&
- content.should =~ /mount_uploader :file, ProductfileUploader/
- }
+ before do
+ Rails::Generators.options[:rails][:orm] = :active_record
+ end
+
+ # after do
+ # prepare_destination
+ # end
+
+ describe 'with "product" as argument' do
+ before do
+ prepare_destination
+ run_generator %w(Product)
end
- it 'should generate the uploader' do
- subject.should generate('app/uploader/adminpanel/productfile_uploader.rb')
+ it 'should generate the productfile migration' do
+ migration_file('db/migrate/create_adminpanel_productfiles_table.rb').should
+ be_a_migration
end
- # it 'should generate the migration' do
- # subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_productfields_table.rb"){|content|
- # content.should =~ /t.integer :product_id/
- # }
- #
- # end
- #
- # it "should generate the default category model" do
- # subject.should generate("app/models/adminpanel/category.rb")
- # end
- #
- # it 'should generate the categories migration' do
- # subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_categories_table.rb")
- # end
- # end
- #
- # with_args :'-c', :false do
- # it "shouldn't generate the default category model" do
- # subject.should_not generate("app/models/adminpanel/category.rb")
- # end
- #
- # it "shouldn't generate the categories migration" do
- # subject.should_not generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_categories_table.rb")
- # end
- #
- # it "should generate the initialization migration" do
- # subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_adminpanel_tables.rb")
- # end
- #
- # end
- #
- # it 'should generate the configuration initializer' do
- # subject.should generate('config/initializers/adminpanel_setup.rb'){ |content|
- # content.should =~ /Adminpanel.setup do |config|/
- # }
+
+ it 'should migrate the correct fields' do
+ migration_file('db/migrate/create_adminpanel_productfiles_table.rb').should(
+ contain(/t.integer :product_id/) &&
+ contain(/create_table :adminpanel_productfiles/)
+ )
+ end
+
+ it 'should generate the productfile model with uploader and attr_accessible' do
+ file('app/models/adminpanel/productfile.rb').should(
+ contain(/attr_accessible :product_id, :file/) &&
+ contain(/mount_uploader :file, ProductfileUploader/)
+ )
+ end
+
+ it 'should generate the productfile model with uploader and attr_accessible' do
+ file('app/models/adminpanel/productfile.rb').should exist
+ end
+
+ it 'should the produfile uploader' do
+ file('app/uploaders/adminpanel/productfile_uploader.rb').should exist
+ end
end
end