2015-03-12 09:07:49 +09:00
|
|
|
require 'hamlit'
|
2015-03-10 20:01:33 +09:00
|
|
|
require 'unindent'
|
2015-03-10 00:37:41 +09:00
|
|
|
|
2015-03-12 09:07:49 +09:00
|
|
|
module HamlitSpecHelper
|
2015-03-10 00:37:41 +09:00
|
|
|
def parse_string(str)
|
2015-03-12 09:07:49 +09:00
|
|
|
Hamlit::Parser.new.call(str)
|
2015-03-10 00:37:41 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
def render_string(str)
|
2015-03-12 09:07:49 +09:00
|
|
|
eval Hamlit::Engine.new.call(str)
|
2015-03-10 00:37:41 +09:00
|
|
|
end
|
2015-03-10 23:38:42 +09:00
|
|
|
|
|
|
|
def assert_render(haml, html)
|
|
|
|
haml = haml.unindent
|
2015-03-11 00:11:14 +09:00
|
|
|
html = html.unindent
|
2015-03-10 23:38:42 +09:00
|
|
|
|
|
|
|
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-16 08:15:10 +09:00
|
|
|
|
|
|
|
def assert_compile(before, after)
|
|
|
|
result = described_class.new.call(before)
|
|
|
|
expect(result).to eq(after)
|
|
|
|
end
|
2015-03-10 00:37:41 +09:00
|
|
|
end
|
|
|
|
|
2015-03-09 23:21:28 +09:00
|
|
|
RSpec.configure do |config|
|
2015-03-12 09:07:49 +09:00
|
|
|
config.include HamlitSpecHelper
|
2015-03-10 00:37:41 +09:00
|
|
|
|
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
|