Sha256: edf6e09787210dd978bcc7a87b8fa66dd92a8045a2d5127ae57a61db6318f153

Contents?: true

Size: 1.9 KB

Versions: 39

Compression:

Stored size: 1.9 KB

Contents

require 'rails_helper'

RSpec.describe Bobot::Page do
  before do
    Bobot.configure do |config|
      config.pages << Bobot::Page.new(
        slug: 'slug_1',
        language: 'language',
        page_access_token: 'page_access_token',
        page_id: '123',
        get_started_payload: 'get_started_payload',
      )
      config.pages << Bobot::Page.new(
        slug: 'slug_2',
        language: 'language',
        page_access_token: 'page_access_token',
        page_id: '456',
        get_started_payload: 'get_started_payload',
      )
    end
  end

  describe '#find' do
    it 'find page in the config' do
      expect(Bobot::Page.find("123").page_id).to eq("123")
      expect(Bobot::Page.find(123).page_id).to eq("123")
      expect(Bobot::Page.find("456").page_id).to eq("456")
      expect(Bobot::Page.find(456).page_id).to eq("456")
    end
    it 'not find page in the config' do
      expect(Bobot::Page.find("1664")).to eq(nil)
      expect(Bobot::Page.find(1664)).to eq(nil)
    end
  end
  
  describe '#find_by_slug' do
    it 'find page in the config' do
      expect(Bobot::Page.find_by_slug("slug_1").slug).to eq("slug_1")
      expect(Bobot::Page.find_by_slug("slug_2").slug).to eq("slug_2")
    end
    it 'not find page in the config' do
      expect(Bobot::Page.find_by_slug("slug_unknown")).to eq(nil)
    end
  end
  
  describe '#[]' do
    it 'find page in the config' do
      expect(Bobot::Page["123"].page_id).to eq("123")
      expect(Bobot::Page[123].page_id).to eq("123")
      expect(Bobot::Page["456"].page_id).to eq("456")
      expect(Bobot::Page[456].page_id).to eq("456")
      expect(Bobot::Page["slug_1"].slug).to eq("slug_1")
      expect(Bobot::Page["slug_2"].slug).to eq("slug_2")
    end
    it 'not find page in the config' do
      expect(Bobot::Page["1664"]).to eq(nil)
      expect(Bobot::Page[1664]).to eq(nil)
      expect(Bobot::Page["slug_unknown"]).to eq(nil)
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
bobot-5.0.4 spec/bobot/page_spec.rb
bobot-5.0.3 spec/bobot/page_spec.rb
bobot-5.0.2 spec/bobot/page_spec.rb
bobot-5.0.1 spec/bobot/page_spec.rb
bobot-5.0.0 spec/bobot/page_spec.rb
bobot-4.15.0 spec/bobot/page_spec.rb
bobot-4.14.0 spec/bobot/page_spec.rb
bobot-4.13.1 spec/bobot/page_spec.rb
bobot-4.13.0 spec/bobot/page_spec.rb
bobot-4.11.0 spec/bobot/page_spec.rb
bobot-4.10.0 spec/bobot/page_spec.rb
bobot-4.9.0 spec/bobot/page_spec.rb
bobot-4.8.0 spec/bobot/page_spec.rb
bobot-4.7.0 spec/bobot/page_spec.rb
bobot-4.6.0 spec/bobot/page_spec.rb
bobot-4.5.0 spec/bobot/page_spec.rb
bobot-4.4.1 spec/bobot/page_spec.rb
bobot-4.4.0 spec/bobot/page_spec.rb
bobot-4.3.1 spec/bobot/page_spec.rb
bobot-4.3.0 spec/bobot/page_spec.rb