Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Address some RuboCop warnings (#112)
Browse files Browse the repository at this point in the history
* RuboCop: RSpec/MultipleExpectations

* RuboCop: Style/StringLiteralsInInterpolation

* RuboCop: RSpec/ReceiveMessages
  • Loading branch information
jgarber623 authored Dec 14, 2023
1 parent 0b60bcd commit 3a960e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/svgeez/elements/symbol_element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(file_path, file_id)

def build
File.read(@file_path).match(%r{^<svg\s*?(?<attributes>.*?)>(?<content>.*?)</svg>}m) do |matches|
%(<symbol #{element_attributes(matches[:attributes]).sort.join(" ")}>#{element_contents(matches[:content])}</symbol>)
"<symbol #{element_attributes(matches[:attributes]).sort.join(' ')}>#{element_contents(matches[:content])}</symbol>"
end
end

Expand Down
20 changes: 10 additions & 10 deletions spec/lib/svgeez/builder_build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
allow(File).to receive(:directory?).and_return(false)
end

it "logs an error" do
it "logs an error", :aggregate_failures do
expect { described_class.new.build }.to raise_error(SystemExit)
expect(logger).to have_received(:error).with("Provided `source` folder does not exist.")
end
end

context "when @source and @destination are the same" do
it "logs an error" do
it "logs an error", :aggregate_failures do
builder = described_class.new(
"source" => "./foo",
"destination" => "./foo"
Expand All @@ -37,7 +37,7 @@
end
end

context "when @destination is nested within @source" do
context "when @destination is nested within @source", :aggregate_failures do
it "logs an error" do
builder = described_class.new(
"source" => "./foo",
Expand Down Expand Up @@ -70,14 +70,14 @@

allow(file).to receive(:write)

file_paths = %w[facebook github heart skull twitter].map { |i| "./spec/fixtures/icons/#{i}.svg" }

allow(source).to receive(:file_paths).and_return(file_paths)
allow(source).to receive(:folder_path).and_return(File.expand_path(source_folder_path))
allow(source).to receive_messages(
file_paths: %w[facebook github heart skull twitter].map { |i| "./spec/fixtures/icons/#{i}.svg" },
folder_path: File.expand_path(source_folder_path)
)
end

context "when @svgo is not specified" do
it "writes a file" do
it "writes a file", :aggregate_failures do
described_class.new(
"source" => source_folder_path,
"destination" => "./spec/fixtures/icons.svg"
Expand All @@ -89,14 +89,14 @@
end

context "when @svgo is specified" do
it "writes a file" do
it "writes a file", :aggregate_failures do
described_class.new(
"source" => source_folder_path,
"destination" => "./spec/fixtures/icons-svgo.svg",
"svgo" => true
).build

expect(file).to have_received(:write).with(%(#{File.read("./spec/fixtures/icons-svgo.svg")}\n))
expect(file).to have_received(:write).with("#{File.read('./spec/fixtures/icons-svgo.svg')}\n")
expect(logger).to have_received(:info).exactly(:twice)
end
end
Expand Down

0 comments on commit 3a960e1

Please sign in to comment.