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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1a9bf838319f743f0d510c8d245a4c22a2b0a12
4
- data.tar.gz: cac3a557d43dc3e55594cacfc5452a9cc0a53ed1
3
+ metadata.gz: 48560d36649996143083b484f812383fcaa87489
4
+ data.tar.gz: 60f58615753e6ca3ce6d28282167096133aa9f82
5
5
  SHA512:
6
- metadata.gz: fc0f7ece221e305b2801bab2b8533ecce8e1fa63a9e80faf736f592d0664eaf9a19f6f5311b52a785eaa29408155c5ae0fbba7976420709c5c3bbaf5f3c6753f
7
- data.tar.gz: c26ccd336525beee3f29d9245e7e796d9c30383671813f2c375d39dc7da7904df2de1d2784fec9a568520703464bf6a2bb5f74e0df96b5a536d2f0ffe03a803a
6
+ metadata.gz: f87c4738d01ce7197f0a9185ab49d054f21034d1bed8ceabef05804525c605eb28f319502326773fe586dc21e05ead1448601a2f8d5cbf6986d6828ef4bebedd
7
+ data.tar.gz: 14b3fb92cdcec8c3a96a6d96a087a2c229a87f95411c5eb0270596dcd83040f87ecd9bcc56e25cba65aa4903a7946edebf4e2cc6f720ad38d4746c0fefaced9c
@@ -1,5 +1,10 @@
1
1
  # NDD RSpec changelog
2
2
 
3
+ ## Version 1.2.0
4
+
5
+ - Drop Jeweler
6
+ - Update matchers to newer versions of RSpec
7
+
3
8
  ## Version 1.1.2
4
9
 
