terminus_spec 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +26 -0
- data/.rspec +1 -0
- data/.rvmrc +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/HISTORY.md +54 -0
- data/LICENSE +20 -0
- data/README.md +13 -0
- data/Rakefile +43 -0
- data/cucumber.yml +6 -0
- data/lib/terminus_spec.rb +200 -0
- data/lib/terminus_spec/factory.rb +27 -0
- data/lib/terminus_spec/generators.rb +80 -0
- data/lib/terminus_spec/locators.rb +23 -0
- data/lib/terminus_spec/logger.rb +7 -0
- data/lib/terminus_spec/matchers.rb +41 -0
- data/lib/terminus_spec/platform_selenium.rb +18 -0
- data/lib/terminus_spec/platform_selenium/platform_object.rb +214 -0
- data/lib/terminus_spec/platform_selenium/web_objects/all.rb +98 -0
- data/lib/terminus_spec/platform_selenium/web_objects/button.rb +13 -0
- data/lib/terminus_spec/platform_selenium/web_objects/link.rb +13 -0
- data/lib/terminus_spec/platform_selenium/web_objects/text_field.rb +14 -0
- data/lib/terminus_spec/platform_watir.rb +18 -0
- data/lib/terminus_spec/platform_watir/platform_object.rb +190 -0
- data/lib/terminus_spec/platform_watir/web_objects/all.rb +88 -0
- data/lib/terminus_spec/platform_watir/web_objects/text_field.rb +13 -0
- data/lib/terminus_spec/platforms.rb +25 -0
- data/lib/terminus_spec/version.rb +3 -0
- data/lib/terminus_spec/web_objects/all.rb +172 -0
- data/lib/terminus_spec/web_objects/button.rb +32 -0
- data/lib/terminus_spec/web_objects/link.rb +40 -0
- data/lib/terminus_spec/web_objects/text_field.rb +45 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/terminus_spec/factory_spec.rb +40 -0
- data/spec/terminus_spec/generators_spec.rb +179 -0
- data/spec/terminus_spec/locators_spec.rb +30 -0
- data/spec/terminus_spec/platform_selenium_spec.rb +28 -0
- data/spec/terminus_spec/platform_watir_spec.rb +32 -0
- data/spec/terminus_spec/platforms_spec.rb +43 -0
- data/spec/terminus_spec/terminus_spec.rb +271 -0
- data/spec/terminus_spec/web_objects/all_spec.rb +87 -0
- data/spec/terminus_spec/web_objects/button_spec.rb +35 -0
- data/spec/terminus_spec/web_objects/link_spec.rb +46 -0
- data/spec/terminus_spec/web_objects/text_field_spec.rb +48 -0
- data/spec/terminus_spec/webobject_selenium_spec.rb +154 -0
- data/spec/terminus_spec/webobject_watir_spec.rb +120 -0
- data/specs/app/favicon.ico +0 -0
- data/specs/app/images/mass_extinction.jpg +0 -0
- data/specs/app/index.html +20 -0
- data/specs/app/modal_1.html +41 -0
- data/specs/app/modal_2.html +29 -0
- data/specs/app/server.rb +25 -0
- data/specs/app/style.css +18 -0
- data/specs/app/success_1.html +12 -0
- data/specs/app/success_2.html +12 -0
- data/specs/app/test_event.html +39 -0
- data/specs/app/test_form.html +114 -0
- data/specs/app/test_frame.html +15 -0
- data/specs/app/test_iframe.html +15 -0
- data/specs/app/test_static.html +92 -0
- data/specs/engine/borg.rb +27 -0
- data/specs/engine/hooks.rb +23 -0
- data/terminus_spec.gemspec +31 -0
- metadata +198 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "terminus_spec/web_objects/all"
|
3
|
+
require "terminus_spec/web_objects/text_field"
|
4
|
+
|
5
|
+
describe TerminusSpec::WebObjects::TextField do
|
6
|
+
let(:textfield) { TerminusSpec::WebObjects::TextField }
|
7
|
+
|
8
|
+
describe "when mapping how to identify a web object" do
|
9
|
+
it "it should be able to map watir locators" do
|
10
|
+
[:class, :id, :index, :name, :tag_name, :xpath].each do |type|
|
11
|
+
locator = textfield.have_watir_find_object_with type => 'value'
|
12
|
+
locator.keys.first.should == type
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "it should be able to map selenium locators" do
|
17
|
+
[:class, :css, :id, :name, :xpath, :index].each do |type|
|
18
|
+
key, value = textfield.have_selenium_find_object_with type => 'value'
|
19
|
+
key.should == type
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "it should be able to map watir selectors to selenium locators" do
|
24
|
+
key, value = textfield.have_selenium_find_object_with :tag_name => 'value'
|
25
|
+
key.should == :css
|
26
|
+
end
|
27
|
+
|
28
|
+
it "it should be able to map selenium selectors to watir locators" do
|
29
|
+
locator = textfield.have_watir_find_object_with :css => 'value'
|
30
|
+
locator.keys.first.should == :tag_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "when performing an action on a web object" do
|
35
|
+
context "and when selenium is the driver" do
|
36
|
+
|
37
|
+
it "it should be able to set the value of the object" do
|
38
|
+
text_field_object = double('selenium_text_field')
|
39
|
+
selenium_text_field = TerminusSpec::WebObjects::TextField.new(text_field_object, :platform => :selenium_webdriver)
|
40
|
+
text_field_object.should_receive(:clear)
|
41
|
+
text_field_object.should_receive(:send_keys).with('Testing')
|
42
|
+
selenium_text_field.value = 'Testing'
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'terminus_spec/web_objects/all'
|
4
|
+
require 'terminus_spec/web_objects/link'
|
5
|
+
require 'terminus_spec/platform_selenium/platform_object'
|
6
|
+
|
7
|
+
class SeleniumTestPage
|
8
|
+
include TerminusSpec
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "web objects can be used by the selenium platform" do
|
12
|
+
before(:each) do
|
13
|
+
@selenium_browser = double('selenium')
|
14
|
+
@selenium_web_object = TerminusSpec::WebObjects::WebObject.new(@selenium_browser, :platform => :selenium_webdriver)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "and that means" do
|
18
|
+
it "it should be possible to tell one object is equal to another" do
|
19
|
+
@selenium_browser.should_receive(:==).and_return(true)
|
20
|
+
@selenium_web_object.should == @selenium_web_object
|
21
|
+
end
|
22
|
+
|
23
|
+
it "it should be possible to tell when an object is visible" do
|
24
|
+
@selenium_browser.should_receive(:displayed?).and_return(true)
|
25
|
+
@selenium_web_object.visible?.should == true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "it should be possible to tell when an object is not visible" do
|
29
|
+
@selenium_browser.should_receive(:displayed?).and_return(false)
|
30
|
+
@selenium_web_object.visible?.should == false
|
31
|
+
end
|
32
|
+
|
33
|
+
it "it should be possible to tell when an object exists" do
|
34
|
+
@selenium_web_object.exists?.should == true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "it should be possible to tell when an object does not exist" do
|
38
|
+
@selenium_web_object = TerminusSpec::WebObjects::WebObject.new(nil, :platform => :selenium_webdriver)
|
39
|
+
@selenium_web_object.exists?.should == false
|
40
|
+
end
|
41
|
+
|
42
|
+
it "it should be possible to get the text contained in an object" do
|
43
|
+
@selenium_browser.should_receive(:text).and_return("testing")
|
44
|
+
@selenium_web_object.text.should == "testing"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "it should be possible to get the value of an object" do
|
48
|
+
@selenium_browser.should_receive(:attribute).with('value').and_return("testing")
|
49
|
+
@selenium_web_object.value.should == "testing"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "it should be possible to get the tag name of an object" do
|
53
|
+
@selenium_browser.should_receive(:tag_name).and_return("div")
|
54
|
+
@selenium_web_object.tag_name.should == "div"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "it should be possible to clear the contents of an object" do
|
58
|
+
@selenium_browser.should_receive(:clear)
|
59
|
+
@selenium_web_object.clear
|
60
|
+
end
|
61
|
+
|
62
|
+
it "it should be possible to send keystrokes to an object" do
|
63
|
+
@selenium_browser.should_receive(:send_keys).with([:control, 'a'])
|
64
|
+
@selenium_web_object.send_keys([:control, 'a'])
|
65
|
+
end
|
66
|
+
|
67
|
+
it "it should be possible to wait until an object is present" do
|
68
|
+
wait = double('wait')
|
69
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
70
|
+
wait.should_receive(:until)
|
71
|
+
@selenium_web_object.when_present(10)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "it should be possible to reference an object when it is present" do
|
75
|
+
wait = double('wait')
|
76
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
77
|
+
wait.should_receive(:until)
|
78
|
+
web_object = @selenium_web_object.when_present(10)
|
79
|
+
web_object.should === @selenium_web_object
|
80
|
+
end
|
81
|
+
|
82
|
+
it "it should be possible to wait until an object is visible" do
|
83
|
+
wait = double('wait')
|
84
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
85
|
+
wait.should_receive(:until)
|
86
|
+
@selenium_web_object.when_visible(10)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "it should be possible to reference an object when it is visible" do
|
90
|
+
wait = double('wait')
|
91
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
92
|
+
wait.should_receive(:until)
|
93
|
+
web_object = @selenium_web_object.when_visible(10)
|
94
|
+
web_object.should === @selenium_web_object
|
95
|
+
end
|
96
|
+
|
97
|
+
it "it should be possible to wait until an object is not visible" do
|
98
|
+
wait = double('wait')
|
99
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
100
|
+
wait.should_receive(:until)
|
101
|
+
@selenium_web_object.when_not_visible(10)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "it should be possible to reference an object when it is not visible" do
|
105
|
+
wait = double('wait')
|
106
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
107
|
+
wait.should_receive(:until)
|
108
|
+
web_object = @selenium_web_object.when_not_visible(10)
|
109
|
+
web_object.should === @selenium_web_object
|
110
|
+
end
|
111
|
+
|
112
|
+
it "it should be possible to wait until a user defined event is executed" do
|
113
|
+
wait = double('wait')
|
114
|
+
Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
115
|
+
wait.should_receive(:until)
|
116
|
+
@selenium_web_object.wait_until(10, "testing") {}
|
117
|
+
end
|
118
|
+
|
119
|
+
it "it should be possible to retrieve the value of an attribute" do
|
120
|
+
@selenium_browser.should_receive(:attribute).and_return(true)
|
121
|
+
@selenium_web_object.attribute('readonly').should be_true
|
122
|
+
end
|
123
|
+
|
124
|
+
it "it should be possible to click the object" do
|
125
|
+
@selenium_browser.should_receive(:click)
|
126
|
+
@selenium_web_object.click
|
127
|
+
end
|
128
|
+
|
129
|
+
it "it should be possible to double-click the object" do
|
130
|
+
@selenium_browser.should_receive(:double_click)
|
131
|
+
@selenium_web_object.double_click
|
132
|
+
end
|
133
|
+
|
134
|
+
it "it should be possible to right-click the object" do
|
135
|
+
@selenium_browser.should_receive(:context_click)
|
136
|
+
@selenium_web_object.right_click
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe TerminusSpec::Platforms::SeleniumWebDriver::PlatformObject do
|
143
|
+
let(:selenium_browser) { mock_browser_with_selenium }
|
144
|
+
let(:selenium_page) { SeleniumTestPage.new(selenium_browser) }
|
145
|
+
|
146
|
+
context "when it needs to build a locators hash" do
|
147
|
+
it "it should add the tag_name when identifying by href for an anchor" do
|
148
|
+
expected_identifier = {:href => 'testing', :tag_name => 'a'}
|
149
|
+
TerminusSpec::WebObjects::Link.should_receive(:have_selenium_find_object_with).with(expected_identifier)
|
150
|
+
selenium_browser.should_receive(:find_element)
|
151
|
+
selenium_page.platform.get_link_for(:href => 'testing')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "web objects can be used by the watir platform" do
|
4
|
+
before(:each) do
|
5
|
+
@watir_browser = Watir::Element.new(nil, {})
|
6
|
+
@watir_web_object = TerminusSpec::WebObjects::WebObject.new(@watir_browser, :platform => :watir_webdriver)
|
7
|
+
end
|
8
|
+
|
9
|
+
context "and that means" do
|
10
|
+
it "it should be possible to tell one object is equal to another" do
|
11
|
+
@watir_browser.should_receive(:==).and_return(true)
|
12
|
+
@watir_web_object.should == @watir_web_object
|
13
|
+
end
|
14
|
+
|
15
|
+
it "it should be possible to tell when an object is visible" do
|
16
|
+
@watir_browser.should_receive(:present?).and_return(true)
|
17
|
+
@watir_web_object.visible?.should == true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "it should be possible to tell when an object is not visible" do
|
21
|
+
@watir_browser.should_receive(:present?).and_return(false)
|
22
|
+
@watir_web_object.visible?.should == false
|
23
|
+
end
|
24
|
+
|
25
|
+
it "it should be possible to tell when an object exists" do
|
26
|
+
@watir_browser.should_receive(:exists?).and_return(true)
|
27
|
+
@watir_web_object.exists?.should == true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "it should be possible to tell when an object does not exist" do
|
31
|
+
@watir_browser.should_receive(:exists?).and_return(false)
|
32
|
+
@watir_web_object.exists?.should == false
|
33
|
+
end
|
34
|
+
|
35
|
+
it "it should be possible to get the text contained in an object" do
|
36
|
+
@watir_browser.should_receive(:text).and_return("testing")
|
37
|
+
@watir_web_object.text.should == "testing"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "it should be possible to get the value of an object" do
|
41
|
+
@watir_browser.should_receive(:value).and_return("testing")
|
42
|
+
@watir_web_object.value.should == "testing"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "it should be possible to get the tag name of an object" do
|
46
|
+
@watir_browser.should_receive(:tag_name).and_return("div")
|
47
|
+
@watir_web_object.tag_name.should == "div"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "it should be possible to clear the contents of an object" do
|
51
|
+
@watir_browser.should_receive(:clear)
|
52
|
+
@watir_web_object.clear
|
53
|
+
end
|
54
|
+
|
55
|
+
it "it should be possible to send keystrokes to an object" do
|
56
|
+
@watir_browser.should_receive(:send_keys).with([:control, 'a'])
|
57
|
+
@watir_web_object.send_keys([:control, 'a'])
|
58
|
+
end
|
59
|
+
|
60
|
+
it "it should be possible to wait until an object is present" do
|
61
|
+
@watir_browser.should_receive(:wait_until_present).with(10)
|
62
|
+
@watir_web_object.when_present(10)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "it should be possible to reference an object when it is present" do
|
66
|
+
@watir_browser.should_receive(:wait_until_present).with(10)
|
67
|
+
web_object = @watir_web_object.when_present(10)
|
68
|
+
web_object.should === @watir_web_object
|
69
|
+
end
|
70
|
+
|
71
|
+
it "it should be possible to wait until an object is visible" do
|
72
|
+
::Watir::Wait.should_receive(:until).with(10, "Object was not visible in 10 seconds")
|
73
|
+
@watir_web_object.when_visible(10)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "it should be possible to reference an object when it is visible" do
|
77
|
+
::Watir::Wait.should_receive(:until).with(10, "Object was not visible in 10 seconds")
|
78
|
+
web_object = @watir_web_object.when_visible(10)
|
79
|
+
web_object.should === @watir_web_object
|
80
|
+
end
|
81
|
+
|
82
|
+
it "it should be possible to wait until an object is not visible" do
|
83
|
+
::Watir::Wait.should_receive(:while).with(10, "Object still visible after 10 seconds")
|
84
|
+
@watir_web_object.when_not_visible(10)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "it should be possible to reference an object when it is not visible" do
|
88
|
+
::Watir::Wait.should_receive(:while).with(10, "Object still visible after 10 seconds")
|
89
|
+
web_object = @watir_web_object.when_not_visible(10)
|
90
|
+
web_object.should === @watir_web_object
|
91
|
+
end
|
92
|
+
|
93
|
+
it "it should be possible to wait until a user defined event is executed" do
|
94
|
+
::Watir::Wait.should_receive(:until).with(10, "testing")
|
95
|
+
@watir_web_object.wait_until(10, "testing") {}
|
96
|
+
end
|
97
|
+
|
98
|
+
it "it should be possible to retrieve the value of an attribute" do
|
99
|
+
@watir_browser.should_receive(:attribute_value).and_return(true)
|
100
|
+
@watir_web_object.attribute("readonly").should be_true
|
101
|
+
end
|
102
|
+
|
103
|
+
it "it should be possible to click the object" do
|
104
|
+
@watir_browser.should_receive(:click)
|
105
|
+
@watir_web_object.click
|
106
|
+
end
|
107
|
+
|
108
|
+
it "it should be possible to double-click the object" do
|
109
|
+
@watir_browser.should_receive(:double_click)
|
110
|
+
@watir_web_object.double_click
|
111
|
+
end
|
112
|
+
|
113
|
+
it "it should be possible to right-click the object" do
|
114
|
+
@watir_browser.stub(:right_click)
|
115
|
+
@watir_browser.stub(:context_click)
|
116
|
+
@watir_web_object.right_click
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Test App</title>
|
6
|
+
<link rel="stylesheet" href="style.css" />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<h1 class="title">Testing with Terminus</h1>
|
11
|
+
<h2 class="subtitle">Landing Page</h2>
|
12
|
+
|
13
|
+
<p><a href="test_static.html">Static Text Examples</a></p>
|
14
|
+
<p><a href="test_form.html">Form Examples</a></p>
|
15
|
+
<p><a href="test_frame.html">Frame Examples</a></p>
|
16
|
+
<p><a href="test_iframe.html">IFrame Examples</a></p>
|
17
|
+
<p><a href="test_event.html">Event Examples</a></p>
|
18
|
+
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Test App - Modal Testing</title>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
function delay_action(other_function) {
|
9
|
+
setTimeout(other_function, 3000);
|
10
|
+
}
|
11
|
+
|
12
|
+
function close_window() {
|
13
|
+
window.returnValue = 22
|
14
|
+
window.close()
|
15
|
+
}
|
16
|
+
|
17
|
+
function modal1() {
|
18
|
+
var retValue = window.showModalDialog(
|
19
|
+
"modal_2.html", self,
|
20
|
+
"status:no;resizable:Yes;help:no;maximize:no;minimize:no;scrollbars:no;");
|
21
|
+
}
|
22
|
+
</script>
|
23
|
+
</head>
|
24
|
+
<body>
|
25
|
+
|
26
|
+
<h1 class="title">Testing with Terminus</h1>
|
27
|
+
<h2 class="subtitle">Modal Page 1</h2>
|
28
|
+
|
29
|
+
<h3>Close buttons</h3>
|
30
|
+
|
31
|
+
<input id="close_window" type="button" onclick="close_window()" value="Close Window"/>
|
32
|
+
<input id="delayed_close" type="button" onclick="delay_action('close_window()')" value="Close Window (with delay)" />
|
33
|
+
|
34
|
+
<h3>Nested modal</h3>
|
35
|
+
|
36
|
+
<input id="launch_modal" type="button" onclick='return modal1();' value="Launch Another Modal"/>
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
</body>
|
41
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Test App - Modal Testing</title>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
function delay_action(other_function) {
|
9
|
+
setTimeout(other_function, 3000);
|
10
|
+
}
|
11
|
+
|
12
|
+
function close_window() {
|
13
|
+
self.close()
|
14
|
+
}
|
15
|
+
</script>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
|
19
|
+
<h1 class="title">Testing with Terminus</h1>
|
20
|
+
<h2 class="subtitle">Modal Page 2</h2>
|
21
|
+
|
22
|
+
<h3>Close buttons</h3>
|
23
|
+
|
24
|
+
<input id="close_window2" type="button" onclick="close_window()" value="Close Window"/>
|
25
|
+
<input id="delayed_close2" type="button" onclick="delay_action('close_window()')" value="Close Window (with delay)" />
|
26
|
+
|
27
|
+
|
28
|
+
</body>
|
29
|
+
</html>
|
data/specs/app/server.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
|
3
|
+
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
|
4
|
+
def prevent_caching(res)
|
5
|
+
res['ETag'] = nil
|
6
|
+
res['Last-Modified'] = Time.now + 100**4
|
7
|
+
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
|
8
|
+
res['Pragma'] = 'no-cache'
|
9
|
+
res['Expires'] = Time.now - 100**4
|
10
|
+
end
|
11
|
+
|
12
|
+
def do_GET(req, res)
|
13
|
+
super
|
14
|
+
prevent_caching(res)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if $0 == __FILE__ then
|
19
|
+
server = WEBrick::HTTPServer.new(:Port => 1234, :AccessLog => [])
|
20
|
+
server.mount '/', NonCachingFileHandler , './'
|
21
|
+
['INT', 'TERM'].each { |signal|
|
22
|
+
trap(signal) { server.stop }
|
23
|
+
}
|
24
|
+
server.start
|
25
|
+
end
|