Sha256: 453aaccde0319beb73e816239671bc55329bcf8b21997fdfb29636fa3b136300

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'

class ShortcutContext
  extend Surrounded::Context
  shortcut_triggers
  
  initialize :user, :other
  
  trigger :shorty do
    user.speak
  end
  
  role :user do
    def speak
      'it works, shorty!'
    end
  end
end

class ShortcutContextNoKeywords
  extend Surrounded::Context
  shortcut_triggers

  initialize_without_keywords :user, :other

  trigger :shorty do
    user.speak
  end

  role :user do
    def speak
      'it works, shorty!'
    end
  end
end

describe Surrounded::Context, 'shortcuts' do
  let(:user){ User.new("Jim") }
  let(:other){ User.new("Guille") }
  it 'creates shortcut class methods for triggers' do
    assert_equal 'it works, shorty!', ShortcutContext.shorty(user: user, other: other)
  end
end

describe Surrounded::Context, 'shortcuts with initialize_without_keywords' do
  let(:user){ User.new("Jim") }
  let(:other){ User.new("Guille") }
  it 'creates shortcut class methods for triggers' do
    assert_equal 'it works, shorty!', ShortcutContextNoKeywords.shorty(user, other)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
surrounded-1.1.0 test/context_shortcuts_test.rb