File tree Expand file tree Collapse file tree 4 files changed +67
-1
lines changed
spec/lib/reveal-ck/builders Expand file tree Collapse file tree 4 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,41 @@ Feature: The capabilities of config.yml
9494 transition: 'page'
9595 """
9696
97+ Scenario : Generating slides with custom filters and requires
98+ Given a file named "config.yml" with:
99+ """
100+ filters:
101+ - 'HTML::Pipeline::ItsFilter'
102+ requires:
103+ - './its_filter'
104+ """
105+ And a file named "its_filter.rb" with:
106+ """
107+ module HTML
108+ class Pipeline
109+ class ItsFilter < TextFilter
110+ def call
111+ # Certain people prefer to say "It is" rather than "It's"
112+ @text.gsub(/It's/, 'It is')
113+ end
114+ end
115+ end
116+ end
117+ """
118+ And a file named "slides.md" with:
119+ """
120+ It's not professional.
121+ """
122+ When I run `reveal-ck generate`
123+ Then the exit status should be 0
124+ And the output should contain exactly "Generating slides for 'slides.md'..\n "
125+ And the following files should exist:
126+ | slides /index .html |
127+ And the file "slides/index.html" should contain:
128+ """
129+ <p>It is not professional.</p>
130+ """
131+
97132 Scenario : Referencing config data with a templating language
98133 Given a file named "config.yml" with:
99134 """
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ def presentation_html
3636 end
3737
3838 def apply_filters_to ( html )
39+ load_dependencies ( config . requires )
3940 filters = get_classes_from_array ( config . filters )
4041 pipeline = HTML ::Pipeline . new ( filters )
4142 filtered_html_string = FilteredHtmlString . new ( html : html ,
@@ -44,6 +45,10 @@ def apply_filters_to(html)
4445 filtered_html_string . render
4546 end
4647
48+ def load_dependencies ( array_of_includes )
49+ array_of_includes . each { |name | require name }
50+ end
51+
4752 def get_classes_from_array ( array_of_names )
4853 array_of_names . map do |name |
4954 name . split ( '::' ) . reduce ( Object ) { |a , e | a . const_get ( e ) }
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ def filter_defaults
5050 'HTML::Pipeline::MentionFilter' ,
5151 'HTML::Pipeline::AutolinkFilter' ] ,
5252 'asset_root' => 'https://assets-cdn.github.com/images/icons/' ,
53- 'base_url' => 'https://github.com'
53+ 'base_url' => 'https://github.com' ,
54+ 'requires' => [ ]
5455 }
5556 end
5657 end
Original file line number Diff line number Diff line change @@ -54,6 +54,31 @@ module Builders
5454 end
5555 end
5656 end
57+
58+ it 'requires the entries in config.filters' do
59+ Dir . mktmpdir do |dir |
60+ Dir . chdir ( dir ) do
61+ slides_file_initial = 'slides-initial.md'
62+ File . open ( slides_file_initial , 'w' ) do |file |
63+ file . puts ( '# Slides' )
64+ end
65+
66+ config = Config . new
67+ config . requires = %w( json time )
68+ application = Rake ::Application . new
69+ slides_html =
70+ CreateSlidesHtml . new ( slides_file : slides_file_initial ,
71+ output_dir : dir ,
72+ config : config ,
73+ application : application )
74+
75+ slides_html . prepare
76+ expect ( slides_html ) . to receive ( :require ) . with ( 'json' )
77+ expect ( slides_html ) . to receive ( :require ) . with ( 'time' )
78+ application [ 'create_slides_html' ] . invoke
79+ end
80+ end
81+ end
5782 end
5883 end
5984end
You can’t perform that action at this time.
0 commit comments