expect 0.0.2 → 0.0.3

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: 196b5411407e208dbba2fe80b60bf3b2d2e767ae
4
- data.tar.gz: d79477542f1a4934baae487d1708f8b888c23d17
3
+ metadata.gz: 141ff12063684e2c83f94cd8d5fab2861a1da524
4
+ data.tar.gz: 34ec01c10edba6adf3bd80c7e0e8b8a4644bd36e
5
5
  SHA512:
6
- metadata.gz: acf79eb71e06e2c271700abff218cdd40aca177a88b2bb907c714da6be4359a40672c154435e8f69f2a8bc1a0ada013eba6cc4f5b04881e5c310e5cbee9313a3
7
- data.tar.gz: dee3899421ea045243d32d4875a9a751275c87f2a393ad0bcb213a3a2ff867a70835e2267df875b0ee62b69f7031625e017a0b6ec59c23a8a3ea79dc69d7fdb7
6
+ metadata.gz: 7e479246ea6e28a30666dbd0016359fa091e9d0f761df95b37045652ca47c589f7eb12a5c8be80b55d8a56c42b7bfa8d136926d435c075479d96ba215305294f
7
+ data.tar.gz: 9652669e2da0d3738c045511767ec5058f0afa7cafc8b3836eefb869d35d004c86043ef4c88c70631a42574e0ae8ff26bf5a5c5ff06ac888135660a627745229
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
@@ -1,3 +1,19 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ script: 'bundle exec rake test:coverage --trace'
5
+ before_install:
6
+ - gem install bundler
2
7
  rvm:
3
- - 2.2.0
8
+ - ree
9
+ - 1.8.7
10
+ - 1.9.2
11
+ - 1.9.3
12
+ - 2.0
13
+ - 2.1
14
+ - 2.2
15
+ - ruby-head
16
+ - jruby-18mode
17
+ - jruby
18
+ - jruby-head
19
+ - rbx-2
@@ -0,0 +1 @@
1
+ - README.md
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'rubysl-irb' if RUBY_ENGINE.eql?('rbx')
data/README.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # Expect
2
2
 
