Skip to content

Commit

Permalink
Fix PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
c-lliope committed Dec 15, 2015
1 parent 667b69a commit 228af91
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/generators/administrate/assets/assets_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Administrate
module Generators
class AssetsGenerator < Administrate::ViewGenerator
def copy_templates
def copy_assets
Rails::Generators.invoke("administrate:assets:images")
Rails::Generators.invoke("administrate:assets:javascripts")
Rails::Generators.invoke("administrate:assets:stylesheets")
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/administrate/assets/images_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ImagesGenerator < Rails::Generators::Base

source_root File.expand_path("../../../../../", __FILE__)

def copy_partials
def copy_images
directory IMAGES_PATH, IMAGES_PATH
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class JavascriptsGenerator < Rails::Generators::Base

source_root File.expand_path("../../../../../", __FILE__)

def copy_partials
def copy_javascripts
directory JAVASCRIPTS_PATH, JAVASCRIPTS_PATH
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StylesheetsGenerator < Rails::Generators::Base

source_root File.expand_path("../../../../../", __FILE__)

def copy_partials
def copy_stylesheets
directory STYLESHEETS_PATH, STYLESHEETS_PATH
end
end
Expand Down
12 changes: 5 additions & 7 deletions spec/generators/assets/images_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
describe Administrate::Generators::Assets::ImagesGenerator, :generator do
describe "administrate:assets:images" do
it "copies the images directory into the `administrate` namespace" do
files = Dir.glob("app/assets/images/administrate/**/*")
images_directory = "app/assets/images/administrate/**/*"

run_generator []

files.each do |copied_file_path|
if File.file?(copied_file_path)
expected_contents = File.read(copied_file_path)
contents = File.read(file(copied_file_path))
each_file_in(images_directory) do |copied_file_path|
expected_contents = File.read(copied_file_path)
contents = File.read(file(copied_file_path))

expect(contents).to eq(expected_contents)
end
expect(contents).to eq(expected_contents)
end
end
end
Expand Down
12 changes: 5 additions & 7 deletions spec/generators/assets/javascripts_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
describe Administrate::Generators::Assets::JavascriptsGenerator, :generator do
describe "administrate:assets:javascripts" do
it "copies the javascripts directory into the `administrate` namespace" do
files = Dir.glob("app/assets/javascripts/administrate/**/*")
javascripts_directory = "app/assets/javascripts/administrate/**/*"

run_generator []

files.each do |copied_file_path|
if File.file?(copied_file_path)
expected_contents = File.read(copied_file_path)
contents = File.read(file(copied_file_path))
each_file_in(javascripts_directory) do |copied_file_path|
expected_contents = File.read(copied_file_path)
contents = File.read(file(copied_file_path))

expect(contents).to eq(expected_contents)
end
expect(contents).to eq(expected_contents)
end
end
end
Expand Down
12 changes: 5 additions & 7 deletions spec/generators/assets/stylesheets_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
describe Administrate::Generators::Assets::StylesheetsGenerator, :generator do
describe "administrate:assets:stylesheets" do
it "copies the stylesheets directory into the `administrate` namespace" do
files = Dir.glob("app/assets/stylesheets/administrate/**/*")
stylesheets_directory = "app/assets/stylesheets/administrate/**/*"

run_generator []

files.each do |copied_file_path|
if File.file?(copied_file_path)
expected_contents = File.read(copied_file_path)
contents = File.read(file(copied_file_path))
each_file_in(stylesheets_directory) do |copied_file_path|
expected_contents = File.read(copied_file_path)
contents = File.read(file(copied_file_path))

expect(contents).to eq(expected_contents)
end
expect(contents).to eq(expected_contents)
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions spec/generators/assets_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
end
end
end

def invoke_generator(*args)
have_received(:invoke).with(*args)
end
end
14 changes: 14 additions & 0 deletions spec/support/generator_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ def contents_for_application_template(view_name)
)
end

def invoke_generator(*args)
have_received(:invoke).with(*args)
end

def each_file_in(path)
files = Dir.glob(path)

files.each do |file_path|
if File.file?(file_path)
yield file_path
end
end
end

private

def copy_to_generator_root(destination, template)
Expand Down

0 comments on commit 228af91

Please sign in to comment.