Sha256: cb9c7bee3bb3008c1f9723f36019793a1b7c371617fa91120b9874d6a542b4c3

Contents?: true

Size: 1.96 KB

Versions: 20

Compression:

Stored size: 1.96 KB

Contents

#
# Copyright 2012 Mortar Data Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Portions of this code from heroku (https://github.com/heroku/heroku/) Copyright Heroku 2008 - 2012,
# used under an MIT license (https://github.com/heroku/heroku/blob/master/LICENSE).
#

require "spec_helper"
require "mortar/helpers"

module Mortar
  describe Helpers do
    include Mortar::Helpers

    context "display_object" do

      it "should display Array correctly" do
        capture_stdout do
          display_object([1,2,3])
        end.should == <<-OUT
1
2
3
OUT
      end

      it "should display { :header => [] } list correctly" do
        capture_stdout do
          display_object({:first_header => [1,2,3], :last_header => [7,8,9]})
        end.should == <<-OUT
=== first_header
1
2
3

=== last_header
7
8
9

OUT
      end

      it "should display String properly" do
        capture_stdout do
          display_object('string')
        end.should == <<-OUT
string
OUT
      end

    end
    
    context "write_to_file" do
      it "should write data to a directory that does not yet exist" do
        
        # use FakeFS file system
        include FakeFS::SpecHelpers
        
        filepath = File.join(Dir.tmpdir, "my_new_dir", "my_new_file.txt")
        data = "foo\nbar"
        write_to_file(data, filepath)
        File.exists?(filepath).should be_true
        infile = File.open(filepath, "r")
        infile.read.should == data
        infile.close()
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mortar-0.7.1 spec/mortar/helpers_spec.rb
mortar-0.7.0 spec/mortar/helpers_spec.rb
mortar-0.6.2 spec/mortar/helpers_spec.rb
mortar-0.6.1 spec/mortar/helpers_spec.rb
mortar-0.6.0 spec/mortar/helpers_spec.rb
mortar-0.5.1 spec/mortar/helpers_spec.rb
mortar-0.5.0 spec/mortar/helpers_spec.rb
mortar-0.4.4 spec/mortar/helpers_spec.rb
mortar-0.4.3 spec/mortar/helpers_spec.rb
mortar-0.4.2 spec/mortar/helpers_spec.rb
mortar-0.4.1 spec/mortar/helpers_spec.rb
mortar-0.4.0 spec/mortar/helpers_spec.rb
mortar-0.3.4 spec/mortar/helpers_spec.rb
mortar-0.3.3 spec/mortar/helpers_spec.rb
mortar-0.3.2 spec/mortar/helpers_spec.rb
mortar-0.3.1 spec/mortar/helpers_spec.rb
mortar-0.3.0 spec/mortar/helpers_spec.rb
mortar-0.2.1 spec/mortar/helpers_spec.rb
mortar-0.2.0 spec/mortar/helpers_spec.rb
mortar-0.1.0 spec/mortar/helpers_spec.rb