spec/env_spec.rb in grope-0.1.4 vs spec/env_spec.rb in grope-0.2.0
- old
+ new
@@ -41,10 +41,28 @@
@env.wait
@env.document.URL.should eql('http://httpstat.us/')
end
+ it "should not load invalid URL" do
+ %w|
+htp://example.com/
+example.com
+example
+|.each do |invalid_url|
+ lambda {
+ Grope::Env.new.load(invalid_url)
+ }.should raise_error
+ end
+ end
+
+ it "should load about: URL" do
+ lambda {
+ Grope::Env.new.load('about:blank')
+ }.should_not raise_error
+ end
+
it "should redirect by click" do
anchor = @env.document.links[0]
js = @env.eval('return Grope;')
js.click(anchor)
@@ -68,11 +86,11 @@
it "should wait" do
now = Time.now.to_i
@env.wait(3)
- (Time.now.to_i - now).should be_close(3, 1)
+ (Time.now.to_i - now).should be_within(1).of(3)
end
it "should wait until given block returns true" do
now = Time.now.to_i
@@ -80,10 +98,10 @@
@env.wait_until(:timeout => 1) do |env|
env.document.title == 'xxx'
end
}.should raise_error(Timeout::Error)
- (Time.now.to_i - now).should be_close(1, 1)
+ (Time.now.to_i - now).should be_within(1).of(1)
@env.document.querySelector('title').innerHTML = 'xxx'
result = @env.wait_until do |env|
env.document.title == 'xxx'