Sha256: 843753389d94fc286806b72a45a3fa777443f3e6086e02a08456064cfa85addf

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Clamp::Messages do

  describe "message" do
    before do
      Clamp.messages = {
        :too_many_arguments => "Way too many!",
        :custom_message => "Say %<what>s to %<whom>s"
      }
    end

    after do
      Clamp.clear_messages!
    end

    it "allows setting custom messages" do
      expect(Clamp.message(:too_many_arguments)).to eql "Way too many!"
    end

    it "fallbacks to a default message" do
      expect(Clamp.message(:no_value_provided)).to eql "no value provided"
    end

    it "formats the message" do
      expect(Clamp.message(:custom_message, :what => "hello", :whom => "Clamp")).to eql "Say hello to Clamp"
    end
  end

  describe "clear_messages!" do
    it "clears messages to the defualt state" do
      default_msg = Clamp.message(:too_many_arguments).clone

      Clamp.messages = {
        :too_many_arguments => "Way too many!"
      }
      Clamp.clear_messages!

      expect(Clamp.message(:too_many_arguments)).to eql default_msg
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clamp-1.0.1 spec/clamp/messages_spec.rb
clamp-1.0.0 spec/clamp/messages_spec.rb