5
10
  - Updated dependencies to fix security alerts
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at c_inconnu2@yahoo.fr. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 David DIDIER
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  [![Dependency Status](https://gemnasium.com/ddidier/ndd-rspec.png)](https://gemnasium.com/ddidier/ndd-rspec)
5
5
  [![Code Climate](https://codeclimate.com/github/ddidier/ndd-rspec/badges/gpa.svg)](https://codeclimate.com/github/ddidier/ndd-rspec)
6
6
  [![Test Coverage](https://codeclimate.com/github/ddidier/ndd-rspec/badges/coverage.svg)](https://codeclimate.com/github/ddidier/ndd-rspec)
7
- [![Documentation Coverage](https://inch-ci.org/github/ddidier/ndd-rspec.svg)](https://inch-ci.org/github/ddidier/ndd-rspec)
8
7
  [![Yard Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/ddidier/ndd-rspec)
8
+ [![Documentation Coverage](https://inch-ci.org/github/ddidier/ndd-rspec.svg)](https://inch-ci.org/github/ddidier/ndd-rspec)
9
9
 
10
10
  RSpec utilities.
11
11
 
@@ -13,37 +13,59 @@ The API documentation can be find at [RubyDoc](http://www.rubydoc.info/github/dd
13
13
 
14
14
  ## Prerequisites
15
15
 
16
- This gem requires RSpec 3.1 and is tested with:
16
+ This gem requires:
17
17
 
18
- - Ruby 1.9.3
19
- - Ruby 2.0.0
20
- - Ruby 2.1.x
18
+ - `rspec >= 3.0`
21
19
 
22
- ## Matchers
20
+ And is tested with:
23
21
 
24
- ### be\_sorted\_by
22
+ - `Ruby 2.4`
23
+ - `Ruby 2.3`
24
+ - `Ruby 2.2`
25
25
 
26
- ```ruby
27
- expect([1, 2, 3]).to be_sorted_by(:to_i) # => success
28
- expect([1, 3, 2]).to be_sorted_by(:to_i) # => failure
26
+ ## Installation
27
+
28
+ Add this line to your application's Gemfile:
29
29
 
30
- Duck = Struct.new(:color)
31
- expect([Duck.new('Grey'), Duck.new('White')]).to be_sorted_by(:color) } # => success
32
- expect([Duck.new('White'), Duck.new('Grey')]).to be_sorted_by(:color) } # => failure
30
+ ```ruby
31
+ gem 'ndd-rspec-rails'
33
32
  ```
34
33
 
35
- ### be\_reverse\_sorted\_by
34
+ And then execute `bundle`
35
+
36
+ Or install it yourself with `gem install ndd-rspec-rails`
37
+
38
+ ## Matchers
39
+
40
+ ### be_sorted_by
36
41
 
37
42
  ```ruby
38
- expect([3, 2, 1]).to be_reverse_sorted_by(:to_i) # => true
39
- expect([1, 3, 2]).to be_reverse_sorted_by(:to_i) # => false
43
+ expect(%w[1 2 3]).to be_sorted_by(:to_i) # => success
44
+ expect(%w[1 3 2]).to be_sorted_by(:to_i) # => failure
45
+ ```
46
+
47
+ ### be_reverse_sorted_by
40
48
 
41
- Duck = Struct.new(:color)
42
- expect([Duck.new('White'), Duck.new('Grey')]).to be_reverse_sorted_by(:color) } # => success
43
- expect([Duck.new('Grey'), Duck.new('White')]).to be_reverse_sorted_by(:color) } # => failure
49
+ ```ruby
50
+ expect(%w[3 2 1]).to be_reverse_sorted_by(:to_i) # => true
51
+ expect(%w[1 3 2]).to be_reverse_sorted_by(:to_i) # => false
44
52
  ```
45
53
 
46
- ## Copyright
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
57
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
60
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
61
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ddidier/ndd-rspec. This project is
66
+ intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
67
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
68
+
69
+ ## License
47
70
 
48
- Copyright (c) 2014 David DIDIER.
49
- See `LICENSE.txt` for further details.
71
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ndd/rspec/rails'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ APPLICATION_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
4
+
5
+ function _rubocop() {
6
+ local txt_orange='\e[38;5;214m'
7
+ local txt_reset='\e[0m'
8
+
9
+ pushd $APPLICATION_DIR > /dev/null \
10
+ && \
11
+ rubocop \
12
+ -D -R \
13
+ --format html -o tmp/rubocop.html \
14
+ --format progress \
15
+ --format offenses \
16
+ ; \
17
+ echo -e "${txt_orange}HTML report was generated at:\n file://$APPLICATION_DIR/tmp/rubocop.html${txt_reset}" \
18
+ ; \
19
+ popd > /dev/null
20
+ }
21
+
22
+ _rubocop $@
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require 'ndd/rspec/version'
2
+ require 'ndd/rspec/matchers'
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
1
  require 'ndd/rspec/matchers/be_reverse_sorted_by'
3
2
  require 'ndd/rspec/matchers/be_sorted_by'
4
3
 
5
-
6
- module RSpec::Matchers
7
- include Ndd::RSpec::Matchers
4
+ RSpec.configure do |config|
5
+ config.include Ndd::RSpec::Matchers
8
6
  end
@@ -1,68 +1,60 @@
1
- # encoding: utf-8
2
- require 'rspec/expectations'
3
-
4
-
5
1
  module Ndd
6
2
  module RSpec
7
- module Matchers
3
+ module Matchers #:nodoc:
8
4
 
9
- # Ensures that an enumerable responding to {#collect} is sorted in reverse order by the given attribute or
10
- # method return value of the objects it contains.
5
+ # Ensures that an enumerable responding to
6
+ # {https://ruby-doc.org/core/Enumerable.html#method-i-collect Enumerable#collect} is sorted in reverse order by
7
+ # the values of the given attribute or by return values of the given method.
11
8
  #
12
9
  # @example
13
- # Duck = Struct.new(:color)
14
- #
15
- # describe 'sorting' do
16
- # let(:a_pair_of_sorted_ducks) { [Duck.new('Grey'), Duck.new('White')] }
17
- # let(:a_pair_of_reverse_sorted_ducks) { [Duck.new('White'), Duck.new('Grey')] }
18
10
  #
19
- # it { expect(a_pair_of_sorted_ducks).to_not be_reverse_sorted_by(:color) }
20
- # it { expect(a_pair_of_reverse_sorted_ducks).to be_reverse_sorted_by(:color) }
21
- # end
11
+ # REVERSE_SORTED_ARRAY = ['3', '2', '1'].freeze
12
+ # UNSORTED_ARRAY = ['1', '3', '2'].freeze
22
13
  #
23
- # @param attribute [Symbol] the attribute or the method to sort with
24
- # @return [Ndd::RSpec::Matchers::BeSortedBy]
14
+ # it { expect(SORTEDREVERSE_SORTED_ARRAY_ARRAY).to be_reverse_sorted_by(:to_i) }
15
+ # it { expect(UNSORTED_ARRAY).to_not be_reverse_sorted_by(:to_i) }
25
16
  #
17
+ # @param attribute [Symbol] the attribute or the method to sort with.
18
+ # @return [Ndd::RSpec::Matchers::BeReverseSortedBy]
26
19
  def be_reverse_sorted_by(attribute)
27
20
  BeReverseSortedBy.new(attribute)
28
21
  end
29
22
 
30
- # @private
23
+ # ------------------------------------------------------------------------------------------------------------
24
+ # Implements {#be_reverse_sorted_by}.
25
+ #
31
26
  class BeReverseSortedBy
32
27
 
33
- def initialize(attribute = nil)
28
+ # @param attribute [Symbol] the attribute or the method to sort with.
29
+ def initialize(attribute)
34
30
  @attribute = attribute
35
31
  end
36
32
 
33
+ # @param actual [Object] the object being tested.
34
+ # @return [Boolean] true if the object is reverse sorted according to the given attribute, false otherwise.
37
35
  def matches?(actual)
38
36
  @actual = actual
39
37
  attributes = actual.collect { |e| e.send(@attribute) }
40
38
  @actual_attributes = attributes
41
- @sorted_attributes = attributes.sort.reverse
42
- @sorted_attributes == @actual_attributes
39
+ @expected_attributes = attributes.sort.reverse
40
+ @expected_attributes == @actual_attributes
43
41
  end
44
42
 
43
+ # @return [String] a description of this matcher.
45
44
  def description
46
- "be sorted by '#@attribute' in reverse order"
45
+ "be sorted in reverse order by '#{@attribute}'"
47
46
  end
48
47
 
48
+ # @return [String] details about the failure of this matcher.
49
49
  def failure_message
50
- return <<-MESSAGE
51
-
52
- expected '#{@actual.inspect}' to be sorted by '#@attribute' in reverse order
53
- expected attributes: #{@sorted_attributes.inspect}
54
- got attributes: #{@actual_attributes.inspect}
55
-
56
- MESSAGE
57
- end
58
-
59
- def ==(other)
60
- matches?(other)
50
+ message = ''
51
+ message << "expected '#{@actual.inspect}'to be sorted in reverse order by '#{@attribute}' but\n"
52
+ message << " expected attributes: #{@expected_attributes.inspect}\n"
53
+ message << " actual attributes: #{@actual_attributes.inspect}"
54
+ message
61
55
  end
62
56
  end
63
57
 
64
- private_constant :BeReverseSortedBy
65
-
66
58
  end
67
59
  end
68
60
  end
@@ -1,69 +1,60 @@
1
- # encoding: utf-8
2
- require 'rspec/expectations'
3
-
4
-
5
1
  module Ndd
6
2
  module RSpec
7
- module Matchers
3
+ module Matchers #:nodoc:
8
4
 
9
- # Ensures that an enumerable responding to {#collect} is sorted by the given attribute or method return value of
10
- # the objects it contains.
5
+ # Ensures that an enumerable responding to
6
+ # {https://ruby-doc.org/core/Enumerable.html#method-i-collect Enumerable#collect} is sorted by the values of
7
+ # the given attribute or by return values of the given method.
11
8
  #
12
9
  # @example
13
- # Duck = Struct.new(:color)
14
10
  #
15
- # describe 'sorting' do
16
- # let(:a_pair_of_sorted_ducks) { [Duck.new('Grey'), Duck.new('White')] }
17
- # let(:a_pair_of_reverse_sorted_ducks) { [Duck.new('White'), Duck.new('Grey')] }
11
+ # SORTED_ARRAY = ['1', '2', '3'].freeze
12
+ # UNSORTED_ARRAY = ['1', '3', '2'].freeze
18
13
  #
19
- # it { expect(a_pair_of_sorted_ducks).to be_sorted_by(:color) }
20
- # it { expect(a_pair_of_reverse_sorted_ducks).to_not be_sorted_by(:color) }
21
- # end
14
+ # it { expect(SORTED_ARRAY).to be_sorted_by(:to_i) }
15
+ # it { expect(UNSORTED_ARRAY).to_not be_sorted_by(:to_i) }
22
16
  #
23
- # @param attribute [Symbol] the attribute or the method to sort with
17
+ # @param attribute [Symbol] the attribute or the method to sort with.
24
18
  # @return [Ndd::RSpec::Matchers::BeSortedBy]
25
- #
26
19
  def be_sorted_by(attribute)
27
20
  BeSortedBy.new(attribute)
28
21
  end
29
22
 
30
-
31
- # @private
23
+ # ------------------------------------------------------------------------------------------------------------
24
+ # Implements {#be_sorted_by}.
25
+ #
32
26
  class BeSortedBy
33
27
 
34
- def initialize(attribute = nil)
28
+ # @param attribute [Symbol] the attribute or the method to sort with.
29
+ def initialize(attribute)
35
30
  @attribute = attribute
36
31
  end
37
32
 
33
+ # @param actual [Object] the object being tested.
34
+ # @return [Boolean] true if the object is sorted according to the given attribute, false otherwise.
38
35
  def matches?(actual)
39
36
  @actual = actual
40
37
  attributes = actual.collect { |e| e.send(@attribute) }
41
38
  @actual_attributes = attributes
42
- @sorted_attributes = attributes.sort
43
- @sorted_attributes == @actual_attributes
39
+ @expected_attributes = attributes.sort
40
+ @expected_attributes == @actual_attributes
44
41
  end
45
42
 
43
+ # @return [String] a description of this matcher.
46
44
  def description
47
- "be sorted by '#@attribute'"
45
+ "be sorted by '#{@attribute}'"
48
46
  end
49
47
 
48
+ # @return [String] details about the failure of this matcher.
50
49
  def failure_message
51
- return <<-MESSAGE
52
-
53
- expected '#{@actual.inspect}' to be sorted by '#@attribute'
54
- expected attributes: #{@sorted_attributes.inspect}
55
- got attributes: #{@actual_attributes.inspect}
56
-
57
- MESSAGE
58
- end
59
-
60
- def ==(other)
61
- matches?(other)
50
+ message = ''
51
+ message << "expected '#{@actual.inspect}'to be sorted by '#{@attribute}' but\n"
52
+ message << " expected attributes: #{@expected_attributes.inspect}\n"
53
+ message << " actual attributes: #{@actual_attributes.inspect}"
54
+ message
62
55
  end
63
56
  end
64
57
 
65
- private_constant :BeSortedBy
66
-
67
58
  end
68
59
  end
69
60
  end