spec/element_spec.rb in page_magic-1.0.0.alpha18 vs spec/element_spec.rb in page_magic-1.0.0.alpha19
- old
+ new
@@ -37,11 +37,14 @@
expect { page_element.browser_element }.to raise_error(PageMagic::UndefinedSelectorException)
end
describe '#respond_to?' do
subject do
- described_class.new(:name, Object.new, type: :element, browser_element: double(element_method: '')) do
+ described_class.new(:name,
+ Object.new,
+ type: :element,
+ prefetched_browser_element: double(element_method: '')) do
element :sub_element, css: '.sub-element'
end
end
it 'checks for methods on self' do
expect(subject.respond_to?(:session)).to eq(true)
@@ -57,10 +60,13 @@
end
describe '#browser_element' do
let!(:browser) { double('browser') }
+ it 'calls the on_load hook' do
+ end
+
context 'options supplied to selector' do
it 'passes them on to the cappybara finder method' do
options = { count: 1 }
xpath_selector = '//div/input'
expect(Capybara.current_session).to receive(:find).with(:xpath, xpath_selector, options)
@@ -110,11 +116,11 @@
selector: { css: "input[name='field_name']" }).browser_element
expect(element[:id]).to eq('field_id')
end
it 'should return a prefetched value' do
- element = described_class.new(:help, page, type: :link, browser_element: :prefetched_object)
+ element = described_class.new(:help, page, type: :link, prefetched_browser_element: :prefetched_object)
expect(element.browser_element).to eq(:prefetched_object)
end
it 'should raise errors for unsupported criteria' do
element = described_class.new(:my_link,
@@ -183,11 +189,11 @@
end
describe 'hooks' do
subject do
described_class.new(:my_button, page, type: :button, selector: { id: 'my_button' }) do
- before do
+ before_events do
call_in_before_hook
end
end
end
context 'method called in before hook' do
@@ -199,10 +205,10 @@
end
context 'method called in before hook' do
subject do
described_class.new(:my_button, page, type: :button, selector: { id: 'my_button' }) do
- after do
+ after_events do
call_in_after_hook
end
end
end
it 'calls methods on the page element' do