Sha256: 3562234152f80e14561dd4f3595bec0945b255eb307bb6abe46863463ce53ebc

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require 'spec_helper'

SimpleCov.command_name('DocString') unless RUBY_VERSION.to_s < '1.9.0'

describe 'DocString, Unit' do

  clazz = CucumberAnalytics::DocString

  it_should_behave_like 'a nested element', clazz
  it_should_behave_like 'a bare bones element', clazz
  it_should_behave_like 'a prepopulated element', clazz
  it_should_behave_like 'a raw element', clazz

  it 'can be parsed from stand alone text' do
    source = "\"\"\"\nsome doc string\n\"\"\""

    expect { clazz.new(source) }.to_not raise_error
  end

  before(:each) do
    @doc_string = clazz.new
  end

  it 'has a content type - #content_type' do
    @doc_string.should respond_to(:content_type)
  end

  it 'can get and set its content type - #content_type, #content_type=' do
    @doc_string.content_type = :some_content_type
    @doc_string.content_type.should == :some_content_type
    @doc_string.content_type = :some_other_content_type
    @doc_string.content_type.should == :some_other_content_type
  end

  it 'starts with no content type' do
    @doc_string.content_type.should == nil
  end

  it 'has contents - #contents' do
    @doc_string.should respond_to(:contents)
  end

  it 'can get and set its contents - #contents, #contents=' do
    @doc_string.contents = :some_contents
    @doc_string.contents.should == :some_contents
    @doc_string.contents = :some_other_contents
    @doc_string.contents.should == :some_other_contents
  end

  it 'starts with no contents' do
    @doc_string.contents.should == []
  end

  it 'stores its contents as an array of strings' do
    source = "\"\"\"\nsome text\nsome more text\n\"\"\""
    doc_string = CucumberAnalytics::DocString.new(source)

    contents = doc_string.contents

    contents.is_a?(Array).should be_true
    contents.each do |line|
      line.is_a?(String).should be_true
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber_analytics-1.2.0 spec/unit/doc_string_unit_spec.rb