|
9 | 9 | let(:out) { StringIO.new } |
10 | 10 | let(:fs) { Hanami::CLI::Files.new(memory: true, out: out) } |
11 | 11 | let(:inflector) { Dry::Inflector.new } |
12 | | - `let(:app) { Hanami.app.namespace }` |
| 12 | + let(:app) { Hanami.app.namespace } |
13 | 13 | let(:dir) { inflector.underscore(app) } |
14 | 14 | let(:controller) { "users" } |
15 | 15 | let(:action) { "index" } |
@@ -1345,37 +1345,6 @@ def handle(request, response) |
1345 | 1345 | end |
1346 | 1346 | end |
1347 | 1347 | end |
1348 | | - |
1349 | | - context "when run from within a slice directory" do |
1350 | | - let(:slice) { "books" } |
1351 | | - let(:controller) { "users" } |
1352 | | - let(:action) { "index" } |
1353 | | - let(:action_name) { "#{controller}.#{action}" } |
1354 | | - |
1355 | | - it "creates the action for the current slice" do |
1356 | | - within_application_directory do |
1357 | | - prepare_slice! |
1358 | | - |
1359 | | - # That is a lot of mocks, is there a better way for this? |
1360 | | - mock_app = double("Hanami::App") |
1361 | | - allow(mock_app).to receive(:root).and_return(Pathname.new(Dir.pwd)) |
1362 | | - allow(mock_app).to receive(:slices).and_return({slice.to_sym => double("Slice")}) |
1363 | | - allow(mock_app).to receive(:namespace).and_return(app) |
1364 | | - allow(mock_app).to receive(:inflector).and_return(inflector) |
1365 | | - |
1366 | | - allow(subject).to receive(:app).and_return(mock_app) |
1367 | | - |
1368 | | - slice_path = File.join(Dir.pwd, "slices", slice) |
1369 | | - allow(Dir).to receive(:pwd).and_return(slice_path) |
1370 | | - |
1371 | | - subject.call(name: action_name) |
1372 | | - |
1373 | | - expect(fs.exist?("slices/#{slice}/actions/#{controller}/#{action}.rb")).to be(true) |
1374 | | - expect(fs.read("config/routes.rb")).to include("slice :#{slice}") |
1375 | | - expect(fs.read("slices/#{slice}/actions/#{controller}/#{action}.rb")).to include("module #{inflector.camelize(slice)}") |
1376 | | - end |
1377 | | - end |
1378 | | - end |
1379 | 1348 | end |
1380 | 1349 |
|
1381 | 1350 | private |
|
0 commit comments