3
- Expectation library with some built-in matchers for Ruby.
3
+ [![Build Status](https://travis-ci.org/fixrb/expect.svg?branch=master)](https://travis-ci.org/fixrb/expect)
4
+ [![Dependency Status](https://gemnasium.com/fixrb/expect.svg)](https://gemnasium.com/fixrb/expect)
5
+ [![Gem Version](http://img.shields.io/gem/v/expect.svg)](https://rubygems.org/gems/expect)
6
+ [![Inline docs](http://inch-ci.org/github/fixrb/expect.svg?branch=master)](http://inch-ci.org/github/fixrb/expect)
7
+ [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)](http://rubydoc.info/gems/expect/frames)
8
+
9
+ > Expectation library with some built-in matchers for Ruby.
10
+
11
+ ## Contact
12
+
13
+ * Home page: https://github.com/fixrb/expect
14
+ * Bugs/issues: https://github.com/fixrb/expect/issues
15
+ * Support: https://stackoverflow.com/questions/tagged/expect
16
+
17
+ ## Rubies
18
+
19
+ * [MRI](https://www.ruby-lang.org/)
20
+ * [Rubinius](http://rubini.us/)
21
+ * [JRuby](http://jruby.org/)
4
22
 
5
23
  ## Installation
6
24
 
@@ -18,11 +36,35 @@ Or install it yourself as:
18
36
 
19
37
  $ gem install expect
20
38
 
21
- ## Development
39
+ ## Usage
40
+
41
+ **Equivalence** expectation:
42
+
43
+ ```ruby
44
+ Expect.this { 'foo' }.to eql: 'foo' # => true
45
+ ```
46
+
47
+ **Identity** expectation:
48
+
49
+ ```ruby
50
+ Expect.this { :foo }.to equal: :foo # => true
51
+ ```
52
+
53
+ **Regular expressions** expectation:
54
+
55
+ ```ruby
56
+ Expect.this { 'foo' }.to match: /^foo$/ # => true
57
+ ```
58
+
59
+ **Expecting errors** expectation:
60
+
61
+ ```ruby
62
+ Expect.this { Boom }.to raise_exception: NameError # => true
63
+ ```
22
64
 
23
- 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.
65
+ ## Versioning
24
66
 
25
- To install this gem onto your local machine, run `bundle exec rake install`.
67
+ __Expect__ follows [Semantic Versioning 2.0](http://semver.org/).
26
68
 
27
69
  ## Contributing
28
70
 
data/Rakefile CHANGED
@@ -1 +1,18 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = File.join 'test', '**', 'test_*.rb'
6
+ t.verbose = true
7
+ t.warning = true
8
+ end
9
+
10
+ namespace :test do
11
+ task :coverage do
12
+ ENV['COVERAGE'] = 'true'
13
+ Rake::Task['test'].invoke
14
+ end
15
+ end
16
+
17
+ task(:doc_stats) { ruby '-S yard stats' }
18
+ task default: [:test, :doc_stats]
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -3,12 +3,5 @@
3
3
  require 'bundler/setup'
4
4
  require 'expect'
5
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
6
  require 'irb'
14
7
  IRB.start
data/bin/setup CHANGED
@@ -3,5 +3,3 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
5
  bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -4,19 +4,21 @@ Gem::Specification.new do |spec|
4
4
  spec.authors = ['Cyril Wack']
5
5
  spec.email = ['contact@cyril.email']
6
6
 
7
- # if spec.respond_to?(:metadata)
8
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
9
- # end
10
-
11
7
  spec.summary = 'Expectation library.'
12
8
  spec.description = 'Expectation library with some matchers for Ruby.'
13
9
  spec.homepage = 'https://github.com/fixrb/expect'
14
10
  spec.license = 'MIT'
15
11
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
12
+ spec.files = `git ls-files -z`.split("\x0")
13
+ .reject { |f| f.match(/^test\//) }
14
+ spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
18
15
  spec.require_paths = ['lib']
19
16
 
20
- spec.add_development_dependency 'bundler', '~> 1.8'
21
- spec.add_development_dependency 'rake', '~> 10.0'
17
+ spec.add_dependency 'matchi', '~> 0.0.1'
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.8'
20
+ spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_development_dependency 'yard', '~> 0.8'
22
+ spec.add_development_dependency 'simplecov', '~> 0.9.1'
23
+ spec.add_development_dependency 'rubocop', '~> 0.29'
22
24
  end
@@ -9,7 +9,7 @@ module Expect
9
9
  # @api public
10
10
  #
11
11
  # @example Duck example
12
- # expect { 42 }.to equal: 42 # => true
12
+ # this { 42 }.to equal: 42 # => true
13
13
  #
14
14
  # @return [ExpectationTarget] the expectation target.
15
15
  def self.this(&input)
@@ -4,7 +4,7 @@ module Expect
4
4
  # Wraps the target of an expectation.
5
5
  #
6
6
  # @example
7
- # expect { do_something } # => ExpectationTarget wrapping the block
7
+ # this { stuff } # => ExpectationTarget wrapping the block
8
8
  class ExpectationTarget < BasicObject
9
9
  def initialize(&actual)
10
10
  @actual = actual
@@ -16,7 +16,7 @@ module Expect
16
16
  #
17
17
  # @see Matcher#pass?
18
18
  def to(definition)
19
- Matcher.pass? false, definition, &@actual
19
+ Matcher.pass?(false, definition, &@actual)
20
20
  end
21
21
 
22
22
  # Evaluate to a negative assertion.
@@ -25,7 +25,7 @@ module Expect
25
25
  #
26
26
  # @see Matcher#pass?
27
27
  def not_to(definition)
28
- Matcher.pass? true, definition, &@actual
28
+ Matcher.pass?(true, definition, &@actual)
29
29
  end
30
30
  end
31
31
  end
@@ -1,3 +1,5 @@
1
+ require 'matchi'
2
+
1
3
  module Expect
2
4
  # This module provides matchers to define expectations.
3
5
  module Matcher
@@ -11,7 +13,7 @@ module Expect
11
13
  params = Array(definition).flatten 1
12
14
  name = params.first
13
15
  expected_args = params[1..-1]
14
- matcher = Matcher.get(name).new(*expected_args)
16
+ matcher = get(name).new(*expected_args)
15
17
 
16
18
  negated ^ matcher.matches?(&actual)
17
19
  end
@@ -22,11 +24,7 @@ module Expect
22
24
  #
23
25
  # Matcher.get(:eql) # => Eql
24
26
  def self.get(name)
25
- const_get name.to_s.split('_').map(&:capitalize).join.to_sym
27
+ Matchi.const_get name.to_s.split('_').map(&:capitalize).join.to_sym
26
28
  end
27
29
  end
28
30
  end
29
-
30
- Dir[File.join File.dirname(__FILE__), 'matcher', '*.rb'].each do |filename|
31
- require_relative filename
32
- end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: matchi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,48 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.29'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.29'
41
97
  description: Expectation library with some matchers for Ruby.
42
98
  email:
43
99
  - contact@cyril.email
@@ -46,8 +102,8 @@ extensions: []
46
102
  extra_rdoc_files: []
47
103
  files:
48
104
  - ".gitignore"
49
- - ".ruby-version"
50
105
  - ".travis.yml"
106
+ - ".yardopts"
51
107
  - CODE_OF_CONDUCT.md
52
108
  - Gemfile
53
109
  - LICENSE.md
@@ -56,15 +112,10 @@ files:
56
112
  - VERSION.semver
57
113
  - bin/console
58
114
  - bin/setup
59
- - expect-0.0.1.gem
60
115
  - expect.gemspec
61
116
  - lib/expect.rb
62
117
  - lib/expect/expectation_target.rb
63
118
  - lib/expect/matcher.rb
64
- - lib/expect/matcher/eql.rb
65
- - lib/expect/matcher/equal.rb
66
- - lib/expect/matcher/match.rb
67
- - lib/expect/matcher/raise_exception.rb
68
119
  homepage: https://github.com/fixrb/expect
69
120
  licenses:
70
121
  - MIT
@@ -90,3 +141,4 @@ signing_key:
90
141
  specification_version: 4
91
142
  summary: Expectation library.
92
143
  test_files: []
144
+ has_rdoc:
@@ -1 +0,0 @@
1
- 2.2.0
Binary file
@@ -1,15 +0,0 @@
1
- module Expect
2
- module Matcher
3
- # Provides the implementation for `eql`.
4
- class Eql < BasicObject
5
- def initialize(expected)
6
- @expected = expected
7
- end
8
-
9
- # @return [Boolean] Comparison between actual and expected values.
10
- def matches?
11
- @expected.eql?(yield)
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Expect
2
- module Matcher
3
- # Provides the implementation for `equal`.
4
- class Equal < BasicObject
5
- def initialize(expected)
6
- @expected = expected
7
- end
8
-
9
- # @return [Boolean] Comparison between actual and expected values.
10
- def matches?
11
- @expected.equal? yield
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Expect
2
- module Matcher
3
- # Provides the implementation for `match`.
4
- class Match < BasicObject
5
- def initialize(expected)
6
- @expected = expected
7
- end
8
-
9
- # @return [Boolean] Comparison between actual and expected values.
10
- def matches?
11
- !@expected.match(yield).nil?
12
- end
13
- end
14
- end
15
- end
@@ -1,21 +0,0 @@
1
- module Expect
2
- module Matcher
3
- # Provides the implementation for `raise_exception`.
4
- class RaiseException < BasicObject
5
- def initialize(expected)
6
- @expected = expected
7
- end
8
-
9
- # @return [Boolean] Comparison between actual and expected values.
10
- def matches?
11
- begin
12
- yield
13
- rescue @expected
14
- true
15
- else
16
- false
17
- end
18
- end
19
- end
20
- end
21
- end