2019-04-11 08:02:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-09-24 23:09:30 -04:00
|
|
|
RSpec.describe QA::Scenario::Actable do
|
2017-02-20 06:45:04 -05:00
|
|
|
subject do
|
|
|
|
Class.new do
|
|
|
|
include QA::Scenario::Actable
|
|
|
|
|
|
|
|
attr_accessor :something
|
|
|
|
|
|
|
|
def do_something(arg = nil)
|
|
|
|
"some#{arg}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.act' do
|
|
|
|
it 'provides means to run steps' do
|
|
|
|
result = subject.act { do_something }
|
|
|
|
|
|
|
|
expect(result).to eq 'some'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'supports passing variables' do
|
|
|
|
result = subject.act('thing') do |variable|
|
|
|
|
do_something(variable)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(result).to eq 'something'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns value from the last method' do
|
|
|
|
result = subject.act { 'test' }
|
|
|
|
|
|
|
|
expect(result).to eq 'test'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.perform' do
|
|
|
|
it 'makes it possible to pass binding' do
|
|
|
|
variable = 'something'
|
|
|
|
|
|
|
|
result = subject.perform do |object|
|
|
|
|
object.something = variable
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(result).to eq 'something'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|