Skip to content

Commit

Permalink
clean up bootstrap generator tests a little
Browse files Browse the repository at this point in the history
  • Loading branch information
tchak committed Mar 17, 2013
1 parent 2f3b418 commit b0531fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
8 changes: 0 additions & 8 deletions lib/generators/ember/bootstrap_generator.rb
Expand Up @@ -42,14 +42,6 @@ def create_store_file
template "store.#{engine_extension}", "#{ember_path}/store.#{engine_extension}"
end

def create_store_file
template "store.#{engine_extension}", "#{ember_path}/store.#{engine_extension}"
end

def create_app_stubs
invoke "ember:view", ["application", "-d #{ember_path}"]
end

private
def inject_into_application_file(safe_extension)
application_file = "app/assets/javascripts/application.#{safe_extension}"
Expand Down
40 changes: 14 additions & 26 deletions test/generators/bootstrap_generator_test.rb
Expand Up @@ -39,42 +39,30 @@ def prepare_destination
assert_file "#{ember_path}/store.js.#{engine}".sub('.js.js','.js')
assert_file "#{ember_path}/router.js.#{engine}".sub('.js.js','.js')
assert_file "#{ember_path}/#{application_name.underscore}.js.#{engine}".sub('.js.js','.js')
#assert_file "#{ember_path}/application.js.#{engine}".sub('.js.js','.js'),
# /Dummy = Ember.Application.create()/
end

end


test "Assert folder layout is properly created with custom path" do
custom_path = ember_path("custom")
run_generator [ "-d", custom_path ]

assert_file "app/assets/javascripts/application.js",
/Dummy = Ember.Application.create()/
assert_new_dirs(:skip_git => false, :in_path => custom_path)
end

test "Assert application stubs" do
run_generator

assert_invoked_generators_files
end

test "Assert application stubs with custom path" do
custom_path = ember_path("custom")
run_generator [ "-d", custom_path ]
test "create bootstrap with #{engine} engine and custom path" do
custom_path = ember_path("custom")
run_generator ["--javascript-engine=#{engine}", "-d", custom_path]
assert_file "#{custom_path}/store.js.#{engine}".sub('.js.js','.js')
assert_file "#{custom_path}/router.js.#{engine}".sub('.js.js','.js')
assert_file "#{custom_path}/#{application_name.underscore}.js.#{engine}".sub('.js.js','.js')
#assert_file "#{custom_path}/application.js.#{engine}".sub('.js.js','.js'),
# /Dummy = Ember.Application.create()/
end

assert_invoked_generators_files(:in_path => custom_path)
end

private

def assert_invoked_generators_files(options = {})
path = options[:in_path] || ember_path

assert_file "#{path}/views/application_view.js"
assert_file "#{path}/templates/application.handlebars"
assert_file "#{path}/controllers/application_controller.js"
assert_file "#{path}/routes/application_route.js"
assert_file "#{path}/#{application_name}.js"
assert_file "#{path}/router.js"
assert_file "#{path}/store.js"
end

def assert_new_dirs(options = {})
Expand Down

0 comments on commit b0531fa

Please sign in to comment.