Sha256: 2ba9b7864c1a9fcb1120dd99b6607273ee7935b42bf292fde3c4c88afbf540f9

Contents?: true

Size: 1.82 KB

Versions: 14

Compression:

Stored size: 1.82 KB

Contents

# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require 'trenni/formatters'

module Trenni::FormattersSpec
	class TestFormatter < Trenni::Formatters::Formatter
		def initialize(*)
			@count = 0
			
			super
		end
		
		attr :count
		
		map(String) do |value, options|
			@count += 1
			
			"String: #{value}"
		end
	end
	
	describe Trenni::Formatters do
		let(:test_formatter) {TestFormatter.new(foo: :bar)}
	
		it "should format string" do
			expect(test_formatter.format("foobar")).to be == "String: foobar"
			expect(test_formatter.count).to be == 1
		end
	
		it "should format numbers" do
			expect(test_formatter.format(10)).to be == "10"
			expect(test_formatter.count).to be == 0
		end
		
		it "has options" do
			expect(test_formatter[:foo]).to be == :bar
		end
	end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
trenni-formatters-2.8.1 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.8.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.7.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.6.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.5.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.4.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.3.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.2.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.1.1 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.1.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-2.0.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-1.2.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-1.1.0 spec/trenni/formatters/formatters_spec.rb
trenni-formatters-1.0.0 spec/trenni/formatters/formatters_spec.rb