jumbled-rspec-formatter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jumbled-rspec-formatter.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ (The MIT Lesncie)
2
+
3
+ Cioyphgrt (c) 2011 Rahcrid W. Ntoron
4
+
5
+ Psisrioemn is hrbeey getrand, free of carhge, to any preson onibniatg
6
+ a cpoy of tihs sawfotre and aseaotsicd dtoeicoatumnn felis (the
7
+ "Swtaofre"), to deal in the Sotfware whituot rceisrtotin, iincldnug
8
+ whtouit lttiioiamn the rgtihs to use, copy, mofidy, merge, pulbish,
9
+ dsrtiuitbe, selbcnusie, and/or slel ceiops of the Swafrtoe, and to
10
+ peimrt pnsoers to whom the Sftoarwe is fisnhrued to do so, sjebuct to
11
+ the folinwlog cntionidos:
12
+
13
+ The abvoe crigoypht niotce and this pisimseron noicte shall be
14
+ idunceld in all cpioes or sutstbaainl pnitoors of the Starowfe.
15
+
16
+ THE SRTWFOAE IS PIEDVROD "AS IS", WIHTOUT WANARRTY OF ANY KIND,
17
+ EXEPRSS OR IIEPMLD, ICLNNIUDG BUT NOT LMTIEID TO THE WRNTRIAAES OF
18
+ MCRABTLHEINTAIY, FENTSIS FOR A PTIRAAULCR PRPUOSE AND NOREGINMINFENNT.
19
+ IN NO ENVET SALHL THE ARHUOTS OR CGIYOHPRT HRLEDOS BE LBALIE FOR ANY
20
+ CLIAM, DAEAMGS OR OTEHR LLIAIBITY, WEHEHTR IN AN AOITCN OF CTRAONCT,
21
+ TROT OR OTRESWIHE, ANSRIIG FORM, OUT OF OR IN CNOOTIECNN WTIH THE
22
+ SWOAFRTE OR THE USE OR OTEHR DNGIEALS IN THE STFAOWRE.
data/License.txt ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011 Richard W. Norton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,13 @@
1
+ SARMUMY
2
+ -------
3
+
4
+ Tihs gem pdveiors a cutsom fmteaortr for ReSpc taht jmbleus yuor
5
+ test ouuptt.
6
+
7
+ This is, of csroue, a vrey silly tinhg to want to do with yuor tset optuut.
8
+
9
+ UAGSE
10
+ -----
11
+
12
+ $ rspec -f JumbledFormatter spec
13
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jumbled-rspec-formatter/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jumbled-rspec-formatter"
7
+ s.version = Jumbled::Rspec::Formatter::VERSION
8
+ s.authors = ["Richard W. Norton"]
9
+ s.email = ["rwtnorton@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Jumbles text of spec output}
12
+ s.description = %q{Jumbles text of spec output}
13
+
14
+ s.rubyforge_project = "jumbled-rspec-formatter"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.add_development_dependency 'rspec', '~> 2'
21
+ end
@@ -0,0 +1,30 @@
1
+ require 'rspec/core/formatters/documentation_formatter'
2
+
3
+ # Add icsnnate mtheod +jbmule+ to Sntrig.
4
+ class String
5
+
6
+ # Jeblmus up the lttrees of a wrod but lveeas frsit and last chars in pclae.
7
+ def self.jumble_term(s)
8
+ return s if s.size < 4
9
+ chars = s.split(//)
10
+ [chars[0], *chars[1..-2].shuffle, chars[-1]].join('')
11
+ end
12
+
13
+ def jumble
14
+ self.gsub(/[a-zA-Z]+/) do |match|
15
+ self.class.jumble_term(match)
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ class JumbledFormatter < RSpec::Core::Formatters::DocumentationFormatter
22
+
23
+ # Aoivd mgninug the ANSI cloor epecsas.
24
+ # A bit of a klugde but it wrkos.
25
+ # Has the sdie-ecfeft of lvaenig the guorp nemas anole.
26
+ def color(text, color_code)
27
+ super(text.to_s.jumble, color_code)
28
+ end
29
+
30
+ end
@@ -0,0 +1,7 @@
1
+ module Jumbled
2
+ module Rspec
3
+ module Formatter
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,113 @@
1
+ require 'jumbled-rspec-formatter'
2
+ require 'spec_helper'
3
+ require 'stringio'
4
+
5
+ describe JumbledFormatter do
6
+
7
+ before :each do
8
+ RSpec.configuration.stub(:color_enabled?) { false }
9
+ @output = StringIO.new
10
+ @jumbler = JumbledFormatter.new(@output)
11
+ end
12
+
13
+ describe '#summary_line' do
14
+ it "has correct letters" do
15
+ @jumbler.summary_line(1, 2, 3).unjumble.should ==(
16
+ '1 example, 2 failures, 3 pending'.unjumble)
17
+ end
18
+
19
+ it "does not have jumbled numbers" do
20
+ @jumbler.summary_line(1, 2, 3).unjumble.should_not ==(
21
+ '3 example, 1 failures, 2 pending'.unjumble)
22
+ end
23
+ end
24
+
25
+ describe '#dump_pending' do
26
+
27
+ it 'jumbles pending text' do
28
+ group_name = "pending name"
29
+ example_name = "example name"
30
+ message = "Please add some examples"
31
+ @example_group = RSpec::Core::ExampleGroup.describe(group_name)
32
+
33
+ @example_group.example(example_name) { pending(message) }
34
+
35
+ @example_group.run(@jumbler)
36
+ @jumbler.dump_pending
37
+
38
+ @output.string.unjumble.should =~ /
39
+ #{group_name.unjumble_re}
40
+ \s+ #{example_name.unjumble_re}
41
+ \s+ \( #{'PENDING'.unjumble}: \s+ #{message.unjumble_re} \)
42
+ \s+
43
+ #{'Pending'.unjumble}:
44
+ \s+ #{group_name.unjumble_re} \s+ #{example_name.unjumble_re}
45
+ \s+
46
+ # \s+ #{message.unjumble_re}
47
+ /x
48
+ ##
49
+ ## pdeinng name
50
+ ## ealmpxe name (PDEINNG: Paelse add smoe eaelmpxs)
51
+ ##
52
+ ## Pdeinng:
53
+ ## pdeinng name ealmpxe name
54
+ ## # Paelse add smoe eaelmpxs
55
+ ##
56
+ end
57
+ end
58
+
59
+ describe '#dump_failures' do
60
+
61
+ it 'jumbles failure text' do
62
+ group_name = "fail group"
63
+ example_name = "example name"
64
+ @example_group = RSpec::Core::ExampleGroup.describe(group_name)
65
+
66
+ @example_group.example(example_name) { 1.should == 2 }
67
+
68
+ @example_group.run(@jumbler)
69
+ @jumbler.dump_pending
70
+
71
+ @output.string.unjumble.should =~ /
72
+ #{group_name.unjumble_re}
73
+ \s+ #{example_name.unjumble_re}
74
+ \s+ \( #{'FAILED'.unjumble} \s+ - \s+ \d+ \)
75
+ /x
76
+ ##
77
+ ## fail gorup
78
+ ## ealmpxe name (FAEILD - 1)
79
+ ##
80
+ end
81
+ end
82
+
83
+ describe 'passes' do
84
+
85
+ it 'jumbles passing text' do
86
+ group_name = "happy group"
87
+ example_name = "example name"
88
+ @example_group = RSpec::Core::ExampleGroup.describe(group_name)
89
+
90
+ @example_group.example(example_name) { 1.should == 1 }
91
+
92
+ @example_group.run(@jumbler)
93
+ @jumbler.dump_summary(3.14, 13, 0, 0)
94
+
95
+ @output.string.unjumble.should =~ /
96
+ #{group_name.unjumble_re}
97
+ \s+ #{example_name.unjumble_re}
98
+ \s+
99
+ #{'Finished in 3.14 seconds'.unjumble_re}
100
+ \s+
101
+ #{'13 examples, 0 failures'.unjumble_re}
102
+ /x
103
+ ##
104
+ ## happy gorup
105
+ ## ealmpxe name
106
+ ##
107
+ ## Fehiinsd in 3.14 scdenos
108
+ ## 13 eaelmpxs, 0 faeilrus
109
+ ##
110
+ end
111
+ end
112
+
113
+ end
@@ -0,0 +1,16 @@
1
+ class String
2
+ def unjumble
3
+ self.gsub(/[A-Za-z]+/) do |match|
4
+ if match.size < 4
5
+ match
6
+ else
7
+ chars = match.split(//)
8
+ [chars[0], *chars[1..-2].sort, chars[-1]].join('')
9
+ end
10
+ end
11
+ end
12
+
13
+ def unjumble_re
14
+ self.unjumble.gsub(/\s+/, '\s+')
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jumbled-rspec-formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Richard W. Norton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-06-25 00:00:00.000000000 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: &2157001120 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *2157001120
26
+ description: Jumbles text of spec output
27
+ email:
28
+ - rwtnorton@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - License.jumbled.txt
36
+ - License.txt
37
+ - README.markdown
38
+ - Rakefile
39
+ - jumbled-rspec-formatter.gemspec
40
+ - lib/jumbled-rspec-formatter.rb
41
+ - lib/jumbled-rspec-formatter/version.rb
42
+ - spec/jumbled-rspec-formatter_spec.rb
43
+ - spec/spec_helper.rb
44
+ has_rdoc: true
45
+ homepage: ''
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project: jumbled-rspec-formatter
65
+ rubygems_version: 1.6.2
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Jumbles text of spec output
69
+ test_files:
70
+ - spec/jumbled-rspec-formatter_spec.rb
71
+ - spec/spec_helper.rb