Sha256: f6edf98962562215052435ca61d13b09738c4eea29ddb94013ddbe35d103a86f

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper_lite'
require 'leadlight/tint'

module Leadlight
  describe Tint do    
    subject { target.extend(Tint.new(:test_tint, options, &definition)) }
    let(:definition) {
      ->(*args) do
        self.tint_applied!
      end
    }
    let(:target) { Target.new }
    let(:status) { 200 }
    let(:response) { stub(:status => status) }
    let(:options) { {} }

    class Target
      def __apply_tint__
      end
    end

    def apply
      subject.__apply_tint__
    end

    before do
      target.stub(:__response__ => response)
    end

    context "with a successful status" do
      it "is applied" do
        target.should_receive(:tint_applied!)
        apply
      end
    end

    context "with an unsuccessful status" do
      let(:status) { 401 }

      it "is not applied" do
        target.should_not_receive(:tint_applied!)
        apply
      end
    end

    context "with a custom status guard" do
      before do
        options[:status] = 401
      end

      context "with a non-matching status" do
        it "is not applied" do
          target.should_not_receive(:tint_applied!)
          apply
        end
      end

      context "with an matching status" do
        let(:status) { 401 }

        it "is applied" do
          target.should_receive(:tint_applied!)
          apply
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
leadlight-0.1.0 spec/leadlight/tint_spec.rb
leadlight-0.0.7 spec/leadlight/tint_spec.rb
leadlight-0.0.6 spec/leadlight/tint_spec.rb
leadlight-0.0.5 spec/leadlight/tint_spec.rb
leadlight-0.0.4 spec/leadlight/tint_spec.rb
leadlight-0.0.3 spec/leadlight/tint_spec.rb