Sha256: d40f1ae658a5ca8ea7d105114290d33401fbb518dd782d7b2cfb5cad66c79941

Contents?: true

Size: 1.43 KB

Versions: 36

Compression:

Stored size: 1.43 KB

Contents

require_relative "./spec_helper.rb"

class NIMock
  attr_reader :identifier
  def initialize nm, order, section
    @identifier = nm
    @order = order
    @section = section
  end

  def [](arg)
    case arg
    when :order
      @order
    when :section
      @section
    else
      nil
    end
  end
end

describe "null Case" do
  before(:each) do
    @ni = NIMock.new('/content/lectures/iter4/db_design/', 7, "lectures")
    @ci = CItem.new(@ni)
  end
  it "works as expected" do
    expect(@ci.title).to eq("db_design")
    expect(@ci.section).to eq("lectures")
    expect(@ci.short_name).to eq("db_design")
    expect(@ci.subsection).to eq("/content/lectures/iter4/")
    expect(@ci.order).to eq(7)
  end
end

describe "more complicated cases" do

  CASES = [
    ['/content/intro/term_overview/', 7, "intro", "term_overview", "intro", 7, "/content/intro/"],
    ['/content/intro/001_term_overview/', nil, "intro", "term_overview", "intro", 1, "/content/intro/"],
    ['/content/lectures/iter2/02_db_design/', 7, "lectures", "db_design", "lectures", 7, "/content/lectures/iter2/"],
    ['/content/', 7, "lectures", "content", "lectures", 7, "//"],
  ]

  context "table driven cases" do
    CASES.each do |c|
      ni = NIMock.new(c[0], c[1], c[2])
      ci = CItem.new(ni)

      it { expect(ci.title).to eq c[3]}
      it { expect(ci.section).to eq c[4]}
      it { expect(ci.order).to eq c[5]}
      it { expect(ci.subsection).to eq c[6]}
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
coursegen-0.9.25 spec/citem_spec.rb
coursegen-0.9.24 spec/citem_spec.rb
coursegen-0.9.21 spec/citem_spec.rb
coursegen-0.9.20 spec/citem_spec.rb
coursegen-0.9.19 spec/citem_spec.rb
coursegen-0.9.18 spec/citem_spec.rb
coursegen-0.9.17 spec/citem_spec.rb
coursegen-0.9.16 spec/citem_spec.rb
coursegen-0.9.15 spec/citem_spec.rb
coursegen-0.9.14 spec/citem_spec.rb
coursegen-0.9.13 spec/citem_spec.rb
coursegen-0.9.12 spec/citem_spec.rb
coursegen-0.9.11 spec/citem_spec.rb
coursegen-0.9.10 spec/citem_spec.rb
coursegen-0.9.9 spec/citem_spec.rb
coursegen-0.9.8 spec/citem_spec.rb
coursegen-0.9.7 spec/citem_spec.rb
coursegen-0.9.6 spec/citem_spec.rb
coursegen-0.9.4 spec/citem_spec.rb
coursegen-0.9.3 spec/citem_spec.rb