Sha256: 5aeb21b7144e87edc0c0e19cad1a6fe143d2f5aad264f1f431e1a739f6e6bce6

Contents?: true

Size: 1.87 KB

Versions: 8

Compression:

Stored size: 1.87 KB

Contents

shared_examples_for 'refreshable' do

    let( :refreshable ) { described_class }
    let( :url ) { @url + 'refreshable' }

    describe '#refresh' do
        context 'when called without a block' do
            it 'refreshes the inputs of the form in blocking mode' do
                res = Arachni::HTTP.get( url, async: false ).response
                f   = refreshable.from_response( res ).select do |f|
                    !!f.auditable['nonce']
                end.first

                nonce = f.auditable['nonce'].dup

                updates = { 'new' => 'stuff', 'param_name' => 'other stuff' }
                f.update updates

                refreshed = f.refresh
                refreshed.auditable['nonce'].should_not == nonce
                refreshed.original['nonce'].should      == nonce

                updates['nonce'] = f.refresh.auditable['nonce']
                f.auditable.should == updates
            end
        end
        context 'when called with a block' do
            it 'refreshes the inputs of the form in async mode' do
                res = Arachni::HTTP.get( url, async: false ).response
                f   = refreshable.from_response( res ).select do |f|
                    !!f.auditable['nonce']
                end.first

                nonce = f.auditable['nonce'].dup

                updates = { 'new' => 'stuff', 'param_name' => 'other stuff' }
                f.update updates

                ran = false
                f.refresh do |form|
                    form.auditable['nonce'].should_not == nonce
                    form.original['nonce'].should      == nonce

                    updates['nonce'] = form.refresh.auditable['nonce']
                    form.auditable.should == updates

                    ran = true
                end

                Arachni::HTTP.run
                ran.should be_true
            end
        end
    end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arachni-0.4.5.2 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.5.1 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.5 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.4 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.3.2 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.3.1 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.3 spec/support/shared/element/capabilities/refreshable.rb
arachni-0.4.2 spec/shared/element/capabilities/refreshable.rb