require File.join(File.dirname(__FILE__),'generator_spec_helper') describe "Generator" do appname = 'mynewapp' source = 'mysource' path = File.expand_path(File.join(File.dirname(__FILE__))) before(:each) do FileUtils.mkdir_p '/tmp' end describe "AppGenerator" do it "should complain if no name is specified" do lambda { Rhoconnect::AppGenerator.new('/tmp',{}) }.should raise_error(Templater::TooFewArgumentsError) end before(:each) do @generator = Rhoconnect::AppGenerator.new('/tmp',{},appname) end it "should create new ruby application files" do SecureRandom.should_receive(:hex).with(64).any_number_of_times [ 'Gemfile', 'Rakefile', "controllers/ruby/application_controller.rb", 'spec/controllers/ruby/application_controller_spec.rb', 'config.ru', 'public', 'settings/settings.yml', 'settings/license.key', 'spec/spec_helper.rb' ].each do |template| @generator.should create("/tmp/#{appname}/#{template}") end end end describe "SourceGenerator" do it "should complain if no name is specified" do lambda { Rhoconnect::SourceGenerator.new('/tmp',{}) }.should raise_error(Templater::TooFewArgumentsError) end before(:each) do FileUtils.rm_rf "/tmp/#{appname}" @app_generator = Rhoconnect::AppGenerator.new('/tmp',{},appname) @app_generator.invoke! Bundler.with_clean_env do @app_generator.after_run end @generator = Rhoconnect::SourceGenerator.new("/tmp/#{appname}",{},source) end it "should create new source adapter and spec" do @generator.should create("/tmp/#{appname}/models/ruby/#{source}.rb") @generator.should create("/tmp/#{appname}/controllers/ruby/#{source}_controller.rb") @generator.should create("/tmp/#{appname}/spec/models/ruby/#{source}_spec.rb") @generator.should create("/tmp/#{appname}/spec/controllers/ruby/#{source}_controller_spec.rb") end end end