faml 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +27 -0
  6. data/Appraisals +26 -0
  7. data/CHANGELOG.md +47 -0
  8. data/Gemfile +8 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +115 -0
  11. data/Rakefile +28 -0
  12. data/benchmark/attribute_builder.haml +5 -0
  13. data/benchmark/rendering.rb +35 -0
  14. data/bin/faml +4 -0
  15. data/ext/attribute_builder/attribute_builder.c +261 -0
  16. data/ext/attribute_builder/extconf.rb +3 -0
  17. data/faml.gemspec +38 -0
  18. data/gemfiles/rails_4.0.gemfile +9 -0
  19. data/gemfiles/rails_4.1.gemfile +9 -0
  20. data/gemfiles/rails_4.2.gemfile +9 -0
  21. data/gemfiles/rails_edge.gemfile +10 -0
  22. data/haml_spec_test.rb +22 -0
  23. data/lib/faml.rb +10 -0
  24. data/lib/faml/ast.rb +112 -0
  25. data/lib/faml/cli.rb +38 -0
  26. data/lib/faml/compiler.rb +374 -0
  27. data/lib/faml/element_parser.rb +235 -0
  28. data/lib/faml/engine.rb +34 -0
  29. data/lib/faml/filter_compilers.rb +41 -0
  30. data/lib/faml/filter_compilers/base.rb +43 -0
  31. data/lib/faml/filter_compilers/cdata.rb +15 -0
  32. data/lib/faml/filter_compilers/coffee.rb +16 -0
  33. data/lib/faml/filter_compilers/css.rb +16 -0
  34. data/lib/faml/filter_compilers/escaped.rb +23 -0
  35. data/lib/faml/filter_compilers/javascript.rb +16 -0
  36. data/lib/faml/filter_compilers/markdown.rb +18 -0
  37. data/lib/faml/filter_compilers/plain.rb +15 -0
  38. data/lib/faml/filter_compilers/preserve.rb +26 -0
  39. data/lib/faml/filter_compilers/ruby.rb +17 -0
  40. data/lib/faml/filter_compilers/sass.rb +15 -0
  41. data/lib/faml/filter_compilers/scss.rb +16 -0
  42. data/lib/faml/filter_compilers/tilt_base.rb +34 -0
  43. data/lib/faml/filter_parser.rb +54 -0
  44. data/lib/faml/html.rb +58 -0
  45. data/lib/faml/indent_tracker.rb +84 -0
  46. data/lib/faml/line_parser.rb +66 -0
  47. data/lib/faml/newline.rb +30 -0
  48. data/lib/faml/parser.rb +211 -0
  49. data/lib/faml/parser_utils.rb +17 -0
  50. data/lib/faml/rails_handler.rb +10 -0
  51. data/lib/faml/railtie.rb +9 -0
  52. data/lib/faml/ruby_multiline.rb +23 -0
  53. data/lib/faml/script_parser.rb +84 -0
  54. data/lib/faml/static_hash_parser.rb +113 -0
  55. data/lib/faml/syntax_error.rb +10 -0
  56. data/lib/faml/text_compiler.rb +69 -0
  57. data/lib/faml/tilt.rb +17 -0
  58. data/lib/faml/version.rb +3 -0
  59. data/spec/compiler_newline_spec.rb +162 -0
  60. data/spec/rails/Rakefile +6 -0
  61. data/spec/rails/app/assets/images/.keep +0 -0
  62. data/spec/rails/app/assets/javascripts/application.js +13 -0
  63. data/spec/rails/app/assets/stylesheets/application.css +15 -0
  64. data/spec/rails/app/controllers/application_controller.rb +5 -0
  65. data/spec/rails/app/controllers/books_controller.rb +8 -0
  66. data/spec/rails/app/controllers/concerns/.keep +0 -0
  67. data/spec/rails/app/helpers/application_helper.rb +2 -0
  68. data/spec/rails/app/mailers/.keep +0 -0
  69. data/spec/rails/app/models/.keep +0 -0
  70. data/spec/rails/app/models/book.rb +9 -0
  71. data/spec/rails/app/models/concerns/.keep +0 -0
  72. data/spec/rails/app/views/books/hello.html.haml +2 -0
  73. data/spec/rails/app/views/books/with_capture.html.haml +4 -0
  74. data/spec/rails/app/views/books/with_variables.html.haml +4 -0
  75. data/spec/rails/app/views/layouts/application.html.haml +9 -0
  76. data/spec/rails/bin/bundle +3 -0
  77. data/spec/rails/bin/rails +4 -0
  78. data/spec/rails/bin/rake +4 -0
  79. data/spec/rails/bin/setup +29 -0
  80. data/spec/rails/config.ru +4 -0
  81. data/spec/rails/config/application.rb +12 -0
  82. data/spec/rails/config/boot.rb +3 -0
  83. data/spec/rails/config/database.yml +25 -0
  84. data/spec/rails/config/environment.rb +5 -0
  85. data/spec/rails/config/environments/development.rb +41 -0
  86. data/spec/rails/config/environments/production.rb +79 -0
  87. data/spec/rails/config/environments/test.rb +42 -0
  88. data/spec/rails/config/initializers/assets.rb +11 -0
  89. data/spec/rails/config/initializers/backtrace_silencers.rb +7 -0
  90. data/spec/rails/config/initializers/cookies_serializer.rb +3 -0
  91. data/spec/rails/config/initializers/filter_parameter_logging.rb +4 -0
  92. data/spec/rails/config/initializers/inflections.rb +16 -0
  93. data/spec/rails/config/initializers/mime_types.rb +4 -0
  94. data/spec/rails/config/initializers/secret_key_base.rb +6 -0
  95. data/spec/rails/config/initializers/session_store.rb +3 -0
  96. data/spec/rails/config/initializers/wrap_parameters.rb +14 -0
  97. data/spec/rails/config/locales/en.yml +23 -0
  98. data/spec/rails/config/routes.rb +7 -0
  99. data/spec/rails/config/secrets.yml +22 -0
  100. data/spec/rails/db/seeds.rb +7 -0
  101. data/spec/rails/lib/assets/.keep +0 -0
  102. data/spec/rails/lib/tasks/.keep +0 -0
  103. data/spec/rails/log/.keep +0 -0
  104. data/spec/rails/public/404.html +67 -0
  105. data/spec/rails/public/422.html +67 -0
  106. data/spec/rails/public/500.html +66 -0
  107. data/spec/rails/public/favicon.ico +0 -0
  108. data/spec/rails/public/robots.txt +5 -0
  109. data/spec/rails/spec/requests/faml_spec.rb +41 -0
  110. data/spec/rails/vendor/assets/javascripts/.keep +0 -0
  111. data/spec/rails/vendor/assets/stylesheets/.keep +0 -0
  112. data/spec/rails_helper.rb +4 -0
  113. data/spec/render/attribute_spec.rb +241 -0
  114. data/spec/render/comment_spec.rb +61 -0
  115. data/spec/render/doctype_spec.rb +57 -0
  116. data/spec/render/element_spec.rb +136 -0
  117. data/spec/render/filters/cdata_spec.rb +12 -0
  118. data/spec/render/filters/coffee_spec.rb +25 -0
  119. data/spec/render/filters/css_spec.rb +45 -0
  120. data/spec/render/filters/escaped_spec.rb +14 -0
  121. data/spec/render/filters/javascript_spec.rb +44 -0
  122. data/spec/render/filters/markdown_spec.rb +19 -0
  123. data/spec/render/filters/plain_spec.rb +24 -0
  124. data/spec/render/filters/preserve_spec.rb +24 -0
  125. data/spec/render/filters/ruby_spec.rb +13 -0
  126. data/spec/render/filters/sass_spec.rb +28 -0
  127. data/spec/render/filters/scss_spec.rb +32 -0
  128. data/spec/render/filters_spec.rb +11 -0
  129. data/spec/render/haml_comment_spec.rb +24 -0
  130. data/spec/render/multiline_spec.rb +39 -0
  131. data/spec/render/newline_spec.rb +83 -0
  132. data/spec/render/plain_spec.rb +20 -0
  133. data/spec/render/preserve_spec.rb +8 -0
  134. data/spec/render/sanitize_spec.rb +36 -0
  135. data/spec/render/script_spec.rb +81 -0
  136. data/spec/render/silent_script_spec.rb +97 -0
  137. data/spec/render/unescape_spec.rb +45 -0
  138. data/spec/spec_helper.rb +47 -0
  139. data/spec/tilt_spec.rb +33 -0
  140. metadata +489 -0
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Multiline rendering', type: :render do
4
+ it 'handles multiline syntax' do
5
+ expect(render_string(<<HAML)).to eq("<p>\nfoo bar baz\nquux\n</p>\n")
6
+ %p
7
+ = "foo " + |
8
+ "bar " + |
9
+ "baz" |
10
+ = "quux"
11
+ HAML
12
+ end
13
+
14
+ it 'handles multiline with non-script line' do
15
+ expect(render_string(<<HAML)).to eq("<p>\nfoo \nbar\n</p>\n")
16
+ %p
17
+ foo |
18
+ bar
19
+ HAML
20
+ end
21
+
22
+ it 'handles multiline at the end of template' do
23
+ expect(render_string(<<HAML)).to eq("<p>\nfoo bar baz \n</p>\n")
24
+ %p
25
+ foo |
26
+ bar |
27
+ baz |
28
+ HAML
29
+ end
30
+
31
+ it 'is not multiline' do
32
+ expect(render_string(<<HAML)).to eq("<div>\nhello\n|\nworld\n</div>\n")
33
+ %div
34
+ hello
35
+ |
36
+ world
37
+ HAML
38
+ end
39
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Newline with > and <', type: :render do
4
+ describe '>' do
5
+ it 'parses nuke-outer-whitespace (>)' do
6
+ expect(render_string(<<HAML)).to eq("<img><span>hello</span><img>\n")
7
+ %img
8
+ %span> hello
9
+ %img
10
+ HAML
11
+
12
+ expect(render_string(<<HAML)).to eq("<div>\n<span>1</span><span>hoge</span></div>\n")
13
+ %div
14
+ %span= 1
15
+ %span> hoge
16
+ HAML
17
+ end
18
+
19
+ it 'handles silent script' do
20
+ expect(render_string(<<HAML)).to eq("<div><span>0</span><span>1</span></div>\n")
21
+ %div
22
+ - 2.times do |i|
23
+ %span>= i
24
+ HAML
25
+ end
26
+
27
+ it 'handles comment' do
28
+ expect(render_string(<<HAML)).to eq("<div>\n<!--<span>0</span><span>1</span>-->\n</div>\n")
29
+ %div
30
+ /
31
+ - 2.times do |i|
32
+ %span>= i
33
+ HAML
34
+ end
35
+
36
+ it 'handles conditional comment' do
37
+ expect(render_string(<<HAML)).to eq("<div>\n<!--[if IE]><span>0</span><span>1</span><![endif]-->\n</div>\n")
38
+ %div
39
+ / [if IE]
40
+ - 2.times do |i|
41
+ %span>= i
42
+ HAML
43
+ end
44
+ end
45
+
46
+ describe '>' do
47
+ it 'parses nuke-inner-whitespace (<)' do
48
+ expect(render_string(<<HAML)).to eq("<blockquote><div>\nFoo!\n</div></blockquote>\n")
49
+ %blockquote<
50
+ %div
51
+ Foo!
52
+ HAML
53
+ end
54
+
55
+ it 'renders pre tag as nuke-inner-whitespace by default' do
56
+ expect(render_string(<<HAML)).to eq("<pre>hello\nworld</pre>\n")
57
+ %pre
58
+ hello
59
+ world
60
+ HAML
61
+ end
62
+
63
+ it 'handles silent script' do
64
+ expect(render_string(<<HAML)).to eq("<div>012</div>\n")
65
+ %div<
66
+ - 3.times do |i|
67
+ = i
68
+ HAML
69
+ end
70
+ end
71
+
72
+ describe '><' do
73
+ it 'parses nuke-whitespaces' do
74
+ expect(render_string(<<HAML)).to eq("<img><pre>foo\nbar</pre><img>\n")
75
+ %img
76
+ %pre><
77
+ foo
78
+ bar
79
+ %img
80
+ HAML
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Plain rendering', type: :render do
4
+ it 'outputs literally when prefixed with "\\"' do
5
+ expect(render_string('\= @title')).to eq("= @title\n")
6
+ end
7
+
8
+ it 'correctly escapes interpolation' do
9
+ expect(render_string(<<'HAML')).to eq("<span>foo\\3bar</span>\n")
10
+ %span foo\\#{1 + 2}bar
11
+ HAML
12
+ expect(render_string(<<'HAML')).to eq("<span>foo\\\#{1 + 2}bar</span>\n")
13
+ %span foo\\\#{1 + 2}bar
14
+ HAML
15
+ end
16
+
17
+ it 'raises error when interpolation is unterminated' do
18
+ expect { render_string('%span foo#{1 + 2') }.to raise_error(Faml::TextCompiler::InvalidInterpolation)
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Preserve rendering', type: :render do
4
+ it 'parses preserved script' do
5
+ expect(render_string('~ "<p>hello\nworld</p>"')).to eq("&lt;p&gt;hello\nworld&lt;/p&gt;\n")
6
+ expect(render_string('%span~ "<p>hello\nworld</p>"')).to eq("<span>&lt;p&gt;hello\nworld&lt;/p&gt;</span>\n")
7
+ end
8
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Sanitize rendering', type: :render do
4
+ it 'parses sanitized script' do
5
+ # Default in faml
6
+ expect(render_string('&= "hello<p>unescape</p>world"')).to eq("hello&lt;p&gt;unescape&lt;/p&gt;world\n")
7
+ expect(render_string(<<HAML)).to eq("<span>\nhello&lt;p&gt;unescape&lt;/p&gt;world\n</span>\n")
8
+ %span
9
+ &= "hello<p>unescape</p>world"
10
+ HAML
11
+ end
12
+
13
+ it 'ignores single sanitize mark' do
14
+ expect(render_string('& <p>hello</p>')).to eq("<p>hello</p>\n")
15
+ expect(render_string('%span& <p>hello</p>')).to eq("<span><p>hello</p></span>\n")
16
+ end
17
+
18
+ it 'parses == syntax' do
19
+ expect(render_string('&== =<p>hello</p>')).to eq("=<p>hello</p>\n")
20
+ expect(render_string('%span&== =<p>hello</p>')).to eq("<span>=<p>hello</p></span>\n")
21
+ end
22
+
23
+ context 'with preserve' do
24
+ it 'ignores preserve mark' do
25
+ expect(render_string('&~ "<p>hello</p>"')).to eq("&lt;p&gt;hello&lt;/p&gt;\n")
26
+ expect(render_string('%span&~ "<p>hello</p>"')).to eq("<span>&lt;p&gt;hello&lt;/p&gt;</span>\n")
27
+ end
28
+ end
29
+
30
+ context 'without Ruby code' do
31
+ it 'raises error' do
32
+ expect { render_string('%span&=') }.to raise_error(Faml::SyntaxError)
33
+ expect { render_string('&=') }.to raise_error(Faml::SyntaxError)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Script rendering', type: :render do
4
+ it 'parses script' do
5
+ expect(render_string('%span= 1 + 2')).to eq("<span>3</span>\n")
6
+ end
7
+
8
+ it 'parses multi-line script' do
9
+ expect(render_string(<<HAML)).to eq("<span>\n3\n</span>\n")
10
+ %span
11
+ = 1 + 2
12
+ HAML
13
+ end
14
+
15
+ it 'parses script and text' do
16
+ expect(render_string(<<HAML)).to eq("<span>\n3\n3\n9\n</span>\n")
17
+ %span
18
+ = 1 + 2
19
+ 3
20
+ = 4 + 5
21
+ HAML
22
+ end
23
+
24
+ it 'can contain Ruby comment' do
25
+ expect(render_string('%span= 1 + 2 # comments')).to eq("<span>3</span>\n")
26
+ end
27
+
28
+ it 'can contain Ruby comment in multi-line' do
29
+ expect(render_string(<<HAML)).to eq("<span>\n3\n3\n9\n</span>\n")
30
+ %span
31
+ = 1 + 2 # comment
32
+ 3
33
+ = 4 + 5 # comment
34
+ HAML
35
+ end
36
+
37
+ it 'can be comment-only' do
38
+ expect(render_string(<<HAML)).to eq("\nstring\n")
39
+ = # comment
40
+ = 'string'
41
+ HAML
42
+ end
43
+
44
+ it 'can have children' do
45
+ expect(render_string(<<HAML)).to eq("<span>0</span>\n1<span>end</span>\n")
46
+ = 1.times do |i|
47
+ %span= i
48
+ %span end
49
+ HAML
50
+ end
51
+
52
+ it 'escapes unsafe string' do
53
+ expect(render_string(<<HAML)).to eq("<p>&lt;script&gt;alert(1)&lt;/script&gt;</p>\n")
54
+ - title = '<script>alert(1)</script>'
55
+ %p= title
56
+ HAML
57
+ end
58
+
59
+ it 'parses Ruby multiline' do
60
+ expect(render_string(<<HAML)).to eq("<div>\n<span>\n2+3i\n</span>\n</div>\n")
61
+ %div
62
+ %span
63
+ = Complex(2,
64
+ 3)
65
+ HAML
66
+ end
67
+
68
+ it 'parses == syntax' do
69
+ expect(render_string('== =#{1+2}hello')).to eq("=3hello\n")
70
+ end
71
+
72
+ context 'without Ruby code' do
73
+ it 'raises error' do
74
+ expect { render_string('%span=') }.to raise_error(Faml::SyntaxError)
75
+ expect { render_string(<<HAML) }.to raise_error(Faml::SyntaxError)
76
+ %span
77
+ =
78
+ HAML
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'SilentScript rendering', type: :render do
4
+ it 'parses silent script' do
5
+ expect(render_string(<<HAML)).to eq("<span>0</span>\n<span>1</span>\n")
6
+ - 2.times do |i|
7
+ %span= i
8
+ HAML
9
+ end
10
+
11
+ it 'parses if' do
12
+ expect(render_string(<<HAML)).to eq("<div>\neven\n</div>\n")
13
+ %div
14
+ - if 2.even?
15
+ even
16
+ HAML
17
+ end
18
+
19
+ it 'parses if and text' do
20
+ expect(render_string(<<HAML)).to eq("<div>\neven\nok\n</div>\n")
21
+ %div
22
+ - if 2.even?
23
+ even
24
+ ok
25
+ HAML
26
+ end
27
+
28
+ it 'parses if and else' do
29
+ expect(render_string(<<HAML)).to eq("<div>\nodd\n</div>\n")
30
+ %div
31
+ - if 1.even?
32
+ even
33
+ - else
34
+ odd
35
+ HAML
36
+ end
37
+
38
+ it 'parses if and elsif' do
39
+ expect(render_string(<<HAML)).to eq("<div>\n2\neven\n</div>\n")
40
+ %div
41
+ - if 1.even?
42
+ even
43
+ - elsif 2.even?
44
+ 2
45
+ even
46
+ - else
47
+ odd
48
+ HAML
49
+ end
50
+
51
+ it 'parses case-when' do
52
+ expect(render_string(<<HAML)).to eq("<div>\n2\neven\n</div>\n")
53
+ %div
54
+ - case
55
+ - when 1.even?
56
+ even
57
+ - when 2.even?
58
+ 2
59
+ even
60
+ - else
61
+ else
62
+ HAML
63
+ end
64
+
65
+ it 'parses Ruby comment' do
66
+ expect(render_string(<<HAML)).to eq("<span>Print me</span>\n")
67
+ - # Ruby comment here
68
+ %span Print me
69
+ HAML
70
+ end
71
+
72
+ it 'parses Ruby multiline' do
73
+ expect(render_string(<<HAML)).to eq("<div>\n<span>ne</span>\n</div>\n")
74
+ %div
75
+ - if 1 == Complex(2,
76
+ 3)
77
+ %span eq
78
+ - else
79
+ %span ne
80
+ HAML
81
+ end
82
+
83
+ it 'raises error if no Ruby code is given' do
84
+ expect { render_string('-') }.to raise_error(Faml::SyntaxError)
85
+ end
86
+
87
+ it 'checks indent levels' do
88
+ expect(render_string(<<HAML)).to eq("<span>hello</span>\n")
89
+ - if true
90
+ %span hello
91
+ - if false
92
+ %span world
93
+ - else
94
+ %span !!!
95
+ HAML
96
+ end
97
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Unescape rendering', type: :render do
4
+ it 'parses unescape script' do
5
+ expect(render_string('%span!= "hello<p>unescape</p>world"')).to eq("<span>hello<p>unescape</p>world</span>\n")
6
+ expect(render_string(<<HAML)).to eq("<span>\nhello<p>unescape</p>world\n</span>\n")
7
+ %span
8
+ != "hello<p>unescape</p>world"
9
+ HAML
10
+ end
11
+
12
+ it 'ignores single unescape mark' do
13
+ expect(render_string('! <p>hello</p>')).to eq("<p>hello</p>\n")
14
+ expect(render_string('%span! <p>hello</p>')).to eq("<span><p>hello</p></span>\n")
15
+ end
16
+
17
+ it 'ignores single Unescape mark without spaces' do
18
+ expect(render_string('!<p>hello</p>')).to eq("<p>hello</p>\n")
19
+ expect(render_string('%span!<p>hello</p>')).to eq("<span><p>hello</p></span>\n")
20
+ end
21
+
22
+ it 'has effect on string interpolation in plain' do
23
+ expect(render_string('! <p>#{"<strong>hello</strong>"}</p>')).to eq("<p><strong>hello</strong></p>\n")
24
+ expect(render_string('%span! <p>#{"<strong>hello</strong>"}</p>')).to eq("<span><p><strong>hello</strong></p></span>\n")
25
+ end
26
+
27
+ it 'parses == syntax' do
28
+ expect(render_string('!== =#{"<br>"}hello')).to eq("=<br>hello\n")
29
+ expect(render_string('%p!== =#{"<br>"}hello')).to eq("<p>=<br>hello</p>\n")
30
+ end
31
+
32
+ context 'with preserve' do
33
+ it 'keeps newlines within preserve tags' do
34
+ expect(render_string('!~ "<p>hello\n<pre>pre\nworld</pre></p>"')).to eq("<p>hello\n<pre>pre&#x000A;world</pre></p>\n")
35
+ expect(render_string('%span!~ "<p>hello\n<pre>pre\nworld</pre></p>"')).to eq("<span><p>hello\n<pre>pre&#x000A;world</pre></p></span>\n")
36
+ end
37
+ end
38
+
39
+ context 'without Ruby code' do
40
+ it 'raises error' do
41
+ expect { render_string('%span!=') }.to raise_error(Faml::SyntaxError)
42
+ expect { render_string('!=') }.to raise_error(Faml::SyntaxError)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,47 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter,
7
+ ]
8
+ SimpleCov.start do
9
+ add_filter File.dirname(__FILE__)
10
+ end
11
+
12
+ require 'faml'
13
+
14
+ module RenderSpecHelper
15
+ def render_string(str, options = {})
16
+ eval(Faml::Engine.new(options).call(str))
17
+ end
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.expect_with :rspec do |expectations|
22
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
23
+ end
24
+
25
+ config.mock_with :rspec do |mocks|
26
+ mocks.verify_partial_doubles = true
27
+ end
28
+
29
+ config.filter_run :focus
30
+ config.run_all_when_everything_filtered = true
31
+
32
+ config.disable_monkey_patching!
33
+
34
+ if config.files_to_run.one?
35
+ config.default_formatter = 'doc'
36
+ end
37
+
38
+ if ENV['TRAVIS']
39
+ config.profile_examples = 10
40
+ end
41
+
42
+ config.order = :random
43
+
44
+ Kernel.srand config.seed
45
+
46
+ config.include(RenderSpecHelper, type: :render)
47
+ end