ndd-rspec 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE +21 -0
- data/README.md +44 -22
- data/bin/console +14 -0
- data/bin/rubocop +22 -0
- data/bin/setup +8 -0
- data/lib/ndd/rspec.rb +2 -0
- data/lib/ndd/rspec/matchers.rb +2 -4
- data/lib/ndd/rspec/matchers/be_reverse_sorted_by.rb +27 -35
- data/lib/ndd/rspec/matchers/be_sorted_by.rb +26 -35
- data/lib/ndd/rspec/version.rb +5 -0
- metadata +53 -84
- data/.document +0 -5
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -17
- data/Gemfile +0 -45
- data/Gemfile.lock +0 -142
- data/Guardfile +0 -38
- data/LICENSE.txt +0 -20
- data/Rakefile +0 -51
- data/VERSION +0 -1
- data/ndd-rspec.gemspec +0 -97
- data/spec/ndd/rspec/matchers/be_reverse_sorted_by_spec.rb +0 -56
- data/spec/ndd/rspec/matchers/be_sorted_by_spec.rb +0 -55
- data/spec/ndd/rspec/matchers/duck.rb +0 -2
- data/spec/ndd/rspec/matchers/shared_examples.rb +0 -21
- data/spec/spec_helper.rb +0 -77
data/Guardfile
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
|
2
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
3
|
-
# bundler
|
4
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
5
|
-
|
6
|
-
guard 'bundler' do
|
7
|
-
watch('Gemfile')
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
12
|
-
# spork (must be before rspec and cucumber)
|
13
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
14
|
-
|
15
|
-
guard 'spork',
|
16
|
-
wait: 60 do
|
17
|
-
|
18
|
-
watch('Gemfile')
|
19
|
-
watch('Gemfile.lock')
|
20
|
-
|
21
|
-
# ----- spec directory
|
22
|
-
watch('spec/spec_helper.rb')
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
27
|
-
# rspec
|
28
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
29
|
-
|
30
|
-
guard :rspec, cmd: 'bundle exec rspec' do
|
31
|
-
|
32
|
-
# ----- lib directory
|
33
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| %W(spec/#{m[1]}_spec.rb) }
|
34
|
-
|
35
|
-
# ----- spec directory
|
36
|
-
watch(%r{^spec/.+_spec\.rb$})
|
37
|
-
watch(%r{^spec/support/(.+)\.rb$}) { %W(spec) }
|
38
|
-
end
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 David DIDIER
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts 'Run `bundle install` to install missing gems'
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification...
|
17
|
-
# see http://guides.rubygems.org/specification-reference/ for more options
|
18
|
-
gem.name = 'ndd-rspec'
|
19
|
-
gem.homepage = 'http://github.com/ddidier/ndd-rspec'
|
20
|
-
gem.license = 'MIT'
|
21
|
-
gem.summary = 'RSpec utilities'
|
22
|
-
gem.description = 'RSpec utilities'
|
23
|
-
gem.email = 'c_inconnu2@yahoo.fr'
|
24
|
-
gem.authors = ['David DIDIER']
|
25
|
-
# dependencies defined in Gemfile
|
26
|
-
end
|
27
|
-
Jeweler::RubygemsDotOrgTasks.new
|
28
|
-
|
29
|
-
require 'rspec/core'
|
30
|
-
require 'rspec/core/rake_task'
|
31
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'Code coverage detail'
|
36
|
-
task :simplecov do
|
37
|
-
ENV['COVERAGE'] = 'true'
|
38
|
-
Rake::Task['spec'].execute
|
39
|
-
end
|
40
|
-
|
41
|
-
task :default => :spec
|
42
|
-
|
43
|
-
require 'rdoc/task'
|
44
|
-
Rake::RDocTask.new do |rdoc|
|
45
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
-
|
47
|
-
rdoc.rdoc_dir = 'rdoc'
|
48
|
-
rdoc.title = "NDD RSpec #{version}"
|
49
|
-
rdoc.rdoc_files.include('README*')
|
50
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.1.2
|
data/ndd-rspec.gemspec
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ndd-rspec 1.1.2 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "ndd-rspec"
|
9
|
-
s.version = "1.1.2"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["David DIDIER"]
|
14
|
-
s.date = "2016-01-08"
|
15
|
-
s.description = "RSpec utilities"
|
16
|
-
s.email = "c_inconnu2@yahoo.fr"
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt",
|
19
|
-
"README.md"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".ruby-gemset",
|
24
|
-
".ruby-version",
|
25
|
-
".travis.yml",
|
26
|
-
"CHANGELOG.md",
|
27
|
-
"Gemfile",
|
28
|
-
"Gemfile.lock",
|
29
|
-
"Guardfile",
|
30
|
-
"LICENSE.txt",
|
31
|
-
"README.md",
|
32
|
-
"Rakefile",
|
33
|
-
"VERSION",
|
34
|
-
"lib/ndd/rspec/matchers.rb",
|
35
|
-
"lib/ndd/rspec/matchers/be_reverse_sorted_by.rb",
|
36
|
-
"lib/ndd/rspec/matchers/be_sorted_by.rb",
|
37
|
-
"ndd-rspec.gemspec",
|
38
|
-
"spec/ndd/rspec/matchers/be_reverse_sorted_by_spec.rb",
|
39
|
-
"spec/ndd/rspec/matchers/be_sorted_by_spec.rb",
|
40
|
-
"spec/ndd/rspec/matchers/duck.rb",
|
41
|
-
"spec/ndd/rspec/matchers/shared_examples.rb",
|
42
|
-
"spec/spec_helper.rb"
|
43
|
-
]
|
44
|
-
s.homepage = "http://github.com/ddidier/ndd-rspec"
|
45
|
-
s.licenses = ["MIT"]
|
46
|
-
s.rubygems_version = "2.5.0"
|
47
|
-
s.summary = "RSpec utilities"
|
48
|
-
|
49
|
-
if s.respond_to? :specification_version then
|
50
|
-
s.specification_version = 4
|
51
|
-
|
52
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
-
s.add_runtime_dependency(%q<rspec>, ["~> 3.3"])
|
54
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.10"])
|
55
|
-
s.add_development_dependency(%q<guard>, ["~> 2.13"])
|
56
|
-
s.add_development_dependency(%q<guard-bundler>, ["~> 2.0"])
|
57
|
-
s.add_development_dependency(%q<guard-rspec>, ["~> 4.6"])
|
58
|
-
s.add_development_dependency(%q<guard-spork>, ["~> 2.0"])
|
59
|
-
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
60
|
-
s.add_development_dependency(%q<rdoc>, ["~> 4.1"])
|
61
|
-
s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
|
62
|
-
s.add_development_dependency(%q<spork>, ["~> 0.9"])
|
63
|
-
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
64
|
-
s.add_development_dependency(%q<libnotify>, [">= 0"])
|
65
|
-
s.add_development_dependency(%q<rb-inotify>, [">= 0"])
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<rspec>, ["~> 3.3"])
|
68
|
-
s.add_dependency(%q<bundler>, ["~> 1.10"])
|
69
|
-
s.add_dependency(%q<guard>, ["~> 2.13"])
|
70
|
-
s.add_dependency(%q<guard-bundler>, ["~> 2.0"])
|
71
|
-
s.add_dependency(%q<guard-rspec>, ["~> 4.6"])
|
72
|
-
s.add_dependency(%q<guard-spork>, ["~> 2.0"])
|
73
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
74
|
-
s.add_dependency(%q<rdoc>, ["~> 4.1"])
|
75
|
-
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
76
|
-
s.add_dependency(%q<spork>, ["~> 0.9"])
|
77
|
-
s.add_dependency(%q<yard>, ["~> 0.8"])
|
78
|
-
s.add_dependency(%q<libnotify>, [">= 0"])
|
79
|
-
s.add_dependency(%q<rb-inotify>, [">= 0"])
|
80
|
-
end
|
81
|
-
else
|
82
|
-
s.add_dependency(%q<rspec>, ["~> 3.3"])
|
83
|
-
s.add_dependency(%q<bundler>, ["~> 1.10"])
|
84
|
-
s.add_dependency(%q<guard>, ["~> 2.13"])
|
85
|
-
s.add_dependency(%q<guard-bundler>, ["~> 2.0"])
|
86
|
-
s.add_dependency(%q<guard-rspec>, ["~> 4.6"])
|
87
|
-
s.add_dependency(%q<guard-spork>, ["~> 2.0"])
|
88
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
89
|
-
s.add_dependency(%q<rdoc>, ["~> 4.1"])
|
90
|
-
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
91
|
-
s.add_dependency(%q<spork>, ["~> 0.9"])
|
92
|
-
s.add_dependency(%q<yard>, ["~> 0.8"])
|
93
|
-
s.add_dependency(%q<libnotify>, [">= 0"])
|
94
|
-
s.add_dependency(%q<rb-inotify>, [">= 0"])
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'ndd/rspec/matchers'
|
4
|
-
require 'ndd/rspec/matchers/shared_examples'
|
5
|
-
require_relative 'duck'
|
6
|
-
|
7
|
-
|
8
|
-
describe 'be reverse sorted by', {:type => 'matcher'} do
|
9
|
-
|
10
|
-
REVERSE_SORTED_ARRAY = [3, 2, 1].freeze
|
11
|
-
REVERSE_UNSORTED_ARRAY = [1, 3, 2].freeze
|
12
|
-
|
13
|
-
it_behaves_like 'an RSpec matcher',
|
14
|
-
:valid_value => REVERSE_SORTED_ARRAY,
|
15
|
-
:invalid_value => REVERSE_UNSORTED_ARRAY do
|
16
|
-
let(:matcher) { be_reverse_sorted_by(:to_i) }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when the actual is sorted according to the given attribute in reverse order' do
|
20
|
-
it { expect(REVERSE_SORTED_ARRAY).to be_reverse_sorted_by(:to_i) }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'when the actual is not sorted according to the given attribute in reverse order' do
|
24
|
-
it { expect(REVERSE_UNSORTED_ARRAY).to_not be_reverse_sorted_by(:to_i) }
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'describes itself' do
|
28
|
-
matcher = be_reverse_sorted_by(:to_i)
|
29
|
-
matcher.matches?(REVERSE_SORTED_ARRAY)
|
30
|
-
expect(matcher.description).to eq("be sorted by 'to_i' in reverse order")
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'provides message on #failure_message' do
|
34
|
-
matcher = be_reverse_sorted_by(:to_i)
|
35
|
-
matcher.matches?(REVERSE_UNSORTED_ARRAY)
|
36
|
-
|
37
|
-
expect(matcher.failure_message).to eq <<-MESSAGE
|
38
|
-
|
39
|
-
expected '[1, 3, 2]' to be sorted by 'to_i' in reverse order
|
40
|
-
expected attributes: [3, 2, 1]
|
41
|
-
got attributes: [1, 3, 2]
|
42
|
-
|
43
|
-
MESSAGE
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'documentation' do
|
47
|
-
describe 'sorting' do
|
48
|
-
let(:a_pair_of_sorted_ducks) { [Duck.new('Grey'), Duck.new('White')] }
|
49
|
-
let(:a_pair_of_reverse_sorted_ducks) { [Duck.new('White'), Duck.new('Grey')] }
|
50
|
-
|
51
|
-
it { expect(a_pair_of_sorted_ducks).to_not be_reverse_sorted_by(:color) }
|
52
|
-
it { expect(a_pair_of_reverse_sorted_ducks).to be_reverse_sorted_by(:color) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'ndd/rspec/matchers'
|
4
|
-
require 'ndd/rspec/matchers/shared_examples'
|
5
|
-
require_relative 'duck'
|
6
|
-
|
7
|
-
describe 'be sorted by', {:type => 'matcher'} do
|
8
|
-
|
9
|
-
SORTED_ARRAY = [1, 2, 3].freeze
|
10
|
-
UNSORTED_ARRAY = [1, 3, 2].freeze
|
11
|
-
|
12
|
-
it_behaves_like 'an RSpec matcher',
|
13
|
-
:valid_value => SORTED_ARRAY,
|
14
|
-
:invalid_value => UNSORTED_ARRAY do
|
15
|
-
let(:matcher) { be_sorted_by(:to_i) }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when the actual is sorted according to the given attribute' do
|
19
|
-
it { expect(SORTED_ARRAY).to be_sorted_by(:to_i) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when the actual is not sorted according to the given attribute' do
|
23
|
-
it { expect(UNSORTED_ARRAY).to_not be_sorted_by(:to_i) }
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'describes itself' do
|
27
|
-
matcher = be_sorted_by(:to_i)
|
28
|
-
matcher.matches?(SORTED_ARRAY)
|
29
|
-
expect(matcher.description).to eq("be sorted by 'to_i'")
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'provides message on #failure_message' do
|
33
|
-
matcher = be_sorted_by(:to_i)
|
34
|
-
matcher.matches?(UNSORTED_ARRAY)
|
35
|
-
|
36
|
-
expect(matcher.failure_message).to eq <<-MESSAGE
|
37
|
-
|
38
|
-
expected '[1, 3, 2]' to be sorted by 'to_i'
|
39
|
-
expected attributes: [1, 2, 3]
|
40
|
-
got attributes: [1, 3, 2]
|
41
|
-
|
42
|
-
MESSAGE
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'documentation' do
|
46
|
-
describe 'sorting' do
|
47
|
-
let(:a_pair_of_sorted_ducks) { [Duck.new('Grey'), Duck.new('White')] }
|
48
|
-
let(:a_pair_of_reverse_sorted_ducks) { [Duck.new('White'), Duck.new('Grey')] }
|
49
|
-
|
50
|
-
it { expect(a_pair_of_sorted_ducks).to be_sorted_by(:color) }
|
51
|
-
it { expect(a_pair_of_reverse_sorted_ducks).to_not be_sorted_by(:color) }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
shared_examples_for 'an RSpec matcher' do |options|
|
5
|
-
|
6
|
-
let(:valid_value) { options.fetch(:valid_value) }
|
7
|
-
let(:invalid_value) { options.fetch(:invalid_value) }
|
8
|
-
|
9
|
-
context 'when using #== so it can be composed' do
|
10
|
-
it 'matches a valid value' do
|
11
|
-
expect(matcher).to eq(valid_value)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'does not match an invalid value' do
|
15
|
-
expect(matcher).not_to eq(invalid_value)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
data/spec/spec_helper.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'codeclimate-test-reporter'
|
3
|
-
CodeClimate::TestReporter.start
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'spork'
|
7
|
-
|
8
|
-
|
9
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
10
|
-
# Spork prefork
|
11
|
-
# Loading more in this block will cause your tests to run faster. However, if you change any
|
12
|
-
# configuration or code from libraries loaded here, you'll need to restart spork for it take effect.
|
13
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
14
|
-
|
15
|
-
lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
|
-
spec_dir = File.dirname(__FILE__)
|
17
|
-
|
18
|
-
Spork.prefork do
|
19
|
-
|
20
|
-
# ----- load path
|
21
|
-
|
22
|
-
$LOAD_PATH.unshift(lib_path)
|
23
|
-
$LOAD_PATH.unshift(spec_dir)
|
24
|
-
|
25
|
-
# ----- code coverage
|
26
|
-
|
27
|
-
if ENV['COVERAGE'] and not ENV['DRB']
|
28
|
-
require 'simplecov'
|
29
|
-
SimpleCov.start 'test_frameworks'
|
30
|
-
end
|
31
|
-
|
32
|
-
# ----- requirements
|
33
|
-
|
34
|
-
require 'rspec'
|
35
|
-
require 'ndd/rspec/matchers'
|
36
|
-
|
37
|
-
# ----- RSpec configuration
|
38
|
-
|
39
|
-
RSpec.configure do |config|
|
40
|
-
|
41
|
-
config.mock_with :rspec
|
42
|
-
|
43
|
-
# ----- filters
|
44
|
-
config.alias_example_to :fit, :focused
|
45
|
-
config.filter_run_including :focused
|
46
|
-
config.order = 'random'
|
47
|
-
config.run_all_when_everything_filtered = true
|
48
|
-
config.expect_with :rspec do |c|
|
49
|
-
c.syntax = :expect
|
50
|
-
end
|
51
|
-
|
52
|
-
# ----- libraries
|
53
|
-
config.include Ndd::RSpec::Matchers, :type => :matcher
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
60
|
-
# Spork each_run
|
61
|
-
# This code will be run each time you run your specs.
|
62
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
63
|
-
|
64
|
-
Spork.each_run do
|
65
|
-
|
66
|
-
# ----- code coverage
|
67
|
-
|
68
|
-
# if ENV['COVERAGE'] and not ENV['DRB']
|
69
|
-
# require 'simplecov'
|
70
|
-
# SimpleCov.start 'test_frameworks'
|
71
|
-
# end
|
72
|
-
|
73
|
-
# ----- files reload
|
74
|
-
Dir["#{lib_path}/**/*.rb"].each { |file| require file }
|
75
|
-
Dir["#{spec_dir}/support/**/*.rb"].each { |file| require file }
|
76
|
-
|
77
|
-
end
|