Sha256: 717ed6607a67cf1d25ece43509dff291d6722e72fe29fa22f067fe5cf61e22c6

Contents?: true

Size: 918 Bytes

Versions: 2

Compression:

Stored size: 918 Bytes

Contents

require 'test_helper'

class EastTestContext
  extend Surrounded::Context
  east_oriented_triggers
  
  initialize :user, :other_user
  
  trigger :ask? do
    "asking a question..."
  end
end

describe Surrounded::Context, '.east_oriented_triggers' do
  let(:user){ User.new("Jim") }
  let(:other_user){ User.new("Guille") }
  let(:context){ EastTestContext.new(user: user, other_user: other_user) }

  it 'returns the context object from trigger methods' do
    assert_equal context, context.ask?
  end
end

describe Surrounded::Context, '.east_oriented_triggers with protect_triggers' do
  let(:user){ User.new("Jim") }
  let(:other_user){ User.new("Guille") }
  let(:context){
    ctxt = EastTestContext.new(user: user, other_user: other_user)
    ctxt.singleton_class.send(:protect_triggers)
    ctxt
  }

  it 'returns the context object from trigger methods' do
    assert_equal context, context.ask?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
surrounded-1.1.0 test/east_oriented_triggers_test.rb
surrounded-1.0.0 test/east_oriented_triggers_test.rb