Sha256: dbb601895506925b1d4f455f91816c326974a109d39380da61de83ceedae6b37

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'cooperator'

subject Cooperator::Context

spec 'dynamic setter and getter' do
  context = Cooperator::Context.new
  context.name = 'Apple'

  assert context.name, :==, 'Apple'
end

spec '.new accepts a hash' do
  context = Cooperator::Context.new name: 'Apple'

  assert context.name, :==, 'Apple'
end

spec '#errors is an array' do
  context = Cooperator::Context.new
  
  assert context.errors, :is_a?, Array
end

spec '#success! marks the context as a success' do
  context = Cooperator::Context.new
  context.success!

  assert context, :success?
  refute context, :failure?
end

spec '#failure! marks the context as a failure' do
  context = Cooperator::Context.new
  context.failure!

  assert context, :failure?
  refute context, :success?
end

spec '#failure! accepts an error message' do
  context = Cooperator::Context.new
  context.failure! 'Failure!'

  assert context.errors, :include?, 'Failure!'
end

spec '#include? returns true for an existing attribute' do
  context = Cooperator::Context.new name: 'Apple'

  assert context, :include?, :name
end

spec '#include? returns false for a non-existing attribute' do
  context = Cooperator::Context.new

  refute context, :include?, :name
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cooperator-0.1.0 spec/context.rb