Sha256: 18217a21e7b7b937cd83c3307224f16756e826518371f739ef6338e0f1b1c285

Contents?: true

Size: 1.36 KB

Versions: 6

Compression:

Stored size: 1.36 KB

Contents

module PageMagic
  describe ClassMethods do
    subject do
      Class.new.tap do |clazz|
        clazz.extend(described_class)
        clazz.include(InstanceMethods)
      end
    end

    describe 'on_load' do
      context 'block not set' do
        it 'returns a default block' do
          expect(subject.on_load).to be(described_class::DEFAULT_ON_LOAD)
        end
      end

      context 'block set' do
        it 'returns that block' do
          expected_block = proc {}
          subject.on_load(&expected_block)
          expect(subject.on_load).to be(expected_block)
        end
      end
    end

    describe '#url' do
      it 'get/sets a value' do
        subject.url(:url)
        expect(subject.url).to eq(:url)
      end
    end

    describe '#visit' do
      include_context :webapp_fixture
      it 'passes all options to create an active session on the registered url' do
        subject.url '/page1'
        expect(PageMagic).to receive(:session).with(application: rack_app,
                                                    options: {},
                                                    browser: :rack_test,
                                                    url: subject.url).and_call_original

        session = subject.visit(application: rack_app, options: {}, browser: :rack_test)

        expect(session.title).to eq('page1')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
page_magic-1.1.0 spec/page_magic/class_methods_spec.rb
page_magic-1.0.4 spec/page_magic/class_methods_spec.rb
page_magic-1.0.3 spec/page_magic/class_methods_spec.rb
page_magic-1.0.2 spec/page_magic/class_methods_spec.rb
page_magic-1.0.1 spec/page_magic/class_methods_spec.rb
page_magic-1.0.0 spec/page_magic/class_methods_spec.rb