2017-12-22 09:40:46 -05:00
|
|
|
describe QA::Page::Element do
|
|
|
|
context 'when pattern is an expression' do
|
|
|
|
subject { described_class.new(:something, /button 'Sign in'/) }
|
|
|
|
|
2018-01-09 04:02:55 -05:00
|
|
|
it 'matches when there is a match' do
|
2017-12-22 09:40:46 -05:00
|
|
|
expect(subject.matches?("button 'Sign in'")).to be true
|
|
|
|
end
|
|
|
|
|
2018-01-09 04:02:55 -05:00
|
|
|
it 'does not match if pattern is not present' do
|
2017-12-22 09:40:46 -05:00
|
|
|
expect(subject.matches?("button 'Sign out'")).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pattern is a string' do
|
|
|
|
subject { described_class.new(:something, 'button') }
|
|
|
|
|
2018-01-09 04:02:55 -05:00
|
|
|
it 'matches when there is match' do
|
2017-12-22 09:40:46 -05:00
|
|
|
expect(subject.matches?('some button in the view')).to be true
|
|
|
|
end
|
|
|
|
|
2018-01-09 04:02:55 -05:00
|
|
|
it 'does not match if pattern is not present' do
|
2017-12-22 09:40:46 -05:00
|
|
|
expect(subject.matches?('text_field :name')).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-09 04:02:55 -05:00
|
|
|
context 'when pattern is not provided' do
|
|
|
|
subject { described_class.new(:some_name) }
|
2017-12-22 09:40:46 -05:00
|
|
|
|
2018-01-09 04:02:55 -05:00
|
|
|
it 'matches when QA specific selector is present' do
|
|
|
|
expect(subject.matches?('some qa-some-name selector')).to be true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not match if QA selector is not there' do
|
|
|
|
expect(subject.matches?('some_name selector')).to be false
|
2017-12-22 09:40:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|