Skip to content

Commit 3d5bd8c

Browse files
ihabadhamjustin808
authored andcommitted
ci: correct rubocop offenses
1 parent a53a2f9 commit 3d5bd8c

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

lib/generators/react_on_rails/install_generator.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ def ensure_shakapacker_installed
102102
return if shakapacker_installed?
103103

104104
GeneratorMessages.add_info("Shakapacker not detected. Installing Shakapacker...")
105-
105+
106106
result = system("rails shakapacker:install")
107107
unless result
108-
GeneratorMessages.add_error("Failed to install Shakapacker automatically. Please run 'rails shakapacker:install' manually.")
108+
GeneratorMessages.add_error("Failed to install Shakapacker automatically. " \
109+
"Please run 'rails shakapacker:install' manually.")
109110
return
110111
end
111112

spec/react_on_rails/binstubs/dev_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def setup_script_execution
2020
# Mock ARGV to simulate no arguments (default HMR mode)
2121
stub_const("ARGV", [])
2222
# Mock pack generation
23-
allow_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs").and_return(true)
23+
allow_any_instance_of(Kernel).to receive(:system)
24+
.with("bundle exec rake react_on_rails:generate_packs").and_return(true)
2425
end
2526

2627
it "includes pack generation function" do
@@ -51,7 +52,7 @@ def setup_script_execution
5152
it "with Overmind installed, uses Overmind" do
5253
setup_script_execution
5354
allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result")
54-
expect_any_instance_of(Kernel).to receive(:system).with("overmind start -f Procfile.dev").and_return(true)
55+
expect_any_instance_of(Kernel).to receive(:system).with("overmind start -f Procfile.dev")
5556

5657
load script_path
5758
end
@@ -60,7 +61,7 @@ def setup_script_execution
6061
setup_script_execution
6162
allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT)
6263
allow(IO).to receive(:popen).with("foreman -v").and_return("Some truthy result")
63-
expect_any_instance_of(Kernel).to receive(:system).with("foreman start -f Procfile.dev").and_return(true)
64+
expect_any_instance_of(Kernel).to receive(:system).with("foreman start -f Procfile.dev")
6465

6566
load script_path
6667
end

spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,23 @@
134134
context "when detecting Shakapacker installation" do
135135
let(:install_generator) { described_class.new }
136136

137-
context "shakapacker_installed?" do
137+
context "when testing shakapacker_installed?" do
138138
specify "when Shakapacker gem is installed" do
139-
mock_gem = double("gem_spec", version: double("version", segments: [7, 0, 0]))
139+
mock_version = instance_double(Gem::Version, segments: [7, 0, 0])
140+
mock_gem = instance_double(Gem::Specification, version: mock_version)
140141
allow(Gem::Specification).to receive(:find_by_name).with("shakapacker").and_return(mock_gem)
141142
expect(install_generator.send(:shakapacker_installed?)).to be true
142143
end
143144

144145
specify "when Shakapacker gem is not installed" do
145-
allow(Gem::Specification).to receive(:find_by_name).with("shakapacker").and_raise(Gem::MissingSpecError.new("gem", "spec"))
146+
allow(Gem::Specification).to receive(:find_by_name).with("shakapacker").and_raise(Gem::MissingSpecError.new(
147+
"gem", "spec"
148+
))
146149
expect(install_generator.send(:shakapacker_installed?)).to be false
147150
end
148151
end
149152

150-
context "ensure_shakapacker_installed" do
153+
context "when testing ensure_shakapacker_installed" do
151154
specify "when Shakapacker is already installed" do
152155
allow(install_generator).to receive(:shakapacker_installed?).and_return(true)
153156
expect(install_generator).not_to receive(:system)
@@ -166,7 +169,9 @@
166169
allow(install_generator).to receive(:shakapacker_installed?).and_return(false)
167170
allow(install_generator).to receive(:system).with("rails shakapacker:install").and_return(false)
168171
expect(GeneratorMessages).to receive(:add_info).with("Shakapacker not detected. Installing Shakapacker...")
169-
expect(GeneratorMessages).to receive(:add_error).with("Failed to install Shakapacker automatically. Please run 'rails shakapacker:install' manually.")
172+
expect(GeneratorMessages).to receive(:add_error)
173+
.with("Failed to install Shakapacker automatically. " \
174+
"Please run 'rails shakapacker:install' manually.")
170175
install_generator.send(:ensure_shakapacker_installed)
171176
end
172177
end

0 commit comments

Comments
 (0)