rspec_gandalf 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +25 -0
- data/README +1 -0
- data/Rakefile +2 -0
- data/lib/matchers/gandalf.rb +68 -0
- data/lib/rspec_gandalf.rb +14 -0
- data/rspec_gandalf.gemspec +19 -0
- data/spec/rspec_gandalf/rspec_gandalf_spec.rb +21 -0
- data/spec/spec_helper.rb +3 -0
- metadata +73 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec_gandalf (0.1)
|
5
|
+
rspec (~> 2.13)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.1)
|
11
|
+
rspec (2.13.0)
|
12
|
+
rspec-core (~> 2.13.0)
|
13
|
+
rspec-expectations (~> 2.13.0)
|
14
|
+
rspec-mocks (~> 2.13.0)
|
15
|
+
rspec-core (2.13.1)
|
16
|
+
rspec-expectations (2.13.0)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.13.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
rspec
|
25
|
+
rspec_gandalf!
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Test
|
data/Rakefile
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
RSpec::Matchers.define :pass do
|
4
|
+
match do |described_object|
|
5
|
+
shall_pass?(described_object)
|
6
|
+
end
|
7
|
+
|
8
|
+
failure_message_for_should do |described_object|
|
9
|
+
if @class_ancestors_contains_balrog
|
10
|
+
"RUN YOU FOOL. You cannot trick me. \nATTENTION: #{described_object.class.name} is a flame of Udun and SHALL NOT PASS"
|
11
|
+
else
|
12
|
+
"ATTENTION: #{described_object.class.name} is a flame of Udun and SHALL NOT PASS."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
failure_message_for_should_not do |actual|
|
17
|
+
"Wow. Calm down. You aren't a Balrog and shall pass. But be warned: One does not simply shall pass the test."
|
18
|
+
end
|
19
|
+
|
20
|
+
def shall_pass?(described_object)
|
21
|
+
!is_balrog?(described_object.class)
|
22
|
+
end
|
23
|
+
|
24
|
+
def is_balrog?(described_class)
|
25
|
+
class_name_contains_balrog = !!(described_class.name.match(/balrog/i))
|
26
|
+
@class_ancestors_contains_balrog = described_class.ancestors.reduce(class_name_contains_balrog) { |mem, class_name|
|
27
|
+
(mem || !!(class_name.name.match(/balrog/i)))
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# module RSpecGandalf
|
33
|
+
# module Matchers
|
34
|
+
# class Pass
|
35
|
+
# def matches?(described_object)
|
36
|
+
# @described_class = described_object.class
|
37
|
+
# shall_pass?()
|
38
|
+
# end
|
39
|
+
|
40
|
+
# def failure_message_for_should
|
41
|
+
# if @class_ancestors_contains_balrog
|
42
|
+
# "RUN YOU FOOL. You cannot trick me. \nATTENTION: #{@described_class.name} is a flame of Udun and SHALL NOT PASS"
|
43
|
+
# else
|
44
|
+
# "ATTENTION: #{@described_class.name} is a flame of Udun and SHALL NOT PASS."
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
# def failure_message_for_should_not
|
49
|
+
# "Wow. Calm down. You aren't a Balrog and shall pass. But be warned: One does not simply shall pass the test."
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def shall_pass?
|
53
|
+
# !is_balrog?()
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def is_balrog?
|
57
|
+
# class_name_contains_balrog = !!(@described_class.name.match(/balrog/i))
|
58
|
+
# @class_ancestors_contains_balrog = @described_class.ancestors.reduce(class_name_contains_balrog) { |mem, class_name|
|
59
|
+
# (mem || !!(class_name.name.match(/balrog/i)))
|
60
|
+
# }
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
|
64
|
+
# def pass
|
65
|
+
# Pass.new
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
# end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Vinícius Oyama"]
|
5
|
+
gem.email = ["vinicius.oyama@gmail.com"]
|
6
|
+
gem.platform = Gem::Platform::RUBY
|
7
|
+
gem.description = %q{Bad tests shall not pass!}
|
8
|
+
gem.summary = %q{One does not simply pass the tests!}
|
9
|
+
gem.homepage = "https://github.com/codus/rest_api"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rspec_gandalf"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = "0.1"
|
17
|
+
|
18
|
+
gem.add_dependency('rspec', '~> 2.13')
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
class Balrog;end;
|
6
|
+
|
7
|
+
class Men;end;
|
8
|
+
|
9
|
+
class Hobbit;end;
|
10
|
+
|
11
|
+
class TrollRog < Balrog;end;
|
12
|
+
|
13
|
+
class PretaGil < Balrog;end;
|
14
|
+
|
15
|
+
describe Hobbit do
|
16
|
+
it { shall pass }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe PretaGil do
|
20
|
+
it { shall pass }
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_gandalf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Vinícius Oyama
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.13'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.13'
|
30
|
+
description: Bad tests shall not pass!
|
31
|
+
email:
|
32
|
+
- vinicius.oyama@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- Gemfile.lock
|
40
|
+
- README
|
41
|
+
- Rakefile
|
42
|
+
- lib/matchers/gandalf.rb
|
43
|
+
- lib/rspec_gandalf.rb
|
44
|
+
- rspec_gandalf.gemspec
|
45
|
+
- spec/rspec_gandalf/rspec_gandalf_spec.rb
|
46
|
+
- spec/spec_helper.rb
|
47
|
+
homepage: https://github.com/codus/rest_api
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.25
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: One does not simply pass the tests!
|
71
|
+
test_files:
|
72
|
+
- spec/rspec_gandalf/rspec_gandalf_spec.rb
|
73
|
+
- spec/spec_helper.rb
|