public
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
tenderlove (author)
Fri May 30 18:54:36 -0700 2008
commit  68c9c39f88088f96eed26922a141c0fbb8dc24e2
tree    57c32e7aa5d4061f3f96fa4ae64cc912ab78e5c3
parent  ae3584f2d4e47d82c063c89631bcd8b23acfd9db
johnson / test / johnson / browser_test.rb
100644 27 lines (21 sloc) 0.674 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require File.expand_path(File.join(File.dirname(__FILE__), "/../helper"))
 
module Johnson
  class BrowserTest < Johnson::TestCase
    def setup
      @runtime = Johnson::Runtime.new
      @runtime.evaluate('Johnson.require("johnson/browser");')
    end
 
    def test_set_location_returns_location
      filename = "file://#{File.expand_path(__FILE__)}"
 
      may_thread {
        @runtime.evaluate("window.location = '#{filename}'")
      }
 
      uri = URI.parse(filename)
      assert_equal(uri.to_s, @runtime.evaluate('window.location').to_s)
    end
 
    def may_thread(&block)
      block.call
      (Thread.list - [Thread.main]).each { |t| t.join }
    end
  end
end