2012-12-21 16:29:15 +08:00
|
|
|
require 'spec_helper'
|
2013-02-12 23:17:46 +08:00
|
|
|
require 'generator_helper'
|
2012-12-21 16:29:15 +08:00
|
|
|
|
2012-12-22 03:51:44 +08:00
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:setup
|
2012-12-21 16:29:15 +08:00
|
|
|
feature Paloma::SetupGenerator do
|
|
|
|
include GeneratorSpec::TestCase
|
2012-12-22 03:51:44 +08:00
|
|
|
destination TEMP
|
2012-12-21 16:29:15 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
2012-12-22 03:51:44 +08:00
|
|
|
directory Paloma.destination do
|
|
|
|
file 'paloma.js'
|
|
|
|
file 'index.js'
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add sexy_controller
|
2012-12-22 03:51:44 +08:00
|
|
|
feature Paloma::AddGenerator, 'creating controller folder only' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
|
|
|
arguments ['sexy_controller']
|
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
2013-01-10 11:38:51 +08:00
|
|
|
directory 'sexy_controller' do
|
|
|
|
file '_callbacks.js' do
|
|
|
|
contains "//= require ./_local.js"
|
|
|
|
contains "//= require_tree ."
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['sexy_controller'] = {};"
|
|
|
|
contains "Paloma.sexy_controller = { /* Put local variables and functions here */ };"
|
2013-01-10 11:38:51 +08:00
|
|
|
end
|
|
|
|
end
|
2012-12-22 03:51:44 +08:00
|
|
|
|
|
|
|
file 'index.js' do
|
2013-01-10 11:38:51 +08:00
|
|
|
contains '//= require ./sexy_controller/_callbacks.js'
|
2012-12-21 16:29:15 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add namespace/new_controller_folder
|
|
|
|
feature Paloma::AddGenerator, 'creating a namespaced controller folder' do
|
2012-12-21 16:29:15 +08:00
|
|
|
include GeneratorSpec::TestCase
|
2012-12-22 03:51:44 +08:00
|
|
|
destination TEMP
|
2013-01-10 14:32:59 +08:00
|
|
|
arguments ['namespace/new_controller_folder']
|
2012-12-21 16:29:15 +08:00
|
|
|
|
|
|
|
before do
|
2012-12-22 03:51:44 +08:00
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
2012-12-21 16:29:15 +08:00
|
|
|
run_generator
|
|
|
|
end
|
2012-12-22 03:51:44 +08:00
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
2013-01-10 14:32:59 +08:00
|
|
|
directory 'namespace' do
|
|
|
|
directory 'new_controller_folder' do
|
|
|
|
file '_callbacks.js' do
|
|
|
|
contains '//= require ./_local.js'
|
|
|
|
contains '//= require_tree .'
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['namespace/new_controller_folder'] = {};"
|
2013-01-10 14:32:59 +08:00
|
|
|
contains 'Paloma.namespace.new_controller_folder = {'
|
|
|
|
end
|
2012-12-22 03:51:44 +08:00
|
|
|
end
|
2013-01-10 14:32:59 +08:00
|
|
|
file '_callbacks.js' do
|
|
|
|
contains "//= require ./_local.js"
|
|
|
|
contains "//= require ./new_controller_folder/_callbacks.js"
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
|
|
|
contains "Paloma.namespace = {"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
file 'index.js' do
|
|
|
|
contains "//= require ./namespace/_callbacks.js"
|
2012-12-22 03:51:44 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2012-12-21 16:29:15 +08:00
|
|
|
|
2012-12-22 03:51:44 +08:00
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add new_controller_folder new_action
|
2012-12-22 03:51:44 +08:00
|
|
|
feature Paloma::AddGenerator, 'creating both controller folder and action file' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
2013-01-08 15:33:40 +08:00
|
|
|
arguments ['new_controller_folder', 'new_action']
|
2012-12-22 03:51:44 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
2012-12-21 16:29:15 +08:00
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
2012-12-22 03:51:44 +08:00
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'new_controller_folder' do
|
|
|
|
file 'new_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['new_controller_folder']['new_action']"
|
2012-12-21 16:29:15 +08:00
|
|
|
end
|
2013-01-10 11:38:51 +08:00
|
|
|
|
|
|
|
file '_callbacks.js' do
|
|
|
|
contains "//= require ./_local.js"
|
|
|
|
contains "//= require_tree ."
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
|
|
|
contains "Paloma.new_controller_folder = {"
|
|
|
|
end
|
2012-12-21 16:29:15 +08:00
|
|
|
end
|
2013-01-10 11:38:51 +08:00
|
|
|
|
|
|
|
file 'index.js' do
|
|
|
|
contains "//= require ./new_controller_folder/_callbacks.js"
|
|
|
|
end
|
2012-12-21 16:29:15 +08:00
|
|
|
end
|
|
|
|
}
|
2012-12-22 03:51:44 +08:00
|
|
|
end
|
2012-12-21 16:29:15 +08:00
|
|
|
end
|
2013-01-03 16:39:41 +08:00
|
|
|
|
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add existing_controller_folder new_action
|
|
|
|
feature Paloma::AddGenerator, 'creating action with existing controller folder' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
|
|
|
arguments ['existing_controller_folder', 'new_action']
|
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
Dir.mkdir "#{Paloma.destination}/existing_controller_folder"
|
|
|
|
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'existing_controller_folder' do
|
|
|
|
file 'new_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['existing_controller_folder']['new_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-03 16:39:41 +08:00
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add namespace/new_controller_folder new_action
|
2013-01-03 16:39:41 +08:00
|
|
|
feature Paloma::AddGenerator, 'creating namespaced controller folder and action file' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
2013-01-08 15:33:40 +08:00
|
|
|
arguments ['namespace/new_controller_folder', 'new_action']
|
2013-01-03 16:39:41 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'namespace' do
|
|
|
|
directory 'new_controller_folder' do
|
|
|
|
file 'new_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['namespace/new_controller_folder']['new_action']"
|
2013-01-03 16:39:41 +08:00
|
|
|
end
|
2013-01-17 00:56:17 +08:00
|
|
|
|
|
|
|
file '_local.js' do
|
|
|
|
contains 'Paloma.namespace.new_controller_folder = {'
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_callbacks.js' do
|
|
|
|
contains '//= require ./_local.js'
|
|
|
|
contains '//= require_tree .'
|
|
|
|
end
|
2013-01-03 16:39:41 +08:00
|
|
|
end
|
2013-01-10 11:38:51 +08:00
|
|
|
|
|
|
|
file '_callbacks.js' do
|
|
|
|
contains "//= require ./_local.js"
|
|
|
|
contains "//= require ./new_controller_folder/_callbacks.js"
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
|
|
|
contains "Paloma.namespace = {"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
file 'index.js' do
|
|
|
|
contains "//= require ./namespace/_callbacks.js"
|
2013-01-03 16:39:41 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2013-01-03 19:04:32 +08:00
|
|
|
|
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add existing_namespace/new_controller_folder new_action
|
2013-01-03 19:04:32 +08:00
|
|
|
feature Paloma::AddGenerator, 'creating controller folder and action file under an existing namespace' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
2013-01-10 14:32:59 +08:00
|
|
|
arguments ['existing_namespace/new_controller_folder', 'new_action']
|
2013-01-03 19:04:32 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
2013-01-17 01:10:38 +08:00
|
|
|
Dir.mkdir "#{Paloma.destination}/existing_namespace"
|
2013-01-03 19:04:32 +08:00
|
|
|
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
2013-01-10 14:32:59 +08:00
|
|
|
directory 'existing_namespace' do
|
2013-01-03 19:04:32 +08:00
|
|
|
directory 'new_controller_folder' do
|
|
|
|
file 'new_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['existing_namespace/new_controller_folder']['new_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
|
|
|
contains 'Paloma.existing_namespace.new_controller_folder = {'
|
2013-01-03 19:04:32 +08:00
|
|
|
end
|
|
|
|
end
|
2013-01-17 01:22:24 +08:00
|
|
|
|
2013-01-10 11:38:51 +08:00
|
|
|
file '_callbacks.js' do
|
2013-01-17 01:00:10 +08:00
|
|
|
contains "//= require ./new_controller_folder/_callbacks.js"
|
2013-01-10 11:38:51 +08:00
|
|
|
end
|
2013-01-08 15:33:40 +08:00
|
|
|
end
|
2013-01-03 19:04:32 +08:00
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2013-01-04 17:33:49 +08:00
|
|
|
|
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add new_controller_folder first_action second_action third_action
|
|
|
|
feature Paloma::AddGenerator, 'create controller folder and multiple action files' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
|
|
|
arguments ['new_controller_folder', 'first_action', 'second_action', 'third_action']
|
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'new_controller_folder' do
|
|
|
|
file '_local.js' do
|
|
|
|
contains 'Paloma.new_controller_folder = {'
|
|
|
|
end
|
|
|
|
|
|
|
|
file 'first_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['new_controller_folder']['first_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
file 'second_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['new_controller_folder']['second_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
file 'third_action.js' do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['new_controller_folder']['third_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
file 'index.js' do
|
|
|
|
contains '//= require ./new_controller_folder/_callbacks.js'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-04 17:33:49 +08:00
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
# rails g paloma:add existing_controller_folder first_action second_action third_action
|
2013-01-04 17:33:49 +08:00
|
|
|
feature Paloma::AddGenerator, 'create multiple actions in an existing controller folder' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
2013-01-08 15:33:40 +08:00
|
|
|
arguments ['existing_controller_folder', 'first_action', 'second_action', 'third_action']
|
2013-01-04 17:33:49 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
Dir.mkdir "#{Paloma.destination}/existing_controller_folder"
|
|
|
|
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'existing_controller_folder' do
|
2013-01-10 14:32:59 +08:00
|
|
|
['first', 'second', 'third'].each do |action|
|
|
|
|
file ("#{action}_action.js") do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['existing_controller_folder']['#{action}_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
2013-01-04 17:33:49 +08:00
|
|
|
end
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# rails g paloma:add namespace/new_controller_folder first_action second_action third_action
|
|
|
|
feature Paloma::AddGenerator, 'create multiple actions in a new namespaced controller' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
|
|
|
arguments ['namespace/new_controller_folder', 'first_action', 'second_action', 'third_action']
|
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'namespace' do
|
|
|
|
directory 'new_controller_folder' do
|
|
|
|
file '_local.js' do
|
|
|
|
contains 'Paloma.namespace.new_controller_folder'
|
|
|
|
end
|
|
|
|
|
|
|
|
['first', 'second', 'third'].each do |action|
|
|
|
|
file ("#{action}_action.js") do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['namespace/new_controller_folder']['#{action}_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
end
|
2013-01-04 17:33:49 +08:00
|
|
|
end
|
2013-01-10 14:32:59 +08:00
|
|
|
file '_callbacks.js' do
|
|
|
|
contains '//= require ./new_controller_folder/_callbacks.js'
|
|
|
|
end
|
2013-01-04 17:33:49 +08:00
|
|
|
|
2013-01-10 14:32:59 +08:00
|
|
|
file '_local.js' do
|
|
|
|
contains 'Paloma.namespace'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
file 'index.js' do
|
|
|
|
contains '//= require ./namespace/_callbacks.js'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-01-17 00:56:17 +08:00
|
|
|
# rails g paloma:add existing_namespace/new_controller_folder first_action second_action third_action
|
2013-01-10 14:32:59 +08:00
|
|
|
feature Paloma::AddGenerator, 'create multiple actions in an existing namespaced controller' do
|
|
|
|
include GeneratorSpec::TestCase
|
|
|
|
destination TEMP
|
|
|
|
arguments ['existing_namespace/new_controller_folder', 'first_action', 'second_action', 'third_action']
|
|
|
|
|
|
|
|
before do
|
|
|
|
prepare_destination
|
|
|
|
mimic_setup
|
|
|
|
Dir.mkdir "#{Paloma.destination}/existing_namespace"
|
|
|
|
File.open("#{Paloma.destination}/existing_namespace/_callbacks.js", 'w'){ |f|
|
|
|
|
f.write('//= require ./_local.js') }
|
|
|
|
|
|
|
|
run_generator
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
destination_root.should have_structure {
|
|
|
|
directory Paloma.destination do
|
|
|
|
directory 'existing_namespace' do
|
|
|
|
directory 'new_controller_folder' do
|
|
|
|
['first', 'second', 'third'].each do |action|
|
|
|
|
file ("#{action}_action.js") do
|
2013-02-09 17:18:06 +08:00
|
|
|
contains "Paloma.callbacks['existing_namespace/new_controller_folder']['#{action}_action']"
|
2013-01-10 14:32:59 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
file '_local.js' do
|
|
|
|
contains 'Paloma.existing_namespace.new_controller_folder'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
file '_callbacks.js' do
|
|
|
|
contains '//= require ./new_controller_folder/_callbacks.js'
|
2013-01-04 17:33:49 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|