Sha256: 00084c9c3c200f24986fff930493fd11dd49016230511a6d6c296d651d6008ec

Contents?: true

Size: 1.37 KB

Versions: 31

Compression:

Stored size: 1.37 KB

Contents

require 'xcpretty/snippet'

module XCPretty

  describe Snippet do

    it "gets the snippet out of the file path" do
      path = File.expand_path('spec/fixtures/NSStringTests.m:36')
      Snippet.from_filepath(path).contents.should ==
<<-EOS
    it(@"-split: splits with delimiter string, not just a char", ^{
        [[[@"one / two / three" split:@" / "] should] equal:@[@"one", @"two", @"three"]];
    });
EOS
    end

    it 'saves the file path' do
      path = File.expand_path('spec/fixtures/NSStringTests.m:36')
      Snippet.from_filepath(path).file_path.should == path
    end

    it "doesn't crash when there's nothing to read" do
      path = File.expand_path('spec/fixtures/NSStringTests.m:64')
      Snippet.from_filepath(path).contents.should == "\nSPEC_END\n"
    end

    it "doesn't crash if file path is invalid" do
      path = 'invalid-path'
      Snippet.from_filepath(path).contents.should == ''
    end

    it "doesn't crash if a failure is on the first line" do
      path = File.expand_path('spec/fixtures/NSStringTests.m:0')
      Snippet.from_filepath(path).contents.should ==
        "//\n//  NSStringTests.m\n//  SampleProject\n"
    end

    it "doesn't crash if the file has only 1 line" do
      path = File.expand_path('spec/fixtures/oneliner.m:0')
      Snippet.from_filepath(path).contents.should ==
         "[[[@1 should] equal] @3];\n"
    end

  end
end

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
xcpretty-0.4.0 spec/xcpretty/snippet_spec.rb
xcpretty-security-patched-0.3.2 spec/xcpretty/snippet_spec.rb
xcpretty-security-patched-0.3.0 spec/xcpretty/snippet_spec.rb
xcpretty-0.3.0 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.8 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.7 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.6 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.4 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.3 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb14 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb13 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb12 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb11 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb10 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb9 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb8 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.2 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb7 spec/xcpretty/snippet_spec.rb
xcpretty-0.2.1 spec/xcpretty/snippet_spec.rb
xcpretty-bb-0.1.12.bb6 spec/xcpretty/snippet_spec.rb