1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/spec/spec_helper.rb

39 lines
770 B
Ruby
Raw Normal View History

2015-03-10 00:37:41 +09:00
require 'hamilton'
2015-03-10 20:01:33 +09:00
require 'unindent'
2015-03-10 00:37:41 +09:00
module HamiltonSpecHelper
def parse_string(str)
Hamilton::Parser.new.call(str)
end
def render_string(str)
eval Hamilton::Engine.new.call(str)
end
2015-03-10 23:38:42 +09:00
def assert_render(haml, html)
haml = haml.unindent
html = html.unindent.gsub(/\n\Z/, '')
expect(render_string(haml)).to eq(html)
end
def assert_parse(haml, &block)
haml = haml.unindent
ast = block.call
expect(parse_string(haml)).to eq(ast)
end
2015-03-10 00:37:41 +09:00
end
2015-03-09 23:21:28 +09:00
RSpec.configure do |config|
2015-03-10 00:37:41 +09:00
config.include HamiltonSpecHelper
2015-03-09 23:21:28 +09:00
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end