ndd-rspec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +40 -0
- data/Gemfile.lock +78 -0
- data/Guardfile +45 -0
- data/LICENSE.txt +20 -0
- data/README.md +37 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/ndd/rspec/matchers/be_reverse_sorted_by.rb +48 -0
- data/lib/ndd/rspec/matchers/be_sorted_by.rb +48 -0
- data/lib/ndd/rspec/matchers.rb +19 -0
- data/spec/ndd/rspec/matchers/be_reverse_sorted_by_spec.rb +39 -0
- data/spec/ndd/rspec/matchers/be_sorted_by_spec.rb +39 -0
- data/spec/ndd/rspec/matchers/shared_examples.rb +19 -0
- data/spec/spec_helper.rb +68 -0
- metadata +259 -0
data/.document
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
HOST_OS = RbConfig::CONFIG['host_os']
|
4
|
+
|
5
|
+
|
6
|
+
# ------------------------------------------------------------------------------
|
7
|
+
# Dependencies required to use the gem.
|
8
|
+
gem 'rspec', '~> 2.11.0'
|
9
|
+
|
10
|
+
|
11
|
+
# ------------------------------------------------------------------------------
|
12
|
+
# Dependencies to develop the gem.
|
13
|
+
# Everything needed to run rake, tests, features, etc.
|
14
|
+
group :development do
|
15
|
+
gem 'bundler', '~> 1.2.0'
|
16
|
+
gem 'guard', '~> 1.5.0'
|
17
|
+
gem 'guard-bundler', '~> 1.0.0'
|
18
|
+
gem 'guard-rspec', '~> 2.1.0'
|
19
|
+
gem 'guard-spork', '~> 1.2.0'
|
20
|
+
gem 'jeweler', '~> 1.8.4'
|
21
|
+
gem 'rdoc', '~> 3.12'
|
22
|
+
gem 'rspec', '~> 2.11.0'
|
23
|
+
gem 'simplecov', '~> 0.7.0', :require => false
|
24
|
+
|
25
|
+
case HOST_OS
|
26
|
+
when /darwin/i
|
27
|
+
gem 'growl'
|
28
|
+
gem 'rb-fsevent'
|
29
|
+
when /linux/i
|
30
|
+
gem 'libnotify'
|
31
|
+
gem 'rb-inotify'
|
32
|
+
when /mswin|windows/i
|
33
|
+
gem 'rb-fchange'
|
34
|
+
gem 'rb-notifu'
|
35
|
+
gem 'win32console'
|
36
|
+
else
|
37
|
+
raise "Platform '#{HOST_OS}' is not supported"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
childprocess (0.3.6)
|
5
|
+
ffi (~> 1.0, >= 1.0.6)
|
6
|
+
coderay (1.0.8)
|
7
|
+
diff-lcs (1.1.3)
|
8
|
+
ffi (1.1.5)
|
9
|
+
git (1.2.5)
|
10
|
+
guard (1.5.0)
|
11
|
+
listen (>= 0.4.2)
|
12
|
+
lumberjack (>= 1.0.2)
|
13
|
+
pry (>= 0.9.10)
|
14
|
+
thor (>= 0.14.6)
|
15
|
+
guard-bundler (1.0.0)
|
16
|
+
bundler (~> 1.0)
|
17
|
+
guard (~> 1.1)
|
18
|
+
guard-rspec (2.1.0)
|
19
|
+
guard (>= 1.1)
|
20
|
+
rspec (~> 2.11)
|
21
|
+
guard-spork (1.2.1)
|
22
|
+
childprocess (>= 0.2.3)
|
23
|
+
guard (>= 1.1)
|
24
|
+
spork (>= 0.8.4)
|
25
|
+
sys-proctable
|
26
|
+
jeweler (1.8.4)
|
27
|
+
bundler (~> 1.0)
|
28
|
+
git (>= 1.2.5)
|
29
|
+
rake
|
30
|
+
rdoc
|
31
|
+
json (1.7.5)
|
32
|
+
libnotify (0.8.0)
|
33
|
+
ffi (>= 1.0.11)
|
34
|
+
listen (0.5.3)
|
35
|
+
lumberjack (1.0.2)
|
36
|
+
method_source (0.8.1)
|
37
|
+
multi_json (1.3.6)
|
38
|
+
pry (0.9.10)
|
39
|
+
coderay (~> 1.0.5)
|
40
|
+
method_source (~> 0.8)
|
41
|
+
slop (~> 3.3.1)
|
42
|
+
rake (0.9.2.2)
|
43
|
+
rb-inotify (0.8.8)
|
44
|
+
ffi (>= 0.5.0)
|
45
|
+
rdoc (3.12)
|
46
|
+
json (~> 1.4)
|
47
|
+
rspec (2.11.0)
|
48
|
+
rspec-core (~> 2.11.0)
|
49
|
+
rspec-expectations (~> 2.11.0)
|
50
|
+
rspec-mocks (~> 2.11.0)
|
51
|
+
rspec-core (2.11.1)
|
52
|
+
rspec-expectations (2.11.3)
|
53
|
+
diff-lcs (~> 1.1.3)
|
54
|
+
rspec-mocks (2.11.3)
|
55
|
+
simplecov (0.7.1)
|
56
|
+
multi_json (~> 1.0)
|
57
|
+
simplecov-html (~> 0.7.1)
|
58
|
+
simplecov-html (0.7.1)
|
59
|
+
slop (3.3.3)
|
60
|
+
spork (0.9.2)
|
61
|
+
sys-proctable (0.9.2)
|
62
|
+
thor (0.16.0)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
bundler (~> 1.2.0)
|
69
|
+
guard (~> 1.5.0)
|
70
|
+
guard-bundler (~> 1.0.0)
|
71
|
+
guard-rspec (~> 2.1.0)
|
72
|
+
guard-spork (~> 1.2.0)
|
73
|
+
jeweler (~> 1.8.4)
|
74
|
+
libnotify
|
75
|
+
rb-inotify
|
76
|
+
rdoc (~> 3.12)
|
77
|
+
rspec (~> 2.11.0)
|
78
|
+
simplecov (~> 0.7.0)
|
data/Guardfile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
4
|
+
|
5
|
+
|
6
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
7
|
+
# bundler
|
8
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
9
|
+
|
10
|
+
guard 'bundler' do
|
11
|
+
watch('Gemfile')
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
16
|
+
# spork (must be before rspec and cucumber)
|
17
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
18
|
+
|
19
|
+
guard 'spork',
|
20
|
+
:wait => 60 do
|
21
|
+
|
22
|
+
watch('Gemfile')
|
23
|
+
watch('Gemfile.lock')
|
24
|
+
|
25
|
+
# ----- spec directory
|
26
|
+
watch('spec/spec_helper.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
31
|
+
# rspec
|
32
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
33
|
+
|
34
|
+
guard 'rspec',
|
35
|
+
:all_after_pass => false,
|
36
|
+
:all_on_start => false,
|
37
|
+
:cli => '--colour --drb --format documentation --tag focused' do
|
38
|
+
|
39
|
+
# ----- lib directory
|
40
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| %W(spec/#{m[1]}_spec.rb) }
|
41
|
+
|
42
|
+
# ----- spec directory
|
43
|
+
watch(%r{^spec/.+_spec\.rb$})
|
44
|
+
watch(%r{^spec/support/(.+)\.rb$}) { %W(spec) }
|
45
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
+
NONINFRINGEMENT. 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/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# NDD-RSpec
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/ddidier/ndd-rspec.png)](http://travis-ci.org/ddidier/ndd-rspec)
|
4
|
+
[![Dependency Status](https://gemnasium.com/ddidier/ndd-rspec.png)](https://gemnasium.com/ddidier/ndd-rspec)
|
5
|
+
|
6
|
+
RSpec utilities.
|
7
|
+
|
8
|
+
## Matchers
|
9
|
+
|
10
|
+
### be\_sorted\_by
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
[1, 2, 3].should be_sorted_by(:to_i) # => true
|
14
|
+
[1, 3, 2].should be_sorted_by(:to_i) # => false
|
15
|
+
```
|
16
|
+
|
17
|
+
### be\_reverse\_sorted\_by
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
[3, 2, 1].should be_reverse_sorted_by(:to_i) # => true
|
21
|
+
[1, 3, 2].should be_reverse_sorted_by(:to_i) # => false
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing to ndd-rspec
|
25
|
+
|
26
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
27
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
28
|
+
* Fork the project.
|
29
|
+
* Start a feature/bugfix branch.
|
30
|
+
* Commit and push until you are happy with your contribution.
|
31
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
32
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version,
|
33
|
+
or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
34
|
+
|
35
|
+
## Copyright
|
36
|
+
|
37
|
+
Copyright (c) 2012 David DIDIER. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
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... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ndd-rspec"
|
18
|
+
gem.homepage = "http://github.com/ddidier/ndd-rspec"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{RSpec utilities}
|
21
|
+
gem.description = %Q{RSpec utilities}
|
22
|
+
gem.email = "c_inconnu2@yahoo.fr"
|
23
|
+
gem.authors = ["David DIDIER"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "address_picker-rails #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rspec/expectations'
|
3
|
+
require 'rspec/expectations/differ'
|
4
|
+
|
5
|
+
|
6
|
+
module Ndd
|
7
|
+
module RSpec
|
8
|
+
module Matchers
|
9
|
+
|
10
|
+
# ----------------------------------------------------------------------------------------------------------------
|
11
|
+
# Ensures that an enumerable (responding to <code>Enumerable#collect</code>) is sorted by the given attribute in reverse order
|
12
|
+
#
|
13
|
+
# Examples:
|
14
|
+
# [MyObject.new(my_attribute: 2), MyObject.new(my_attribute: 1)].should be_reverse_sorted_by(:my_attribute) }
|
15
|
+
#
|
16
|
+
class BeReverseSortedBy
|
17
|
+
|
18
|
+
def initialize(attribute = nil)
|
19
|
+
@attribute = attribute
|
20
|
+
end
|
21
|
+
|
22
|
+
def matches?(actual)
|
23
|
+
@actual = actual
|
24
|
+
attributes = actual.collect { |e| e.send(@attribute) }
|
25
|
+
@actual_attributes = attributes
|
26
|
+
@sorted_attributes = attributes.sort.reverse
|
27
|
+
@sorted_attributes == @actual_attributes
|
28
|
+
end
|
29
|
+
|
30
|
+
def failure_message_for_should
|
31
|
+
return <<-MESSAGE
|
32
|
+
|
33
|
+
expected '#{@actual.inspect}' to be sorted by '#@attribute' in reverse order
|
34
|
+
expected attributes: #{@sorted_attributes.inspect}
|
35
|
+
got attributes: #{@actual_attributes.inspect}
|
36
|
+
|
37
|
+
MESSAGE
|
38
|
+
end
|
39
|
+
|
40
|
+
def ==(other)
|
41
|
+
matches?(other)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rspec/expectations'
|
3
|
+
require 'rspec/expectations/differ'
|
4
|
+
|
5
|
+
|
6
|
+
module Ndd
|
7
|
+
module RSpec
|
8
|
+
module Matchers
|
9
|
+
|
10
|
+
# ----------------------------------------------------------------------------------------------------------------
|
11
|
+
# Ensures that an enumerable (responding to <code>Enumerable#collect</code>) is sorted by the given attribute.
|
12
|
+
#
|
13
|
+
# Examples:
|
14
|
+
# [MyObject.new(my_attribute: 1), MyObject.new(my_attribute: 2)].should be_sorted_by(:my_attribute) }
|
15
|
+
#
|
16
|
+
class BeSortedBy
|
17
|
+
|
18
|
+
def initialize(attribute = nil)
|
19
|
+
@attribute = attribute
|
20
|
+
end
|
21
|
+
|
22
|
+
def matches?(actual)
|
23
|
+
@actual = actual
|
24
|
+
attributes = actual.collect { |e| e.send(@attribute) }
|
25
|
+
@actual_attributes = attributes
|
26
|
+
@sorted_attributes = attributes.sort
|
27
|
+
@sorted_attributes == @actual_attributes
|
28
|
+
end
|
29
|
+
|
30
|
+
def failure_message_for_should
|
31
|
+
return <<-MESSAGE
|
32
|
+
|
33
|
+
expected '#{@actual.inspect}' to be sorted by '#@attribute'
|
34
|
+
expected attributes: #{@sorted_attributes.inspect}
|
35
|
+
got attributes: #{@actual_attributes.inspect}
|
36
|
+
|
37
|
+
MESSAGE
|
38
|
+
end
|
39
|
+
|
40
|
+
def ==(other)
|
41
|
+
matches?(other)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative 'matchers/be_reverse_sorted_by'
|
3
|
+
require_relative 'matchers/be_sorted_by'
|
4
|
+
|
5
|
+
module Ndd
|
6
|
+
module RSpec
|
7
|
+
module Matchers
|
8
|
+
|
9
|
+
def be_reverse_sorted_by(attribute)
|
10
|
+
BeReverseSortedBy.new(attribute)
|
11
|
+
end
|
12
|
+
|
13
|
+
def be_sorted_by(attribute)
|
14
|
+
BeSortedBy.new(attribute)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'ndd/rspec/matchers'
|
4
|
+
require 'ndd/rspec/matchers/shared_examples'
|
5
|
+
|
6
|
+
|
7
|
+
describe "be reverse sorted by", { :type => 'matcher' } do
|
8
|
+
|
9
|
+
REVERSE_SORTED_ARRAY = [3, 2, 1].freeze
|
10
|
+
UNSORTED_ARRAY = [1, 3, 2].freeze
|
11
|
+
|
12
|
+
it_behaves_like "an RSpec matcher",
|
13
|
+
:valid_value => REVERSE_SORTED_ARRAY,
|
14
|
+
:invalid_value => UNSORTED_ARRAY do
|
15
|
+
let(:matcher) { be_reverse_sorted_by(:to_i) }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "matches when actual is sorted according to the given attribute in reverse order" do
|
19
|
+
REVERSE_SORTED_ARRAY.should be_reverse_sorted_by(:to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does not match when actual is not sorted according to the given attribute in reverse order" do
|
23
|
+
UNSORTED_ARRAY.should_not be_reverse_sorted_by(:to_i)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "provides message on #failure_message" do
|
27
|
+
matcher = be_reverse_sorted_by(:to_i)
|
28
|
+
matcher.matches?(UNSORTED_ARRAY)
|
29
|
+
|
30
|
+
matcher.failure_message_for_should.should == <<-MESSAGE
|
31
|
+
|
32
|
+
expected '[1, 3, 2]' to be sorted by 'to_i' in reverse order
|
33
|
+
expected attributes: [3, 2, 1]
|
34
|
+
got attributes: [1, 3, 2]
|
35
|
+
|
36
|
+
MESSAGE
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'ndd/rspec/matchers'
|
4
|
+
require 'ndd/rspec/matchers/shared_examples'
|
5
|
+
|
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
|
+
it "matches when actual is sorted according to the given attribute" do
|
19
|
+
SORTED_ARRAY.should be_sorted_by(:to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does not match when actual is not sorted according to the given attribute" do
|
23
|
+
UNSORTED_ARRAY.should_not be_sorted_by(:to_i)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "provides message on #failure_message" do
|
27
|
+
matcher = be_sorted_by(:to_i)
|
28
|
+
matcher.matches?(UNSORTED_ARRAY)
|
29
|
+
|
30
|
+
matcher.failure_message_for_should.should == <<-MESSAGE
|
31
|
+
|
32
|
+
expected '[1, 3, 2]' to be sorted by 'to_i'
|
33
|
+
expected attributes: [1, 2, 3]
|
34
|
+
got attributes: [1, 3, 2]
|
35
|
+
|
36
|
+
MESSAGE
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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
|
+
it 'matches a valid value when using #== so it can be composed' do
|
10
|
+
expect(matcher).to eq(valid_value)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'does not match an invalid value when using #== so it can be composed' do
|
14
|
+
expect(matcher).not_to eq(invalid_value)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'spork'
|
4
|
+
|
5
|
+
|
6
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
7
|
+
# Spork prefork
|
8
|
+
# Loading more in this block will cause your tests to run faster. However, if you change any
|
9
|
+
# configuration or code from libraries loaded here, you'll need to restart spork for it take effect.
|
10
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
Spork.prefork do
|
13
|
+
|
14
|
+
# ----- code coverage
|
15
|
+
|
16
|
+
if ENV["COVERAGE"] and not ENV['DRB']
|
17
|
+
require 'simplecov'
|
18
|
+
SimpleCov.start
|
19
|
+
end
|
20
|
+
|
21
|
+
# ----- requirements
|
22
|
+
|
23
|
+
require 'rspec'
|
24
|
+
require 'ndd/rspec/matchers'
|
25
|
+
|
26
|
+
|
27
|
+
# ----- RSpec configuration
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
|
31
|
+
config.mock_with :rspec
|
32
|
+
|
33
|
+
# ----- filters
|
34
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
35
|
+
config.alias_example_to :fit, :focused
|
36
|
+
config.fail_fast = false
|
37
|
+
config.filter_run :focused
|
38
|
+
config.run_all_when_everything_filtered = true
|
39
|
+
|
40
|
+
# ----- libraries
|
41
|
+
# Ndd-RSpec
|
42
|
+
config.include Ndd::RSpec::Matchers, :type => :matcher
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
49
|
+
# Spork each_run
|
50
|
+
# This code will be run each time you run your specs.
|
51
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
52
|
+
|
53
|
+
Spork.each_run do
|
54
|
+
|
55
|
+
# ----- code coverage
|
56
|
+
|
57
|
+
if ENV["COVERAGE"] and not ENV['DRB']
|
58
|
+
require 'simplecov'
|
59
|
+
SimpleCov.start
|
60
|
+
end
|
61
|
+
|
62
|
+
# ----- files reload
|
63
|
+
lib_path = File.expand_path('../../lib', __FILE__)
|
64
|
+
Dir["#{lib_path}/**/*.rb"].each do |file|
|
65
|
+
load file
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ndd-rspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David DIDIER
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-24 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.11.0
|
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.11.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.2.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.2.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.5.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.5.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: guard-bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: guard-rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.1.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.1.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: guard-spork
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.2.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.0
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: jeweler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.8.4
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.8.4
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rdoc
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '3.12'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '3.12'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rspec
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 2.11.0
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.11.0
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: simplecov
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 0.7.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.7.0
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: libnotify
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: rb-inotify
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
description: RSpec utilities
|
207
|
+
email: c_inconnu2@yahoo.fr
|
208
|
+
executables: []
|
209
|
+
extensions: []
|
210
|
+
extra_rdoc_files:
|
211
|
+
- LICENSE.txt
|
212
|
+
- README.md
|
213
|
+
files:
|
214
|
+
- .document
|
215
|
+
- .travis.yml
|
216
|
+
- CHANGELOG.md
|
217
|
+
- Gemfile
|
218
|
+
- Gemfile.lock
|
219
|
+
- Guardfile
|
220
|
+
- LICENSE.txt
|
221
|
+
- README.md
|
222
|
+
- Rakefile
|
223
|
+
- VERSION
|
224
|
+
- lib/ndd/rspec/matchers.rb
|
225
|
+
- lib/ndd/rspec/matchers/be_reverse_sorted_by.rb
|
226
|
+
- lib/ndd/rspec/matchers/be_sorted_by.rb
|
227
|
+
- spec/ndd/rspec/matchers/be_reverse_sorted_by_spec.rb
|
228
|
+
- spec/ndd/rspec/matchers/be_sorted_by_spec.rb
|
229
|
+
- spec/ndd/rspec/matchers/shared_examples.rb
|
230
|
+
- spec/spec_helper.rb
|
231
|
+
homepage: http://github.com/ddidier/ndd-rspec
|
232
|
+
licenses:
|
233
|
+
- MIT
|
234
|
+
post_install_message:
|
235
|
+
rdoc_options: []
|
236
|
+
require_paths:
|
237
|
+
- lib
|
238
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
239
|
+
none: false
|
240
|
+
requirements:
|
241
|
+
- - ! '>='
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
segments:
|
245
|
+
- 0
|
246
|
+
hash: 3507608324869974558
|
247
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
|
+
none: false
|
249
|
+
requirements:
|
250
|
+
- - ! '>='
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '0'
|
253
|
+
requirements: []
|
254
|
+
rubyforge_project:
|
255
|
+
rubygems_version: 1.8.24
|
256
|
+
signing_key:
|
257
|
+
specification_version: 3
|
258
|
+
summary: RSpec utilities
|
259
|
+
test_files: []
|