lib/rutl/interface/null_interface.rb in rutl-0.1.3 vs lib/rutl/interface/null_interface.rb in rutl-0.1.4
- old
+ new
@@ -2,28 +2,30 @@
#
# Interface-level code for fake browser.
#
class NullInterface < BaseInterface
- @variables = []
- attr_accessor :variables
-
- def initialize(pages:)
- @driver = NullDriver.new
- @driver.interface = @interface
+ def initialize
+ context = ElementContext.new(destinations: nil,
+ interface: self,
+ selectors: [])
+ @driver = NullDriver.new(context)
super
end
- def set_current_page(page)
- @current_page = page
- end
+ # The null driver needs to talk to the null interface.
+ # Other driver/interface relations are not like this.
+ attr_writer :current_page
def current_page
# Default to @pages.first if not set?
- # A browser can alwasy check its current URL but the null driver can't.
- @current_page || @pages.first
+ # A browser can always check its current URL but the null driver can't.
+ @current_page ||= @pages.first
end
def wait_for_transition(destinations)
- @current_page = find_page(destinations.first)
+ # TODO: Setting @current page didn't do it beacause that set
+ # context.interface.current_page and we wanted this in the browser.
+ @current_page = destinations.first.new(self)
+ $browser.current_page = @current_page
end
end