require 'cuukie/code_snippets' require 'tempfile' describe "The code_snippet method" do include Cuukie::CodeSnippets before(:all) do @source = Tempfile.new('source.rb') @source.write < e backtrace_to_snippet(e.backtrace).should == {:first_line => 1, :marked_line => 3, :raw_lines => "# one\n# two\n1 / 0\n# four\n"} ensure source.delete end end it "returns a nil snippet if the extraction fails" do backtrace_to_snippet(['abcd'])['lines'].should be_nil end end