|
134 | 134 | context "when detecting Shakapacker installation" do |
135 | 135 | let(:install_generator) { described_class.new } |
136 | 136 |
|
137 | | - context "shakapacker_installed?" do |
| 137 | + context "when testing shakapacker_installed?" do |
138 | 138 | 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) |
140 | 141 | allow(Gem::Specification).to receive(:find_by_name).with("shakapacker").and_return(mock_gem) |
141 | 142 | expect(install_generator.send(:shakapacker_installed?)).to be true |
142 | 143 | end |
143 | 144 |
|
144 | 145 | 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 | + )) |
146 | 149 | expect(install_generator.send(:shakapacker_installed?)).to be false |
147 | 150 | end |
148 | 151 | end |
149 | 152 |
|
150 | | - context "ensure_shakapacker_installed" do |
| 153 | + context "when testing ensure_shakapacker_installed" do |
151 | 154 | specify "when Shakapacker is already installed" do |
152 | 155 | allow(install_generator).to receive(:shakapacker_installed?).and_return(true) |
153 | 156 | expect(install_generator).not_to receive(:system) |
|
166 | 169 | allow(install_generator).to receive(:shakapacker_installed?).and_return(false) |
167 | 170 | allow(install_generator).to receive(:system).with("rails shakapacker:install").and_return(false) |
168 | 171 | 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.") |
170 | 175 | install_generator.send(:ensure_shakapacker_installed) |
171 | 176 | end |
172 | 177 | end |
|
0 commit comments