Sha256: 2de8120d49240ed4183a4557868e7e7771bac61d5a97c3de1b11e8777eae327d

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require "spec_helper"
require 'action_controller'
require "rails-footnotes/notes/assigns_note"

describe Footnotes::Notes::AssignsNote do
  let(:note) do
    @controller = double
    @controller.stub(:instance_variables).and_return([:@action_has_layout, :@status])
    @controller.instance_variable_set(:@action_has_layout, true)
    @controller.instance_variable_set(:@status, 200)
    Footnotes::Notes::AssignsNote.new(@controller)
  end
  subject {note}

  before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = []}

  it {should be_valid}
  its(:title) {should eql 'Assigns (2)'}

  specify {note.send(:assigns).should eql [:@action_has_layout, :@status]}
  specify {note.send(:to_table).should eql [['Name', 'Value'], [:@action_has_layout, "true"], [:@status, "200"]]}

  describe "Ignored Assigns" do
    before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = [:@status]}
    it {note.send(:assigns).should_not include :@status}
  end

  describe "Ignored Assigns by regexp" do
    before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns_pattern = /^@status$/}
    it {note.send(:assigns).should_not include :@status}
  end

  it "should call #mount_table method with correct params" do
    note.should_receive(:mount_table).with(
      [['Name', 'Value'], [:@action_has_layout, "true"], [:@status, "200"]], {:summary=>"Debug information for Assigns (2)"})
    note.content
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-footnotes-4.0.2 spec/notes/assigns_note_spec.rb
rails-footnotes-4.0.1 spec/notes/assigns_note_spec.rb
rails-footnotes-4.0.0 spec/notes/assigns_note_spec.rb