Skip to content

Commit 4b689da

Browse files
committed
Update app file spec
1 parent a2220f7 commit 4b689da

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

spec/views/components/code_block/app_file_spec.rb

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,45 @@ def render_page(*, **)
1010
end
1111

1212
it "renders contents of file" do
13-
page = render_page(CodeBlock::AppFile.new("config/database.yml"))
14-
expect(page).to have_content(<<~YAML)
15-
default: &default
16-
adapter: sqlite3
17-
YAML
18-
expect(page).to have_content("config/database.yml")
13+
page = render_page(CodeBlock::AppFile.new("spec/fixtures/example_file_for_app_file_test.rb"))
14+
expect(page).to have_content(<<~RUBY.strip)
15+
class ExampleFileForAppFileTest
16+
def hello
17+
puts "Hello World"
18+
end
19+
end
20+
RUBY
1921
end
2022

2123
it "renders contents of file by line number" do
22-
page = render_page(CodeBlock::AppFile.new("config/database.yml", lines: 7))
23-
expect(page).to have_content(<<~YAML.strip)
24-
default: &default
25-
YAML
24+
page = render_page(CodeBlock::AppFile.new("spec/fixtures/example_file_for_app_file_test.rb", lines: 3))
25+
expect(page).to have_content(<<~RUBY.strip)
26+
puts "Hello World"
27+
RUBY
2628

27-
expect(page).not_to have_content("database: storage/production/data.sqlite3")
29+
expect(page).not_to have_content("class ExampleFileForAppFileTest")
2830
end
2931

3032
it "renders contents of file by line number range" do
31-
page = render_page(CodeBlock::AppFile.new("config/database.yml", lines: [7..8]))
32-
expect(page).to have_content(<<~YAML.strip)
33-
default: &default
34-
adapter: sqlite3
35-
YAML
33+
page = render_page(CodeBlock::AppFile.new("spec/fixtures/example_file_for_app_file_test.rb", lines: [2..4]))
34+
expect(page).to have_content(<<~RUBY.strip)
35+
puts "Hello World"
36+
RUBY
3637

37-
expect(page).not_to have_content("database: storage/production/data.sqlite3")
38+
expect(page).not_to have_content("class ExampleFileForAppFileTest")
3839
end
3940

4041
it "renders contents of file by heterogeneous line number collection" do
41-
page = render_page(CodeBlock::AppFile.new("config/database.yml", lines: [7..8, 60]))
42-
expect(page).to have_content(<<~YAML.strip)
43-
default: &default
44-
adapter: sqlite3
45-
YAML
42+
page = render_page(CodeBlock::AppFile.new("spec/fixtures/example_file_for_app_file_test.rb", lines: [1, 4..5]))
43+
expect(page).to have_content(<<~RUBY.strip)
44+
class ExampleFileForAppFileTest
45+
RUBY
46+
expect(page).to have_content(<<~RUBY.strip)
47+
end
48+
end
49+
RUBY
4650

47-
expect(page).to have_content("database: storage/production/data.sqlite3")
48-
expect(page).not_to have_content("database: storage/development/data.sqlite3")
51+
expect(page).not_to have_content("puts \"Hello World\"")
4952
end
5053

5154
it "renders basic code block when content type is atom" do

0 commit comments

Comments
 (0)