spec/polytrix/validator_spec.rb in polytrix-0.1.2 vs spec/polytrix/validator_spec.rb in polytrix-0.1.3
- old
+ new
@@ -4,22 +4,22 @@
describe 'Validator' do
describe '#initialize' do
let(:global_matcher) { Validator::UNIVERSAL_MATCHER }
it 'accepts scope options and callback' do
- validator = Validator.new 'dummy', suite: 'java', sample: 'hello world' do |challenge|
+ validator = Validator.new 'dummy', suite: 'java', scenario: 'hello world' do |_challenge|
# Validate the challenge
end
expect(validator.suite).to eq('java')
end
- it 'defaults suite and sample to the universal matcher' do
- validator = Validator.new 'dummy' do |challenge|
+ it 'defaults suite and scenario to the universal matcher' do
+ validator = Validator.new 'dummy' do |_challenge|
# Validate
end
expect(validator.suite).to eq(Validator::UNIVERSAL_MATCHER)
- expect(validator.sample).to eq(Validator::UNIVERSAL_MATCHER)
+ expect(validator.scenario).to eq(Validator::UNIVERSAL_MATCHER)
end
end
describe '#should_validate?' do
let(:challenge) do
@@ -38,25 +38,25 @@
expect(validator(/r/, /hello/).should_validate? challenge).to be false
end
end
describe '#validate' do
- let(:challenge) { Fabricate(:challenge) }
+ let(:challenge) { Fabricate(:challenge, result: Result.new) }
- xit 'calls the validation callback' do
+ it 'calls the validation callback' do
called = false
- validator = Validator.new 'dummy' do |challenge|
+ validator = Validator.new 'dummy' do |_challenge|
called = true
end
expect { validator.validate challenge }.to change { called }.from(false).to(true)
end
end
def validator(*args)
scope = {}
scope[:suite] = args[0]
- scope[:sample] = args[1] if args[1]
- Validator.new 'dummy', scope do |challenge|
+ scope[:scenario] = args[1] if args[1]
+ Validator.new 'dummy', scope do |_challenge|
# Dummy validator
end
end
end
end