Sha256: b812167eb21fe3d75cc52c0e5c47298713dd24f76a2ec7a411a76a12671d074f

Contents?: true

Size: 1.75 KB

Versions: 7

Compression:

Stored size: 1.75 KB

Contents

require "spec_helper"

RSpec.describe Ribose::Wiki do
  describe ".all" do
    it "retrieves the list of wiki pages" do
      space_id = 123_456

      stub_ribose_wiki_list_api(space_id)
      wikis = Ribose::Wiki.all(space_id)

      expect(wikis.count).to eq(2)
      expect(wikis.first.name).to eq("Wiki Page One")
      expect(wikis.last.name).to eq("Wiki Page Two")
    end
  end

  describe ".fetch" do
    it "retrieves the details for a wiki page" do
      wiki_id = 456_789
      space_id = 123_456

      stub_ribose_wiki_fetch_api(space_id, wiki_id)
      wiki = Ribose::Wiki.fetch(space_id, wiki_id)

      expect(wiki.name).to eq("Wiki Page One")
      expect(wiki.history.current_ver).to eq(1)
      expect(wiki.updater.name).to eq("John Doe")
    end
  end

  describe ".create" do
    it "creates a new wiki page in space" do
      space_id = 123_456
      attributes = { name: "Wiki Page One" }

      stub_ribose_wiki_create_api(space_id, attributes)
      wiki = Ribose::Wiki.create(space_id, attributes)

      expect(wiki.id).not_to be_nil
      expect(wiki.name).to eq(attributes[:name])
    end
  end

  describe ".update" do
    it "updates a wiki with provided details" do
      wiki_id = 456_789
      space_id = 123_456
      attributes = { name: "Wiki Page One" }

      stub_ribose_wiki_update_api(space_id, wiki_id, attributes)
      wiki = Ribose::Wiki.update(space_id, wiki_id, attributes)

      expect(wiki.id).not_to be_nil
      expect(wiki.name).to eq("Wiki Page One")
    end
  end

  describe ".delete" do
    it "deletes an existing space wiki page" do
      wiki_id = 456_789
      space_id = 123_456

      stub_ribose_wiki_delete_api(space_id, wiki_id)
      expect { Ribose::Wiki.delete(space_id, wiki_id) }.not_to raise_error
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ribose-0.5.0 spec/ribose/wiki_spec.rb
ribose-0.4.1 spec/ribose/wiki_spec.rb
ribose-0.4.0 spec/ribose/wiki_spec.rb
ribose-0.3.2 spec/ribose/wiki_spec.rb
ribose-0.3.1 spec/ribose/wiki_spec.rb
ribose-0.3.0 spec/ribose/wiki_spec.rb
ribose-0.2.0 spec/ribose/wiki_spec.rb