Sha256: ee8cc3ebcd02a3a546f093458a442bafb6e91dc3f4e8a71e0a9b20ee601f87c7

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

describe "ProMotion::TestWebScreen functionality" do
  extend WebStub::SpecHelpers

  before  { disable_network_access! }
  after   { enable_network_access! }

  tests PM::TestWebScreen

  # Override controller to properly instantiate
  def controller
    rotate_device to: :portrait, button: :bottom
    @webscreen ||= TestWebScreen.new(nav_bar: true)
    @webscreen.navigationController
  end

  after do
    @webscreen = nil
  end

  it "should have the proper html content" do
    file_name = "WebScreen.html"

    @webscreen.set_content(file_name)

    @loaded_file = File.read(File.join(NSBundle.mainBundle.resourcePath, file_name))
    wait_for_change @webscreen, 'is_load_finished' do
      @webscreen.html.delete("\n").should == @loaded_file.delete("\n")
    end
  end

  it "should allow you to navigate to a website" do
    stub_request(:get, "https://www.google.com/").
      to_return(body: %q{Google! <form action="/search">%}, content_type: "text/html")

    @webscreen.open_url(NSURL.URLWithString("https://www.google.com/"))
    wait_for_change @webscreen, 'is_load_finished' do
      @webscreen.html.include?('<form action="/search"').should == true
    end
  end

  it "should manipulate the webscreen contents with javascript" do
    @webscreen.set_content('<h1 id="cool">Something Cool</h1>')

    wait_for_change @webscreen, 'is_load_finished' do
      @webscreen.evaluate('document.getElementById("cool").innerHTML = "Changed"')
      @webscreen.html.should =~ /<h1 id="cool">Changed<\/h1>/
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ProMotion-1.2.1 spec/functional/func_web_screen_spec.rb
ProMotion-1.2.0 spec/functional/func_web_screen_spec.rb