Sha256: 88f9c27504da742a83e4c7e4695072ab48ad88cbba9232f0d43baed8bcda382e

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

require "rails_helper"

describe MagicLamp::RenderCatcher do
  subject { MagicLamp::RenderCatcher.new(MagicLamp::Configuration.new) }

  it { is_expected.to be_kind_of(MagicLamp::Callbacks) }

  context "attr_accessor" do
    it { is_expected.to attr_accessorize :render_argument }
  end

  describe "#render" do
    it "saves its first arguments as render argument" do
      subject.render :foo, :bar, :baz
      expect(subject.render_argument).to eq(:foo)
    end
  end

  describe "#first_render_argument" do
    let(:block) { proc { render :foo, :bar, :baz } }
    let(:result) { subject.first_render_argument(&block) }

    it "returns the first argument to render given a block" do
      expect(result).to eq(:foo)
    end

    it "executes callbacks around the evaluation of the block" do
      expect(subject).to receive(:execute_before_each_callback).ordered
      expect(subject).to receive(:instance_eval).ordered
      expect(subject).to receive(:execute_after_each_callback).ordered
      subject.first_render_argument { render :foo }
    end
  end

  describe "#method_missing" do
    it "does nothing when an unknown method is called" do
      expect do
        subject.foo
        subject.foo = "what"
        subject.bar(1, 2, 3) { |x| "never gonna happen" }
      end.to_not raise_error
    end

    it "returns itself" do
      expect(subject.foo.bar.baz).to eq(subject)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
magic_lamp-1.5.0 spec/lib/render_catcher_spec.rb
magic_lamp-1.4.1 spec/lib/render_catcher_spec.rb
magic_lamp-1.4.0 spec/lib/render_catcher_spec.rb
magic_lamp-1.3.1 spec/lib/render_catcher_spec.rb
magic_lamp-1.3.0 spec/lib/render_catcher_spec.rb
magic_lamp-1.2.0 spec/lib/render_catcher_spec.rb
magic_lamp-1.1.1 spec/lib/render_catcher_spec.rb
magic_lamp-1.1.0 spec/lib/render_catcher_spec.rb