rails-footnotes 7.1.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-footnotes/notes/log_note/note_logger.rb +1 -0
- data/lib/rails-footnotes/version.rb +1 -1
- metadata +7 -71
- data/.github/dependabot.yml +0 -10
- data/.github/workflows/ci.yml +0 -19
- data/.github/workflows/merge-dependabot.yml +0 -33
- data/.gitignore +0 -10
- data/.rspec.example +0 -1
- data/.ruby-version +0 -1
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -256
- data/Rakefile +0 -18
- data/bin/rake +0 -29
- data/bin/rspec +0 -29
- data/gemfiles/Gemfile.rails-3.2.22 +0 -5
- data/gemfiles/Gemfile.rails-4.0.x +0 -6
- data/gemfiles/Gemfile.rails-4.1.x +0 -5
- data/gemfiles/Gemfile.rails-4.2.x +0 -5
- data/gemfiles/Gemfile.rails-edge +0 -5
- data/rails-footnotes.gemspec +0 -19
- data/renovate.json +0 -5
- data/spec/abstract_note_spec.rb +0 -89
- data/spec/app/assets/config/manifest.js +0 -2
- data/spec/app/assets/javascripts/foobar.js +0 -1
- data/spec/app/assets/stylesheets/foobar.css +0 -0
- data/spec/app/views/files/index.html.erb +0 -1
- data/spec/app/views/layouts/application.html.erb +0 -12
- data/spec/app/views/partials/_foo.html.erb +0 -1
- data/spec/app/views/partials/index.html.erb +0 -1
- data/spec/controllers/files_note_controller_spec.rb +0 -38
- data/spec/controllers/footnotes_controller_spec.rb +0 -128
- data/spec/controllers/log_note_controller_spec.rb +0 -32
- data/spec/controllers/partials_note_controller_spec.rb +0 -28
- data/spec/env_note_spec.rb +0 -73
- data/spec/fixtures/html_download.html +0 -5
- data/spec/footnotes_spec.rb +0 -267
- data/spec/notes/assigns_note_spec.rb +0 -68
- data/spec/notes/controller_note_spec.rb +0 -12
- data/spec/notes/files_note_spec.rb +0 -26
- data/spec/notes/javascripts_note_spec.rb +0 -18
- data/spec/notes/stylesheets_note_spec.rb +0 -19
- data/spec/notes/view_note_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -68
- data/spec/support/active_record.rb +0 -22
data/spec/footnotes_spec.rb
DELETED
@@ -1,267 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require 'action_controller'
|
5
|
-
require 'action_controller/test_case'
|
6
|
-
require "tempfile"
|
7
|
-
|
8
|
-
class FootnotesController < ActionController::Base
|
9
|
-
attr_accessor :template, :performed_render
|
10
|
-
end
|
11
|
-
|
12
|
-
module Footnotes::Notes
|
13
|
-
class TestNote < AbstractNote
|
14
|
-
def self.to_sym; :test; end
|
15
|
-
def valid?; true; end
|
16
|
-
end
|
17
|
-
|
18
|
-
class NoteXNote < TestNote; end
|
19
|
-
class NoteYNote < TestNote; end
|
20
|
-
class NoteZNote < TestNote; end
|
21
|
-
|
22
|
-
class FileURINote < TestNote
|
23
|
-
def link
|
24
|
-
"/example/local file path/with-special-chars/öäü/file"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "Footnotes" do
|
30
|
-
context "response_body is file" do
|
31
|
-
before do
|
32
|
-
@controller = FootnotesController.new
|
33
|
-
@controller.template = Object.new
|
34
|
-
@controller.request = ActionDispatch::TestRequest.create
|
35
|
-
@controller.response = ActionDispatch::TestResponse.new
|
36
|
-
@controller.params = {}
|
37
|
-
|
38
|
-
Footnotes::Filter.notes = [ :test ]
|
39
|
-
Footnotes::Filter.multiple_notes = false
|
40
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
41
|
-
|
42
|
-
@file = Tempfile.new("test")
|
43
|
-
def @file.body; read; end
|
44
|
-
@file.write "foobarbaz"
|
45
|
-
@file.rewind
|
46
|
-
@controller.response_body = @file
|
47
|
-
end
|
48
|
-
|
49
|
-
after do
|
50
|
-
@file.close!
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should not change file position" do
|
54
|
-
expect {
|
55
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
56
|
-
}.not_to change{ @controller.response_body.pos }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "response_body is Rack::File::Iterator" do
|
61
|
-
before do
|
62
|
-
@controller = FootnotesController.new
|
63
|
-
@controller.template = Object.new
|
64
|
-
@controller.request = ActionDispatch::TestRequest.create
|
65
|
-
@controller.response = ActionDispatch::TestResponse.new
|
66
|
-
@controller.params = {}
|
67
|
-
|
68
|
-
Footnotes::Filter.notes = [ :test ]
|
69
|
-
Footnotes::Filter.multiple_notes = false
|
70
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
71
|
-
|
72
|
-
@file = Rack::File::Iterator.new("README.md", (0..-1), {})
|
73
|
-
@controller.response_body = @file
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should work" do
|
77
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "response_body is HTML" do
|
82
|
-
before do
|
83
|
-
@controller = FootnotesController.new
|
84
|
-
@controller.template = Object.new
|
85
|
-
@controller.request = ActionDispatch::TestRequest.create
|
86
|
-
@controller.response = ActionDispatch::TestResponse.new
|
87
|
-
@controller.response_body = HTML_DOCUMENT.dup
|
88
|
-
@controller.params = {}
|
89
|
-
|
90
|
-
Footnotes::Filter.notes = [ :test ]
|
91
|
-
Footnotes::Filter.multiple_notes = false
|
92
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "footnotes_controller" do
|
96
|
-
index = @controller.response.body.index(/This is the HTML page/)
|
97
|
-
expect(index).to eql 334
|
98
|
-
end
|
99
|
-
|
100
|
-
it "foonotes_included" do
|
101
|
-
footnotes_perform!
|
102
|
-
expect(@controller.response_body).not_to eq(HTML_DOCUMENT)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should escape links with special chars" do
|
106
|
-
note_with_link = Footnotes::Notes::FileURINote.new
|
107
|
-
link = Footnotes::Filter.prefix(note_with_link.link, 1, 1, 1)
|
108
|
-
expect(link).to eql "txmt://open?url=file:///example/local%20file%20path/with-special-chars/%C3%B6%C3%A4%C3%BC/file&line=1&column=1"
|
109
|
-
end
|
110
|
-
|
111
|
-
specify "footnotes_not_included_when_request_is_xhr" do
|
112
|
-
@controller.request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
|
113
|
-
@controller.request.env['HTTP_ACCEPT'] = 'text/javascript, text/html, application/xml, text/xml, */*'
|
114
|
-
footnotes_perform!
|
115
|
-
expect(@controller.response.body).to eql HTML_DOCUMENT
|
116
|
-
end
|
117
|
-
|
118
|
-
specify "footnotes_not_included_when_content_type_is_javascript" do
|
119
|
-
@controller.response.content_type = 'text/javascript'
|
120
|
-
footnotes_perform!
|
121
|
-
expect(@controller.response.body).to eql HTML_DOCUMENT
|
122
|
-
end
|
123
|
-
|
124
|
-
specify "footnotes_included_when_content_type_is_html" do
|
125
|
-
@controller.response.content_type = 'text/html; charset=utf-8'
|
126
|
-
footnotes_perform!
|
127
|
-
expect(@controller.response.body).not_to eql HTML_DOCUMENT
|
128
|
-
end
|
129
|
-
|
130
|
-
specify "footnotes_included_when_content_type_is_nil" do
|
131
|
-
footnotes_perform!
|
132
|
-
expect(@controller.response.body).not_to eql HTML_DOCUMENT
|
133
|
-
end
|
134
|
-
|
135
|
-
specify "not_included_when_body_is_not_a_string" do
|
136
|
-
allow(@controller.response).to receive(:body).and_return(Time.now)# = Proc.new { Time.now }
|
137
|
-
expect(Footnotes::Filter.new(@controller).send(:valid?)).not_to be
|
138
|
-
expect(@controller.response.body).not_to match(/<!-- Footnotes/)
|
139
|
-
end
|
140
|
-
|
141
|
-
specify "notes_are_initialized" do
|
142
|
-
footnotes_perform!
|
143
|
-
test_note = @footnotes.instance_variable_get('@notes').first
|
144
|
-
expect(test_note.class.name).to eql 'Footnotes::Notes::TestNote'
|
145
|
-
expect(test_note.to_sym).to eql :test
|
146
|
-
end
|
147
|
-
|
148
|
-
specify "notes_links" do
|
149
|
-
note = Footnotes::Notes::TestNote.new
|
150
|
-
expect(note).to receive(:row).twice
|
151
|
-
@footnotes.instance_variable_set(:@notes, [note])
|
152
|
-
footnotes_perform!
|
153
|
-
end
|
154
|
-
|
155
|
-
specify "notes_fieldset" do
|
156
|
-
note = Footnotes::Notes::TestNote.new
|
157
|
-
expect(note).to receive(:has_fieldset?).exactly(3).times
|
158
|
-
@footnotes.instance_variable_set(:@notes, [note])
|
159
|
-
footnotes_perform!
|
160
|
-
end
|
161
|
-
|
162
|
-
specify "multiple_notes" do
|
163
|
-
Footnotes::Filter.multiple_notes = true
|
164
|
-
note = Footnotes::Notes::TestNote.new
|
165
|
-
expect(note).to receive(:has_fieldset?).twice
|
166
|
-
@footnotes.instance_variable_set(:@notes, [note])
|
167
|
-
footnotes_perform!
|
168
|
-
end
|
169
|
-
|
170
|
-
specify "notes_are_reset" do
|
171
|
-
note = Footnotes::Notes::TestNote.new
|
172
|
-
expect(note.class).to receive(:close!)
|
173
|
-
@footnotes.instance_variable_set(:@notes, [note])
|
174
|
-
@footnotes.send(:close!, @controller)
|
175
|
-
end
|
176
|
-
|
177
|
-
specify "links_helper" do
|
178
|
-
note = Footnotes::Notes::TestNote.new
|
179
|
-
expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="">Test</a>'
|
180
|
-
|
181
|
-
expect(note).to receive(:link).once.and_return(:link)
|
182
|
-
expect(@footnotes.send(:link_helper, note)).to eql '<a href="link" onclick="">Test</a>'
|
183
|
-
end
|
184
|
-
|
185
|
-
specify "links_helper_has_fieldset?" do
|
186
|
-
note = Footnotes::Notes::TestNote.new
|
187
|
-
expect(note).to receive(:has_fieldset?).once.and_return(true)
|
188
|
-
expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="Footnotes.hideAllAndToggle(\'test_debug_info\');return false;">Test</a>'
|
189
|
-
end
|
190
|
-
|
191
|
-
specify "links_helper_onclick" do
|
192
|
-
note = Footnotes::Notes::TestNote.new
|
193
|
-
expect(note).to receive(:onclick).twice.and_return(:onclick)
|
194
|
-
expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="onclick">Test</a>'
|
195
|
-
|
196
|
-
expect(note).to receive(:has_fieldset?).once.and_return(true)
|
197
|
-
expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="onclick">Test</a>'
|
198
|
-
end
|
199
|
-
|
200
|
-
specify "insert_style" do
|
201
|
-
@controller.response.body = "<head></head><split><body></body>"
|
202
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
203
|
-
footnotes_perform!
|
204
|
-
expect(@controller.response.body.split('<split>').first.include?('<!-- Footnotes Style -->')).to be
|
205
|
-
end
|
206
|
-
|
207
|
-
specify "insert_footnotes_inside_body" do
|
208
|
-
@controller.response.body = "<head></head><split><body></body>"
|
209
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
210
|
-
footnotes_perform!
|
211
|
-
expect(@controller.response.body.split('<split>').last.include?('<!-- End Footnotes -->')).to be
|
212
|
-
end
|
213
|
-
|
214
|
-
specify "insert_footnotes_inside_holder" do
|
215
|
-
@controller.response.body = "<head></head><split><div id='footnotes_holder'></div>"
|
216
|
-
@footnotes = Footnotes::Filter.new(@controller)
|
217
|
-
footnotes_perform!
|
218
|
-
expect(@controller.response.body.split('<split>').last.include?('<!-- End Footnotes -->')).to be
|
219
|
-
end
|
220
|
-
|
221
|
-
specify "insert_text" do
|
222
|
-
@footnotes.send(:insert_text, :after, /<head>/, "Graffiti")
|
223
|
-
after = " <head>Graffiti"
|
224
|
-
expect(@controller.response.body.split("\n")[2]).to eql after
|
225
|
-
|
226
|
-
@footnotes.send(:insert_text, :before, /<\/body>/, "Notes")
|
227
|
-
after = " Notes</body>"
|
228
|
-
expect(@controller.response.body.split("\n")[12]).to eql after
|
229
|
-
end
|
230
|
-
|
231
|
-
describe 'Hooks' do
|
232
|
-
before {Footnotes::Filter.notes = [:note_x, :note_y, :note_z]}
|
233
|
-
context 'before' do
|
234
|
-
specify do
|
235
|
-
Footnotes.setup {|config| config.before {|controller, filter| filter.notes -= [:note_y] }}
|
236
|
-
Footnotes::Filter.start!(@controller)
|
237
|
-
expect(Footnotes::Filter.notes).to eql [:note_x, :note_z]
|
238
|
-
end
|
239
|
-
end
|
240
|
-
context "after" do
|
241
|
-
specify do
|
242
|
-
Footnotes.setup {|config| config.after {|controller, filter| filter.notes -= [:note_y] }}
|
243
|
-
Footnotes::Filter.start!(@controller)
|
244
|
-
expect(Footnotes::Filter.notes).to eql [:note_x, :note_z]
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
protected
|
251
|
-
def footnotes_perform!
|
252
|
-
template_expects('html')
|
253
|
-
@controller.performed_render = true
|
254
|
-
|
255
|
-
Footnotes::Filter.start!(@controller)
|
256
|
-
@footnotes.add_footnotes!
|
257
|
-
end
|
258
|
-
|
259
|
-
def template_expects(format)
|
260
|
-
if @controller.template.respond_to?(:template_format)
|
261
|
-
allow(@controller.template).to receive(:template_format).and_return(format)
|
262
|
-
else
|
263
|
-
allow(@controller.template).to receive(:format).and_return(format)
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "action_controller"
|
3
|
-
require "rails-footnotes/notes/assigns_note"
|
4
|
-
require "support/active_record"
|
5
|
-
|
6
|
-
describe Footnotes::Notes::AssignsNote do
|
7
|
-
let(:controller) do
|
8
|
-
double(instance_variables: [:@action_has_layout, :@status]).tap do |c|
|
9
|
-
c.instance_variable_set(:@action_has_layout, true)
|
10
|
-
c.instance_variable_set(:@status, 200)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
subject(:note) { Footnotes::Notes::AssignsNote.new(controller) }
|
14
|
-
|
15
|
-
before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = []}
|
16
|
-
|
17
|
-
it { should be_valid }
|
18
|
-
|
19
|
-
describe '#title' do
|
20
|
-
subject { super().title }
|
21
|
-
it {should eql 'Assigns (2)'}
|
22
|
-
end
|
23
|
-
|
24
|
-
specify {expect(note.send(:assigns)).to eql [:@action_has_layout, :@status]}
|
25
|
-
specify {expect(note.send(:to_table)).to eql [
|
26
|
-
["Name", "Value"],
|
27
|
-
["<strong>@action_has_layout</strong><br /><em>TrueClass</em>", "true"],
|
28
|
-
["<strong>@status</strong><br /><em>Integer</em>", "200"]
|
29
|
-
]}
|
30
|
-
|
31
|
-
describe "Ignored Assigns" do
|
32
|
-
before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = [:@status]}
|
33
|
-
it {expect(note.send(:assigns)).not_to include :@status}
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "Ignored Assigns by regexp" do
|
37
|
-
before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns_pattern = /^@status$/}
|
38
|
-
it {expect(note.send(:assigns)).not_to include :@status}
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should call #mount_table method with correct params" do
|
42
|
-
expect(note).to receive(:mount_table).with(
|
43
|
-
[
|
44
|
-
["Name", "Value"],
|
45
|
-
["<strong>@action_has_layout</strong><br /><em>TrueClass</em>", "true"],
|
46
|
-
["<strong>@status</strong><br /><em>Integer</em>", "200"]
|
47
|
-
], {:summary=>"Debug information for Assigns (2)"})
|
48
|
-
note.content
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "when it is an ActiveRecord::Relation" do
|
52
|
-
let(:controller) do
|
53
|
-
double(instance_variables: [:@widgets]).tap do |c|
|
54
|
-
c.instance_variable_set(:@widgets, Widget.all)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should still work" do
|
59
|
-
expect(note).to receive(:mount_table).with(
|
60
|
-
[
|
61
|
-
["Name", "Value"],
|
62
|
-
["<strong>@widgets</strong><br /><em>ActiveRecord::Relation</em>", "#<ActiveRecord::Relation []>"],
|
63
|
-
], {:summary=>"Debug information for Assigns (1)"})
|
64
|
-
expect(note).to be_valid
|
65
|
-
note.content
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "rails-footnotes/notes/controller_note"
|
3
|
-
|
4
|
-
describe Footnotes::Notes::ControllerNote do
|
5
|
-
# Issue #60
|
6
|
-
it "should not be valid if conftroller file not exist" do
|
7
|
-
note = Footnotes::Notes::ControllerNote.new(double)
|
8
|
-
allow(note).to receive(:controller_filename).and_return(nil)
|
9
|
-
|
10
|
-
expect(note).not_to be_valid
|
11
|
-
end
|
12
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'action_controller'
|
3
|
-
require "rails-footnotes/notes/files_note"
|
4
|
-
|
5
|
-
class ConcreteFilesNote < Footnotes::Notes::FilesNote
|
6
|
-
def scan_text(text)
|
7
|
-
[]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe Footnotes::Notes::FilesNote do
|
12
|
-
|
13
|
-
let(:note) do
|
14
|
-
ConcreteFilesNote.new(double('controller', :response => double('', :body => '')))
|
15
|
-
end
|
16
|
-
|
17
|
-
subject { note }
|
18
|
-
|
19
|
-
it { should be_valid }
|
20
|
-
|
21
|
-
describe '#row' do
|
22
|
-
subject { super().row }
|
23
|
-
it { should eql :edit }
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require "rails-footnotes/notes/javascripts_note"
|
3
|
-
|
4
|
-
describe Footnotes::Notes::JavascriptsNote do
|
5
|
-
let(:note) {described_class.new(double('controller', :response => double('body', :body => '')))}
|
6
|
-
subject {note}
|
7
|
-
|
8
|
-
it {should be_valid}
|
9
|
-
|
10
|
-
it "should return js links from html after #scan_text mehtod call" do
|
11
|
-
expect(subject.send(:scan_text, HTML_WITH_JS)).to eql ['/javascripts/all.js', '/javascripts/jquery.js']
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
HTML_WITH_JS = <<-EOF
|
16
|
-
<script cache="false" src="/javascripts/all.js?1315913920" type="text/javascript"></script>
|
17
|
-
<script cache="false" src="/javascripts/jquery.js?1315913920" type="text/javascript"></script>
|
18
|
-
EOF
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require "rails-footnotes/notes/stylesheets_note"
|
3
|
-
|
4
|
-
describe Footnotes::Notes::StylesheetsNote do
|
5
|
-
|
6
|
-
let(:note) {described_class.new(double('controller', :response => double('body', :body => '')))}
|
7
|
-
subject {note}
|
8
|
-
|
9
|
-
it {should be_valid}
|
10
|
-
|
11
|
-
it "should return css link from html text after #scan_text call" do
|
12
|
-
expect(subject.send(:scan_text, HTML_WITH_CSS)).to eql ['/stylesheets/compiled/print.css', '/stylesheets/compiled/print.css']
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
HTML_WITH_CSS = <<-EOF
|
17
|
-
<link href="/stylesheets/compiled/print.css?1315913920" media="print" rel="stylesheet" type="text/css" />'
|
18
|
-
'<link href="/stylesheets/compiled/print.css?1315913920" media="print" rel="stylesheet" type="text/css" />'
|
19
|
-
EOF
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "rails-footnotes/notes/view_note"
|
3
|
-
|
4
|
-
describe Footnotes::Notes::ViewNote do
|
5
|
-
it "should not be valid if view file not exist" do
|
6
|
-
note = Footnotes::Notes::ViewNote.new(double)
|
7
|
-
allow(note).to receive(:filename).and_return(nil)
|
8
|
-
|
9
|
-
expect(note).not_to be_valid
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not explode if template is nil" do
|
13
|
-
Footnotes::Notes::ViewNote.template = nil
|
14
|
-
|
15
|
-
note = Footnotes::Notes::ViewNote.new(double)
|
16
|
-
expect(note).to_not be_valid
|
17
|
-
end
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
|
-
ENV["RAILS_ENV"] ||= 'test'
|
7
|
-
require "sprockets/railtie"
|
8
|
-
require "rails-footnotes"
|
9
|
-
require 'capybara/rspec'
|
10
|
-
|
11
|
-
module FooBar
|
12
|
-
class Application < Rails::Application
|
13
|
-
config.secret_key_base = 'foobar'
|
14
|
-
config.root = Dir.new('./spec')
|
15
|
-
config.eager_load = false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
ActionController::Base.class_eval do
|
20
|
-
include Rails.application.routes.url_helpers
|
21
|
-
end
|
22
|
-
|
23
|
-
class ApplicationController < ActionController::Base
|
24
|
-
end
|
25
|
-
|
26
|
-
module Helpers
|
27
|
-
def page
|
28
|
-
Capybara::Node::Simple.new(response.body)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
RSpec.configure do |config|
|
33
|
-
Rails.application.initialize!
|
34
|
-
|
35
|
-
config.include Capybara::DSL
|
36
|
-
config.include Helpers
|
37
|
-
config.example_status_persistence_file_path = ".rspec_results"
|
38
|
-
config.filter_run_when_matching :focus
|
39
|
-
|
40
|
-
Rails.application.routes.draw do
|
41
|
-
get 'footnotes/foo'
|
42
|
-
get 'footnotes/foo_holder'
|
43
|
-
get 'footnotes/foo_js'
|
44
|
-
get 'footnotes/foo_download'
|
45
|
-
get 'partials/index'
|
46
|
-
get 'files/index'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
require 'rspec/rails'
|
51
|
-
require 'capybara/rails'
|
52
|
-
|
53
|
-
HTML_DOCUMENT = <<EOF
|
54
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
55
|
-
<html>
|
56
|
-
<head>
|
57
|
-
<title>HTML to XHTML Example: HTML page</title>
|
58
|
-
<link rel="Stylesheet" href="htmltohxhtml.css" type="text/css" media="screen">
|
59
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
60
|
-
</head>
|
61
|
-
<body>
|
62
|
-
<p>This is the HTML page. It works and is encoded just like any HTML page you
|
63
|
-
have previously done. View <a href="htmltoxhtml2.htm">the XHTML version</a> of
|
64
|
-
this page to view the difference between HTML and XHTML.</p>
|
65
|
-
<p>You will be glad to know that no changes need to be made to any of your CSS files.</p>
|
66
|
-
</body>
|
67
|
-
</html>
|
68
|
-
EOF
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "active_record"
|
2
|
-
|
3
|
-
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
4
|
-
|
5
|
-
ActiveRecord::Migration.verbose = false
|
6
|
-
|
7
|
-
ActiveRecord::Migration.create_table :widgets do |t|
|
8
|
-
t.string :name
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
|
12
|
-
class Widget < ActiveRecord::Base
|
13
|
-
end
|
14
|
-
|
15
|
-
RSpec.configure do |config|
|
16
|
-
config.around do |example|
|
17
|
-
ActiveRecord::Base.transaction do
|
18
|
-
example.run
|
19
|
-
raise ActiveRecord::Rollback
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|