Sha256: e348396272b323272acc622b68604b15aa8d53b77bd7abc84a5e48184cd2d378
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true describe Nanoc::Int::CodeSnippet do subject(:code_snippet) { described_class.new(data, 'lib/foo.rb') } describe '#load' do subject { code_snippet.load } describe 'calling #include' do let(:data) do <<~EOS module CodeSnippetSpecHelper1 def fe345b48e4 "fe345b48e4" end end include CodeSnippetSpecHelper1 EOS end it 'makes helper functions available everywhere' do expect { subject } .to change { [Nanoc::Int::Context.new({}).respond_to?(:fe345b48e4), Complex.respond_to?(:fe345b48e4)] } .from([false, false]) .to([true, true]) end end describe 'calling #use_helper' do let(:data) do <<~EOS module CodeSnippetSpecHelper2 def e0f0c30b5e "e0f0c30b5e" end end use_helper CodeSnippetSpecHelper2 EOS end it 'makes helper functions available in helpers only' do expect { subject } .to change { [Nanoc::Int::Context.new({}).respond_to?(:e0f0c30b5e), Complex.respond_to?(:e0f0c30b5e)] } .from([false, false]) .to([true, false]) end end it 'defines at top level' do @foo = 'meow' code_snippet = Nanoc::Int::CodeSnippet.new("@foo = 'woof'", 'dog.rb') code_snippet.load expect(@foo).to eq('meow') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc-4.8.12 | spec/nanoc/base/entities/code_snippet_spec.rb |
nanoc-4.8.11 | spec/nanoc/base/entities/code_snippet_spec.rb |