rails-footnotes 4.1.6 → 4.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57242b5f541d4d6722be87fcb7aaee885065388
4
- data.tar.gz: 804664dc9f668fe41bf3cd4c0a3e05a72cf4bb2d
3
+ metadata.gz: 5e2343ef7d62b4ef197387788f0ff7dd42e86441
4
+ data.tar.gz: 72282e6373b9b1519d1cd6ba2eedea85aaf39d60
5
5
  SHA512:
6
- metadata.gz: 4f6e3da7e078c14fd7d4115d250a871c74e75319a4aa47373ebae0cbc3e0094770c24fac5b7ddac183df83eb5a73bcddd93037c09af387a91cc5d4403a1f5b32
7
- data.tar.gz: cc4644cb39a8336493649916a3d412f03eb42ff8f8b703f88e29bbd2f6720f0e9a75e6df292a20ce5bddecd4b09a4c7b1a833b4dda4f864b57c5c8e906632510
6
+ metadata.gz: bb376b0a2f6ee0414db7c4923bd0d9d81813852241cccee6f5a0861c6f92d99f5f19b69eb2a25812694245c62048a4f75dadc46406963e4dc714bc7e1c4dbc60
7
+ data.tar.gz: c202eef9eb88ba4327a00c046763e5572269b863ac528bb6a58644f2bda6f29ee99902cff4102daf1da9f3fecdc052e79fc0d36aa68807fda0a91b48820f8c42
data/CHANGELOG CHANGED
@@ -1,5 +1,7 @@
1
+ == Footnotes v4.1.7 ==
2
+ * Fix notes not collapsing when clicking on them again (#130)*
1
3
  == Footnotes v4.1.6 ==
2
- * Fix incorrect handler link to css/js files (#217)*
4
+ * Fix incorrect handler link to css/js files (#127)*
3
5
  == Footnotes v4.1.5 ==
4
6
  * Remove use of non-existing note in initializer introduced in v4, impacting new installations *
5
7
  == Footnotes v4.1.4 ==
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ task :default => :spec
9
9
  desc 'Run tests for Footnotes.'
10
10
  RSpec::Core::RakeTask.new(:spec) do |t|
11
11
  t.pattern = 'spec/**/*_spec.rb'
12
- t.rcov = false
12
+ # t.rcov = false
13
13
  end
14
14
 
15
15
  desc 'Generate documentation for Footnotes.'
@@ -50,9 +50,13 @@ module Footnotes
50
50
  @@after_hooks << block
51
51
  end
52
52
 
53
- def self.enabled?
53
+ def self.enabled?(controller)
54
54
  if @@enabled.is_a? Proc
55
- @@enabled.call
55
+ if @@enabled.arity == 1
56
+ @@enabled.call(controller)
57
+ else
58
+ @@enabled.call
59
+ end
56
60
  else
57
61
  !!@@enabled
58
62
  end
@@ -11,13 +11,13 @@ module Footnotes
11
11
  end
12
12
 
13
13
  def rails_footnotes_before_filter
14
- if Footnotes.enabled?
14
+ if Footnotes.enabled?(self)
15
15
  Footnotes::Filter.start!(self)
16
16
  end
17
17
  end
18
18
 
19
19
  def rails_footnotes_after_filter
20
- if Footnotes.enabled?
20
+ if Footnotes.enabled?(self)
21
21
  filter = Footnotes::Filter.new(self)
22
22
  filter.add_footnotes!
23
23
  filter.close!(self)
@@ -207,14 +207,22 @@ module Footnotes
207
207
  }
208
208
 
209
209
  function hideAllAndToggle(id) {
210
+ var n = note(id);
211
+ var display = n.style.display;
210
212
  hideAll();
213
+ // Restore original display to allow toggling
214
+ n.style.display = display;
211
215
  toggle(id)
212
216
 
213
217
  location.href = '#footnotes_debug';
214
218
  }
215
219
 
220
+ function note(id) {
221
+ return (document.getElementById(id));
222
+ }
223
+
216
224
  function toggle(id){
217
- var el = document.getElementById(id);
225
+ var el = note(id);
218
226
  if (el.style.display == 'none') {
219
227
  Footnotes.show(el);
220
228
  } else {
@@ -1,31 +1,39 @@
1
1
  module Footnotes
2
2
  module Notes
3
3
  class ViewNote < AbstractNote
4
+ cattr_accessor :template
5
+
6
+ def self.start!(controller)
7
+ @subscriber ||= ActiveSupport::Notifications.subscribe('render_template.action_view') do |*args|
8
+ event = ActiveSupport::Notifications::Event.new *args
9
+ self.template = {:file => event.payload[:identifier], :duration => event.duration}
10
+ end
11
+ end
12
+
4
13
  def initialize(controller)
5
14
  @controller = controller
6
- @template = controller.instance_variable_get(:@template)
7
15
  end
8
16
 
9
17
  def row
10
18
  :edit
11
19
  end
12
20
 
21
+ def title
22
+ "View (#{"%.3f" % self.template[:duration]}ms)"
23
+ end
24
+
13
25
  def link
14
26
  escape(Footnotes::Filter.prefix(filename, 1, 1))
15
27
  end
16
28
 
17
29
  def valid?
18
- prefix? && first_render?
30
+ prefix? && filename && File.exists?(filename)
19
31
  end
20
32
 
21
33
  protected
22
34
 
23
- def first_render?
24
- @template.instance_variable_get(:@_first_render)
25
- end
26
-
27
35
  def filename
28
- @filename ||= @template.instance_variable_get(:@_first_render).filename
36
+ @filename ||= self.class.template[:file]
29
37
  end
30
38
 
31
39
  end
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "4.1.6"
2
+ VERSION = "4.1.7"
3
3
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "rails", ">= 3.2"
18
18
 
19
- s.add_development_dependency "rspec-rails", '~> 2.14.0'
19
+ s.add_development_dependency "rspec-rails", '~> 3.2.1'
20
20
  s.add_development_dependency "test-unit"
21
21
  s.add_development_dependency "capybara"
22
22
 
@@ -11,17 +11,21 @@ describe Footnotes::Notes::AbstractNote do
11
11
  Footnotes::Filter.notes = @notes
12
12
  end
13
13
 
14
- it {described_class.should respond_to :start!}
15
- it {described_class.should respond_to :close!}
16
- it {described_class.should respond_to :title}
14
+ it {expect(described_class).to respond_to :start!}
15
+ it {expect(described_class).to respond_to :close!}
16
+ it {expect(described_class).to respond_to :title}
17
17
 
18
18
  it {should respond_to :to_sym}
19
- its(:to_sym) {should eql :abstract}
20
19
 
21
- it { described_class.should be_included }
20
+ describe '#to_sym' do
21
+ subject { super().to_sym }
22
+ it {should eql :abstract}
23
+ end
24
+
25
+ it { expect(described_class).to be_included }
22
26
  specify do
23
27
  Footnotes::Filter.notes = []
24
- described_class.should_not be_included
28
+ expect(described_class).not_to be_included
25
29
  end
26
30
 
27
31
  it { should respond_to :row }
@@ -45,12 +49,12 @@ describe Footnotes::Notes::AbstractNote do
45
49
 
46
50
  #TODO should be moved to builder
47
51
  #helpers
48
- specify { subject.escape('<').should eql '&lt;' }
49
- specify { subject.escape('&').should eql '&amp;' }
50
- specify { subject.escape('>').should eql '&gt;' }
52
+ specify { expect(subject.escape('<')).to eql '&lt;' }
53
+ specify { expect(subject.escape('&')).to eql '&amp;' }
54
+ specify { expect(subject.escape('>')).to eql '&gt;' }
51
55
 
52
- specify { subject.mount_table([]).should be_blank }
53
- specify { subject.mount_table([['h1', 'h2', 'h3']], :class => 'table').should be_blank }
56
+ specify { expect(subject.mount_table([])).to be_blank }
57
+ specify { expect(subject.mount_table([['h1', 'h2', 'h3']], :class => 'table')).to be_blank }
54
58
 
55
59
  specify {
56
60
  tab = <<-TABLE
@@ -60,7 +64,7 @@ describe Footnotes::Notes::AbstractNote do
60
64
  </table>
61
65
  TABLE
62
66
 
63
- subject.mount_table([['h1'],['r1c1']], :class => 'table').should eql tab
67
+ expect(subject.mount_table([['h1'],['r1c1']], :class => 'table')).to eql tab
64
68
  }
65
69
 
66
70
  specify {
@@ -70,7 +74,7 @@ describe Footnotes::Notes::AbstractNote do
70
74
  <tbody><tr><td>r1c1</td><td>r1c2</td><td>r1c3</td></tr></tbody>
71
75
  </table>
72
76
  TABLE
73
- subject.mount_table([['h1', 'h2', 'h3'],['r1c1', 'r1c2', 'r1c3']]).should eql tab
77
+ expect(subject.mount_table([['h1', 'h2', 'h3'],['r1c1', 'r1c2', 'r1c3']])).to eql tab
74
78
  }
75
79
 
76
80
  specify {
@@ -6,14 +6,8 @@ class FilesController < ApplicationController
6
6
  end
7
7
  end
8
8
 
9
- describe FilesController do
10
-
9
+ describe FilesController, type: :controller do
11
10
  render_views
12
- include Capybara::DSL
13
-
14
- def page
15
- Capybara::Node::Simple.new(response.body)
16
- end
17
11
 
18
12
  before :all do
19
13
  Footnotes.enabled = true
@@ -20,28 +20,24 @@ class FootnotesController < ActionController::Base
20
20
 
21
21
  end
22
22
 
23
- describe FootnotesController do
24
-
25
- def page
26
- Capybara::Node::Simple.new(response.body)
27
- end
23
+ describe FootnotesController, type: :controller do
28
24
 
29
25
  shared_examples 'has_footnotes' do
30
26
  it 'includes footnotes' do
31
27
  get :foo
32
- response.body.should have_selector('#footnotes_debug')
28
+ expect(response.body).to have_selector('#footnotes_debug')
33
29
  end
34
30
  end
35
31
 
36
32
  shared_examples 'has_no_footnotes' do
37
33
  it 'does not include footnotes' do
38
- response.body.should_not have_selector('#footnotes_debug')
34
+ expect(response.body).not_to have_selector('#footnotes_debug')
39
35
  end
40
36
  end
41
37
 
42
38
  it 'does not alter the page by default' do
43
39
  get :foo
44
- response.body.should == HTML_DOCUMENT
40
+ expect(response.body).to eq(HTML_DOCUMENT)
45
41
  end
46
42
 
47
43
  context 'with footnotes' do
@@ -62,17 +58,17 @@ describe FootnotesController do
62
58
  end
63
59
 
64
60
  it 'includes footnotes in the last div in body' do
65
- all('body > :last-child')[0][:id].should == 'footnotes_debug'
61
+ expect(all('body > :last-child')[0][:id]).to eq('footnotes_debug')
66
62
  end
67
63
 
68
64
  it 'includes footnotes in the footnoted_holder div if present' do
69
65
  get :foo_holder
70
- response.body.should have_selector('#footnotes_holder > #footnotes_debug')
66
+ expect(response.body).to have_selector('#footnotes_holder > #footnotes_debug')
71
67
  end
72
68
 
73
69
  it 'does not alter a html file download' do
74
70
  get :foo_download
75
- response.body.should == File.open(Rails.root.join('fixtures', 'html_download.html')).read
71
+ expect(response.body).to eq(File.open(Rails.root.join('fixtures', 'html_download.html')).read)
76
72
  end
77
73
  end
78
74
 
@@ -90,6 +86,43 @@ describe FootnotesController do
90
86
  end
91
87
  end
92
88
 
89
+ describe 'when footnotes is disabled' do
90
+ include_context 'has_no_footnotes'
91
+ before do
92
+ Footnotes.enabled = false
93
+ get :foo
94
+ end
95
+ end
96
+
97
+ describe 'with a proc' do
98
+
99
+ it 'yields the controller' do
100
+ c = nil
101
+ Footnotes.enabled = lambda { |controller| c = controller}
102
+ get :foo
103
+ expect(c).to be_kind_of(ActionController::Base)
104
+ end
105
+
106
+ context 'returning true' do
107
+ include_context 'has_footnotes'
108
+
109
+ before do
110
+ Footnotes.enabled = lambda { true }
111
+ get :foo
112
+ end
113
+ end
114
+
115
+ context 'returning false' do
116
+ include_context 'has_no_footnotes'
117
+
118
+ before do
119
+ Footnotes.enabled = lambda { false }
120
+ get :foo
121
+ end
122
+ end
123
+
124
+ end
125
+
93
126
  end
94
127
 
95
128
  end
@@ -1,11 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'stringio'
3
3
 
4
- describe 'log note' do
5
-
6
- def page
7
- Capybara::Node::Simple.new(response.body)
8
- end
4
+ describe 'log note', type: :controller do
9
5
 
10
6
  class ApplicationController < ActionController::Base
11
7
  end
@@ -29,8 +25,8 @@ describe 'log note' do
29
25
  it 'Includes the log in the response' do
30
26
  get :index
31
27
  log_debug = first('fieldset#log_debug_info div', :visible => false)
32
- log_debug.should have_content('foo')
33
- log_debug.should have_content('bar')
28
+ expect(log_debug).to have_content('foo')
29
+ expect(log_debug).to have_content('bar')
34
30
  end
35
31
 
36
32
  end
@@ -7,7 +7,7 @@ class PartialsController < ActionController::Base
7
7
 
8
8
  end
9
9
 
10
- describe PartialsController do
10
+ describe PartialsController, type: :controller do
11
11
 
12
12
  render_views
13
13
 
@@ -21,7 +21,7 @@ describe PartialsController do
21
21
 
22
22
  it 'lists the rendered partials' do
23
23
  get :index
24
- response.body.should have_selector('#footnotes_debug #partials_debug_info table tr', :visible => false, :count => 2)
24
+ expect(response.body).to have_selector('#footnotes_debug #partials_debug_info table tr', :visible => false, :count => 2)
25
25
  end
26
26
 
27
27
 
@@ -42,7 +42,7 @@ describe "Footnotes" do
42
42
 
43
43
  it "footnotes_controller" do
44
44
  index = @controller.response.body.index(/This is the HTML page/)
45
- index.should eql 334
45
+ expect(index).to eql 334
46
46
  end
47
47
 
48
48
  context "response_body is file" do
@@ -66,62 +66,62 @@ describe "Footnotes" do
66
66
 
67
67
  it "foonotes_included" do
68
68
  footnotes_perform!
69
- @controller.response_body.should_not == HTML_DOCUMENT
69
+ expect(@controller.response_body).not_to eq(HTML_DOCUMENT)
70
70
  end
71
71
 
72
72
  it "should escape links with special chars" do
73
73
  note_with_link = Footnotes::Notes::FileURINote.new
74
74
  link = Footnotes::Filter.prefix(note_with_link.link, 1, 1, 1)
75
- link.should eql "txmt://open?url=file:///example/local%20file%20path/with-special-chars/%C3%B6%C3%A4%C3%BC/file&amp;line=1&amp;column=1"
75
+ expect(link).to eql "txmt://open?url=file:///example/local%20file%20path/with-special-chars/%C3%B6%C3%A4%C3%BC/file&amp;line=1&amp;column=1"
76
76
  end
77
77
 
78
78
  specify "footnotes_not_included_when_request_is_xhr" do
79
79
  @controller.request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
80
80
  @controller.request.env['HTTP_ACCEPT'] = 'text/javascript, text/html, application/xml, text/xml, */*'
81
81
  footnotes_perform!
82
- @controller.response.body.should eql HTML_DOCUMENT
82
+ expect(@controller.response.body).to eql HTML_DOCUMENT
83
83
  end
84
84
 
85
85
  specify "footnotes_not_included_when_content_type_is_javascript" do
86
86
  @controller.response.content_type = 'text/javascript'
87
87
  footnotes_perform!
88
- @controller.response.body.should eql HTML_DOCUMENT
88
+ expect(@controller.response.body).to eql HTML_DOCUMENT
89
89
  end
90
90
 
91
91
  specify "footnotes_included_when_content_type_is_html" do
92
92
  @controller.response.content_type = 'text/html'
93
93
  footnotes_perform!
94
- @controller.response.body.should_not eql HTML_DOCUMENT
94
+ expect(@controller.response.body).not_to eql HTML_DOCUMENT
95
95
  end
96
96
 
97
97
  specify "footnotes_included_when_content_type_is_nil" do
98
98
  footnotes_perform!
99
- @controller.response.body.should_not eql HTML_DOCUMENT
99
+ expect(@controller.response.body).not_to eql HTML_DOCUMENT
100
100
  end
101
101
 
102
102
  specify "not_included_when_body_is_not_a_string" do
103
- @controller.response.stub(:body).and_return(Time.now)# = Proc.new { Time.now }
104
- Footnotes::Filter.new(@controller).send(:valid?).should_not be
105
- @controller.response.body.should_not =~ /<!-- Footnotes/
103
+ allow(@controller.response).to receive(:body).and_return(Time.now)# = Proc.new { Time.now }
104
+ expect(Footnotes::Filter.new(@controller).send(:valid?)).not_to be
105
+ expect(@controller.response.body).not_to match(/<!-- Footnotes/)
106
106
  end
107
107
 
108
108
  specify "notes_are_initialized" do
109
109
  footnotes_perform!
110
110
  test_note = @footnotes.instance_variable_get('@notes').first
111
- test_note.class.name.should eql 'Footnotes::Notes::TestNote'
112
- test_note.to_sym.should eql :test
111
+ expect(test_note.class.name).to eql 'Footnotes::Notes::TestNote'
112
+ expect(test_note.to_sym).to eql :test
113
113
  end
114
114
 
115
115
  specify "notes_links" do
116
116
  note = Footnotes::Notes::TestNote.new
117
- note.should_receive(:row).twice
117
+ expect(note).to receive(:row).twice
118
118
  @footnotes.instance_variable_set(:@notes, [note])
119
119
  footnotes_perform!
120
120
  end
121
121
 
122
122
  specify "notes_fieldset" do
123
123
  note = Footnotes::Notes::TestNote.new
124
- note.should_receive(:has_fieldset?).exactly(3).times
124
+ expect(note).to receive(:has_fieldset?).exactly(3).times
125
125
  @footnotes.instance_variable_set(:@notes, [note])
126
126
  footnotes_perform!
127
127
  end
@@ -129,70 +129,70 @@ describe "Footnotes" do
129
129
  specify "multiple_notes" do
130
130
  Footnotes::Filter.multiple_notes = true
131
131
  note = Footnotes::Notes::TestNote.new
132
- note.should_receive(:has_fieldset?).twice
132
+ expect(note).to receive(:has_fieldset?).twice
133
133
  @footnotes.instance_variable_set(:@notes, [note])
134
134
  footnotes_perform!
135
135
  end
136
136
 
137
137
  specify "notes_are_reset" do
138
138
  note = Footnotes::Notes::TestNote.new
139
- note.class.should_receive(:close!)
139
+ expect(note.class).to receive(:close!)
140
140
  @footnotes.instance_variable_set(:@notes, [note])
141
141
  @footnotes.send(:close!, @controller)
142
142
  end
143
143
 
144
144
  specify "links_helper" do
145
145
  note = Footnotes::Notes::TestNote.new
146
- @footnotes.send(:link_helper, note).should eql '<a href="#" onclick="">Test</a>'
146
+ expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="">Test</a>'
147
147
 
148
- note.should_receive(:link).once.and_return(:link)
149
- @footnotes.send(:link_helper, note).should eql '<a href="link" onclick="">Test</a>'
148
+ expect(note).to receive(:link).once.and_return(:link)
149
+ expect(@footnotes.send(:link_helper, note)).to eql '<a href="link" onclick="">Test</a>'
150
150
  end
151
151
 
152
152
  specify "links_helper_has_fieldset?" do
153
153
  note = Footnotes::Notes::TestNote.new
154
- note.should_receive(:has_fieldset?).once.and_return(true)
155
- @footnotes.send(:link_helper, note).should eql '<a href="#" onclick="Footnotes.hideAllAndToggle(\'test_debug_info\');return false;">Test</a>'
154
+ expect(note).to receive(:has_fieldset?).once.and_return(true)
155
+ expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="Footnotes.hideAllAndToggle(\'test_debug_info\');return false;">Test</a>'
156
156
  end
157
157
 
158
158
  specify "links_helper_onclick" do
159
159
  note = Footnotes::Notes::TestNote.new
160
- note.should_receive(:onclick).twice.and_return(:onclick)
161
- @footnotes.send(:link_helper, note).should eql '<a href="#" onclick="onclick">Test</a>'
160
+ expect(note).to receive(:onclick).twice.and_return(:onclick)
161
+ expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="onclick">Test</a>'
162
162
 
163
- note.should_receive(:has_fieldset?).once.and_return(true)
164
- @footnotes.send(:link_helper, note).should eql '<a href="#" onclick="onclick">Test</a>'
163
+ expect(note).to receive(:has_fieldset?).once.and_return(true)
164
+ expect(@footnotes.send(:link_helper, note)).to eql '<a href="#" onclick="onclick">Test</a>'
165
165
  end
166
166
 
167
167
  specify "insert_style" do
168
168
  @controller.response.body = "<head></head><split><body></body>"
169
169
  @footnotes = Footnotes::Filter.new(@controller)
170
170
  footnotes_perform!
171
- @controller.response.body.split('<split>').first.include?('<!-- Footnotes Style -->').should be
171
+ expect(@controller.response.body.split('<split>').first.include?('<!-- Footnotes Style -->')).to be
172
172
  end
173
173
 
174
174
  specify "insert_footnotes_inside_body" do
175
175
  @controller.response.body = "<head></head><split><body></body>"
176
176
  @footnotes = Footnotes::Filter.new(@controller)
177
177
  footnotes_perform!
178
- @controller.response.body.split('<split>').last.include?('<!-- End Footnotes -->').should be
178
+ expect(@controller.response.body.split('<split>').last.include?('<!-- End Footnotes -->')).to be
179
179
  end
180
180
 
181
181
  specify "insert_footnotes_inside_holder" do
182
182
  @controller.response.body = "<head></head><split><div id='footnotes_holder'></div>"
183
183
  @footnotes = Footnotes::Filter.new(@controller)
184
184
  footnotes_perform!
185
- @controller.response.body.split('<split>').last.include?('<!-- End Footnotes -->').should be
185
+ expect(@controller.response.body.split('<split>').last.include?('<!-- End Footnotes -->')).to be
186
186
  end
187
187
 
188
188
  specify "insert_text" do
189
189
  @footnotes.send(:insert_text, :after, /<head>/, "Graffiti")
190
190
  after = " <head>Graffiti"
191
- @controller.response.body.split("\n")[2].should eql after
191
+ expect(@controller.response.body.split("\n")[2]).to eql after
192
192
 
193
193
  @footnotes.send(:insert_text, :before, /<\/body>/, "Notes")
194
194
  after = " Notes</body>"
195
- @controller.response.body.split("\n")[12].should eql after
195
+ expect(@controller.response.body.split("\n")[12]).to eql after
196
196
  end
197
197
 
198
198
  describe 'Hooks' do
@@ -201,14 +201,14 @@ describe "Footnotes" do
201
201
  specify do
202
202
  Footnotes.setup {|config| config.before {|controller, filter| filter.notes -= [:note_y] }}
203
203
  Footnotes::Filter.start!(@controller)
204
- Footnotes::Filter.notes.should eql [:note_x, :note_z]
204
+ expect(Footnotes::Filter.notes).to eql [:note_x, :note_z]
205
205
  end
206
206
  end
207
207
  context "after" do
208
208
  specify do
209
209
  Footnotes.setup {|config| config.after {|controller, filter| filter.notes -= [:note_y] }}
210
210
  Footnotes::Filter.start!(@controller)
211
- Footnotes::Filter.notes.should eql [:note_x, :note_z]
211
+ expect(Footnotes::Filter.notes).to eql [:note_x, :note_z]
212
212
  end
213
213
  end
214
214
  end
@@ -224,9 +224,9 @@ describe "Footnotes" do
224
224
 
225
225
  def template_expects(format)
226
226
  if @controller.template.respond_to?(:template_format)
227
- @controller.template.stub(:template_format).and_return(format)
227
+ allow(@controller.template).to receive(:template_format).and_return(format)
228
228
  else
229
- @controller.template.stub(:format).and_return(format)
229
+ allow(@controller.template).to receive(:format).and_return(format)
230
230
  end
231
231
  end
232
232
 
@@ -5,7 +5,7 @@ require "rails-footnotes/notes/assigns_note"
5
5
  describe Footnotes::Notes::AssignsNote do
6
6
  let(:note) do
7
7
  @controller = double
8
- @controller.stub(:instance_variables).and_return([:@action_has_layout, :@status])
8
+ allow(@controller).to receive(:instance_variables).and_return([:@action_has_layout, :@status])
9
9
  @controller.instance_variable_set(:@action_has_layout, true)
10
10
  @controller.instance_variable_set(:@status, 200)
11
11
  Footnotes::Notes::AssignsNote.new(@controller)
@@ -15,10 +15,14 @@ describe Footnotes::Notes::AssignsNote do
15
15
  before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = []}
16
16
 
17
17
  it {should be_valid}
18
- its(:title) {should eql 'Assigns (2)'}
19
18
 
20
- specify {note.send(:assigns).should eql [:@action_has_layout, :@status]}
21
- specify {note.send(:to_table).should eql [
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 [
22
26
  ["Name", "Value"],
23
27
  ["<strong>@action_has_layout</strong><br /><em>TrueClass</em>", "true"],
24
28
  ["<strong>@status</strong><br /><em>Fixnum</em>", "200"]
@@ -26,16 +30,16 @@ describe Footnotes::Notes::AssignsNote do
26
30
 
27
31
  describe "Ignored Assigns" do
28
32
  before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = [:@status]}
29
- it {note.send(:assigns).should_not include :@status}
33
+ it {expect(note.send(:assigns)).not_to include :@status}
30
34
  end
31
35
 
32
36
  describe "Ignored Assigns by regexp" do
33
37
  before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns_pattern = /^@status$/}
34
- it {note.send(:assigns).should_not include :@status}
38
+ it {expect(note.send(:assigns)).not_to include :@status}
35
39
  end
36
40
 
37
41
  it "should call #mount_table method with correct params" do
38
- note.should_receive(:mount_table).with(
42
+ expect(note).to receive(:mount_table).with(
39
43
  [
40
44
  ["Name", "Value"],
41
45
  ["<strong>@action_has_layout</strong><br /><em>TrueClass</em>", "true"],
@@ -5,8 +5,8 @@ describe Footnotes::Notes::ControllerNote do
5
5
  # Issue #60
6
6
  it "should not be valid if conftroller file not exist" do
7
7
  note = Footnotes::Notes::ControllerNote.new(double)
8
- note.stub(:controller_filename).and_return(nil)
8
+ allow(note).to receive(:controller_filename).and_return(nil)
9
9
 
10
- note.should_not be_valid
10
+ expect(note).not_to be_valid
11
11
  end
12
12
  end
@@ -11,6 +11,10 @@ describe Footnotes::Notes::FilesNote do
11
11
  subject { note }
12
12
 
13
13
  it { should be_valid }
14
- its(:row) { should eql :edit }
14
+
15
+ describe '#row' do
16
+ subject { super().row }
17
+ it { should eql :edit }
18
+ end
15
19
 
16
20
  end
@@ -8,7 +8,7 @@ describe Footnotes::Notes::JavascriptsNote do
8
8
  it {should be_valid}
9
9
 
10
10
  it "should return js links from html after #scan_text mehtod call" do
11
- subject.send(:scan_text, HTML_WITH_JS).should eql ['/javascripts/all.js', '/javascripts/jquery.js']
11
+ expect(subject.send(:scan_text, HTML_WITH_JS)).to eql ['/javascripts/all.js', '/javascripts/jquery.js']
12
12
  end
13
13
  end
14
14
 
@@ -9,7 +9,7 @@ describe Footnotes::Notes::StylesheetsNote do
9
9
  it {should be_valid}
10
10
 
11
11
  it "should return css link from html text after #scan_text call" do
12
- subject.send(:scan_text, HTML_WITH_CSS).should eql ['/stylesheets/compiled/print.css', '/stylesheets/compiled/print.css']
12
+ expect(subject.send(:scan_text, HTML_WITH_CSS)).to eql ['/stylesheets/compiled/print.css', '/stylesheets/compiled/print.css']
13
13
  end
14
14
  end
15
15
 
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+ require "rails-footnotes/notes/view_note"
3
+
4
+ describe Footnotes::Notes::ViewNote do
5
+
6
+ it "should not be valid if view file not exist" do
7
+ note = Footnotes::Notes::ViewNote.new(double)
8
+ allow(note).to receive(:filename).and_return(nil)
9
+
10
+ expect(note).not_to be_valid
11
+ end
12
+ end
@@ -6,6 +6,7 @@ end
6
6
  ENV["RAILS_ENV"] ||= 'test'
7
7
  require "sprockets/railtie"
8
8
  require "rails-footnotes"
9
+ require 'capybara/rspec'
9
10
 
10
11
  module FooBar
11
12
  class Application < Rails::Application
@@ -22,10 +23,19 @@ end
22
23
  class ApplicationController < ActionController::Base
23
24
  end
24
25
 
26
+ module Helpers
27
+ def page
28
+ Capybara::Node::Simple.new(response.body)
29
+ end
30
+ end
31
+
25
32
  RSpec.configure do |config|
26
33
 
27
34
  Rails.application.initialize!
28
35
 
36
+ config.include Capybara::DSL
37
+ config.include Helpers
38
+
29
39
  Rails.application.routes.draw do
30
40
  get 'footnotes/foo'
31
41
  get 'footnotes/foo_holder'
@@ -34,9 +44,7 @@ RSpec.configure do |config|
34
44
  get 'partials/index'
35
45
  get 'files/index'
36
46
  end
37
-
38
47
  end
39
48
 
40
49
  require 'rspec/rails'
41
- require 'capybara/rspec'
42
50
  require 'capybara/rails'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.6
4
+ version: 4.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman V. Babenko
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-03-02 00:00:00.000000000 Z
15
+ date: 2015-05-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
@@ -34,14 +34,14 @@ dependencies:
34
34
  requirements:
35
35
  - - "~>"
36
36
  - !ruby/object:Gem::Version
37
- version: 2.14.0
37
+ version: 3.2.1
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - "~>"
43
43
  - !ruby/object:Gem::Version
44
- version: 2.14.0
44
+ version: 3.2.1
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: test-unit
47
47
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,7 @@ files:
137
137
  - spec/notes/files_note_spec.rb
138
138
  - spec/notes/javascripts_note_spec.rb
139
139
  - spec/notes/stylesheets_note_spec.rb
140
+ - spec/notes/view_note_spec.rb
140
141
  - spec/spec_helper.rb
141
142
  homepage: http://github.com/josevalim/rails-footnotes
142
143
  licenses: []
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project: rails-footnotes
160
- rubygems_version: 2.4.5
161
+ rubygems_version: 2.4.6
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Every Rails page has footnotes that gives information about your application
@@ -182,4 +183,5 @@ test_files:
182
183
  - spec/notes/files_note_spec.rb
183
184
  - spec/notes/javascripts_note_spec.rb
184
185
  - spec/notes/stylesheets_note_spec.rb
186
+ - spec/notes/view_note_spec.rb
185
187
  - spec/spec_helper.rb