Skip to content

Commit 7814e52

Browse files
add working tests for status quo
1 parent 3be279a commit 7814e52

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require 'generator_spec'
2+
require 'generators/matestack_app/matestack_app_generator'
3+
4+
describe MatestackAppGenerator, type: :generator do
5+
let(:dummy) {File.expand_path(File.join(__FILE__, '..', '..', '..', 'dummy'))}
6+
let(:dummy_copy) {File.expand_path(File.join(__FILE__, '..', '..', '..', 'dummy_copy'))}
7+
8+
before :each do
9+
FileUtils.cp_r dummy, dummy_copy
10+
end
11+
12+
after :each do
13+
FileUtils.rm_rf dummy
14+
FileUtils.cp_r dummy_copy, dummy
15+
FileUtils.rm_rf dummy_copy
16+
end
17+
18+
destination Rails.root
19+
20+
it "creates an example app" do
21+
run_generator %w(my_example_app)
22+
23+
assert_file "app/matestack/apps/my_example_app.rb", /class Apps::MyExampleApp < Matestack::Ui::App\b/
24+
end
25+
26+
it "creates an example app with --all_inclusive flag" do
27+
run_generator %w(my_example_app --all_inclusive)
28+
29+
assert_file "app/matestack/apps/my_example_app.rb", /class Apps::MyExampleApp < Matestack::Ui::App\b/
30+
assert_file "app/matestack/pages/my_example_app/example_page.rb", /class Pages::MyExampleApp::ExamplePage < Matestack::Ui::Page\b/
31+
assert_file "app/controllers/my_example_app_controller.rb", /class MyExampleAppController < ApplicationController\b/
32+
assert_file "config/routes.rb", /my_example_app\b/
33+
end
34+
35+
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require "generator_spec"
2+
require 'generators/matestack_component/matestack_component_generator'
3+
4+
describe MatestackComponentGenerator, type: :generator do
5+
let(:dummy) {File.expand_path(File.join(__FILE__, '..', '..', '..', 'dummy'))}
6+
let(:dummy_copy) {File.expand_path(File.join(__FILE__, '..', '..', '..', 'dummy_copy'))}
7+
8+
before :each do
9+
FileUtils.cp_r dummy, dummy_copy
10+
end
11+
12+
after :each do
13+
FileUtils.rm_rf dummy
14+
FileUtils.cp_r dummy_copy, dummy
15+
FileUtils.rm_rf dummy_copy
16+
end
17+
18+
destination Rails.root
19+
20+
it "creates a custom static component" do
21+
run_generator %w(example_component)
22+
23+
assert_file "app/matestack/components/example_component.rb", /class Components::ExampleComponent < Matestack::Ui::StaticComponent\b/
24+
end
25+
26+
it "creates a custom dynamic component" do
27+
run_generator %w(example_component --dynamic)
28+
29+
assert_file "app/matestack/components/example_component.rb", /class Components::ExampleComponent < Matestack::Ui::DynamicComponent\b/
30+
assert_file "app/matestack/components/example_component.js", /custom-example_component\b/
31+
end
32+
33+
end

spec/lib/generators/matestack_page_generator_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
destination Rails.root
1919

20-
it "creates a test page" do
21-
run_generator %w(my_example_page my_app)
20+
it "creates example page" do
21+
run_generator %w(my_example_page --app_name my_app)
22+
23+
assert_file "app/matestack/pages/my_app/my_example_page.rb", /class Pages::MyApp::MyExamplePage < Matestack::Ui::Page\b/
24+
assert_file "config/routes.rb", /my_example_page\b/
2225

23-
assert_file "app/matestack/pages/my_app/my_example_page.rb", /class Pages::MyApp::MyExamplePage < Matestack::Page\b/
2426
end
2527

2628
end

0 commit comments

Comments
 (0)