Sha256: d88b59cfa50e0565450b570e6b6f1a40748d4dc7a7ce7d542b899e28c406cb9f
Contents?: true
Size: 1.71 KB
Versions: 7
Compression:
Stored size: 1.71 KB
Contents
# -*- encoding: utf-8 -*- require 'cucumber/rails/database' describe Cucumber::Rails::Database do let(:strategy) { double(before_js: nil, before_non_js: nil) } it 'forwards events to the selected strategy' do allow(Cucumber::Rails::Database::TruncationStrategy).to receive_messages(new: strategy) Cucumber::Rails::Database.javascript_strategy = :truncation expect(strategy).to receive(:before_non_js).ordered Cucumber::Rails::Database.before_non_js expect(strategy).to receive(:before_js).ordered Cucumber::Rails::Database.before_js end it 'raises an error if you use a non-understood strategy' do expect { Cucumber::Rails::Database.javascript_strategy = :invalid }.to raise_error(Cucumber::Rails::Database::InvalidStrategy) end describe 'using a custom strategy' do class ValidStrategy def before_js # Anything end def before_non_js # Likewise end end class InvalidStrategy end it 'raises an error if the strategy doens\'t support the protocol' do expect { Cucumber::Rails::Database.javascript_strategy = InvalidStrategy }.to raise_error(ArgumentError) end it 'accepts a custom strategy with a valid interface' do expect { Cucumber::Rails::Database.javascript_strategy = ValidStrategy }.not_to raise_error end it 'forwards events to a custom strategy' do allow(ValidStrategy).to receive_messages(new: strategy) Cucumber::Rails::Database.javascript_strategy = ValidStrategy expect(strategy).to receive(:before_non_js).ordered Cucumber::Rails::Database.before_non_js expect(strategy).to receive(:before_js).ordered Cucumber::Rails::Database.before_js end end end
Version data entries
7 entries across 7 versions & 1 rubygems