rspec-inherit_from_matcher 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 220c8a9299b5bd2bfcd3c3c386cf5b97b454a9b5
4
+ data.tar.gz: e2c96a85ba81afe3dfe68678e84eebfcf9336328
5
+ SHA512:
6
+ metadata.gz: 4910c7259d143c7cd4ac7e1a3256fde1f6a1c2b53ae522dd57c2203816c45c82b953e5f8b80dbf07adc8f7ae58ee6eaaf88679c6553a35e1694f2750a63998e7
7
+ data.tar.gz: 8429b389d0c9907cdd99c5610343b76ed5cdc29941971fa07ba916a362899f14a1ef0cd3425f4e4cf6f6107d7a218ac945590f24246fcf063bd09c99abbb3eb5
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ vendor
18
+ tmp
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+
3
+ script: 'rake spec'
4
+
5
+ rvm:
6
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Faraz Yashar
2
+
3
+ MIT License
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
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # RSpec Inherit From Matcher :family:
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/rspec-inherit_from_matcher.svg)](http://badge.fury.io/rb/rspec-inherit_from_matcher)
4
+ [![Build Status](https://travis-ci.org/fny/rspec-inherit_from_matcher.svg)](https://travis-ci.org/fny/rspec-inherit_from_matcher)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ group :test do
12
+ gem 'rspec-inherit_from_matcher'
13
+ end
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install rspec-inherit_from_matcher
23
+
24
+ ## Usage
25
+
26
+ ```ruby
27
+ # Setup
28
+ Parent = Class.new
29
+ Child = Class.new(Parent)
30
+
31
+ # In your examples
32
+ expect(Child).to inherit_from(Parent)
33
+ expect(Parent).not_to inherit_from(Child)
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. You can run the tests with `rake spec`
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`.
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/fny/rspec-inherit_from_matcher/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |test|
8
+ test.pattern = 'spec/**/*_spec.rb'
9
+ end
@@ -0,0 +1,16 @@
1
+ require 'rspec'
2
+
3
+ RSpec::Matchers.define :inherit_from do |superclass|
4
+ match do |klass|
5
+ klass.ancestors.include?(superclass)
6
+ end
7
+
8
+ failure_message do |klass|
9
+ "Expected #{klass} to inherit from #{superclass}. " \
10
+ "Ancestors: #{klass.ancestors}"
11
+ end
12
+
13
+ failure_message_when_negated do |klass|
14
+ "Expected #{klass} not to inherit from #{superclass}"
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.version = '1.0.0'
3
+ spec.name = 'rspec-inherit_from_matcher'
4
+ spec.authors = ["Faraz Yashar"]
5
+ spec.email = 'faraz.yashar@gmail.com'
6
+ spec.summary = 'RSpec matcher for checking whether a class inherits from another'
7
+
8
+ spec.homepage = 'https://github.com/fny/rspec-inherit_from_matcher'
9
+ spec.license = 'MIT'
10
+
11
+ spec.files = `git ls-files`.split($\)
12
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
13
+ spec.require_paths = ['lib']
14
+
15
+ spec.add_dependency 'rake'
16
+ spec.add_dependency 'bundler'
17
+ spec.add_dependency 'rspec', '>= 2.9'
18
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ Parent = Class.new
4
+ Child = Class.new(Parent)
5
+ Rock = Class.new
6
+
7
+ def expect_rspec_failure(message_or_pattern)
8
+ begin
9
+ yield
10
+ rescue RSpec::Expectations::ExpectationNotMetError => e
11
+ case message_or_pattern
12
+ when Regexp
13
+ expect(e.message).to match(message_or_pattern)
14
+ else
15
+ expect(e.message).to eq(message_or_pattern)
16
+ end
17
+ end
18
+ end
19
+
20
+ RSpec.describe "inherit from matcher" do
21
+ describe "positive check" do
22
+ it "works when the child inherits from the given parent" do
23
+ expect(Child).to inherit_from(Parent)
24
+ end
25
+ it "fails when the child does not inherit from the given parent" do
26
+ expect_rspec_failure(/Expected Rock to inherit from Parent\. Ancestors: \[Rock.*\]/) do
27
+ expect(Rock).to inherit_from(Parent)
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "negative check" do
33
+ it "works when the child does not inherit from the given parent " do
34
+ expect(Parent).not_to inherit_from(Child)
35
+ expect(Rock).not_to inherit_from(Parent)
36
+ end
37
+ it "fails when the child inherits from the given parent" do
38
+ expect_rspec_failure("Expected Child not to inherit from Parent") do
39
+ expect(Child).not_to inherit_from(Parent)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'rspec-inherit_from_matcher'
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-inherit_from_matcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Faraz Yashar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.9'
55
+ description:
56
+ email: faraz.yashar@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - ".travis.yml"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/rspec-inherit_from_matcher.rb
68
+ - rspec-inherit_from_matcher.gemspec
69
+ - spec/rspec-inherit_from_matcher/inherit_from_spec.rb
70
+ - spec/spec_helper.rb
71
+ homepage: https://github.com/fny/rspec-inherit_from_matcher
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.6
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: RSpec matcher for checking whether a class inherits from another
95
+ test_files:
96
+ - spec/rspec-inherit_from_matcher/inherit_from_spec.rb
97
+ - spec/spec_helper.rb