|
2 | 2 | require 'action_controller' |
3 | 3 | require "rails-footnotes/notes/assigns_note" |
4 | 4 |
|
5 | | -class FootnotesController < ActionController::Base |
6 | | -end |
7 | | - |
8 | 5 | describe Footnotes::Notes::AssignsNote do |
9 | 6 | let(:note) do |
10 | | - @controller = FootnotesController.new |
11 | | - @controller.stub(:instance_variables).and_return([:@action_has_layout, :@view_context_class, :@_status]) |
| 7 | + @controller = mock |
| 8 | + @controller.stub(:instance_variables).and_return([:@action_has_layout, :@_status]) |
| 9 | + @controller.instance_variable_set(:@action_has_layout, true) |
| 10 | + @controller.instance_variable_set(:@_status, 200) |
12 | 11 | Footnotes::Notes::AssignsNote.new(@controller) |
13 | 12 | end |
14 | 13 | subject {note} |
15 | 14 |
|
16 | 15 | before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = []} |
| 16 | + |
17 | 17 | it {should be_valid} |
18 | | - its(:title) {should eql 'Assigns (3)'} |
19 | | - specify {note.send(:assigns).should eql [:@action_has_layout, :@view_context_class, :@_status]} |
| 18 | + its(:title) {should eql 'Assigns (2)'} |
| 19 | + |
| 20 | + specify {note.send(:assigns).should eql [:@action_has_layout, :@_status]} |
| 21 | + specify {note.send(:to_table).should eql [['Name', 'Value'], [:@action_has_layout, "true"], [:@_status, "200"]]} |
20 | 22 |
|
21 | 23 | describe "Ignored Assigns" do |
22 | 24 | before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = [:@_status]} |
23 | 25 | it {note.send(:assigns).should_not include :@_status} |
24 | 26 | end |
| 27 | + |
| 28 | + it "should call #mount_table method with correct params" do |
| 29 | + note.should_receive(:mount_table).with( |
| 30 | + [['Name', 'Value'], [:@action_has_layout, "true"], [:@_status, "200"]], {:summary=>"Debug information for Assigns (2)"}) |
| 31 | + note.content |
| 32 | + end |
25 | 33 | end |
0 commit comments