minitest-spec-expect 0.1.2 → 0.1.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: ff92ff300afa1d4005dd94914c098b074d4b5e91
4
- data.tar.gz: 2c0a4cfca88016906215e09a09884e43cd20192e
3
+ metadata.gz: 0506523fe0fda5d2761cad8fc13b9170f8fcc280
4
+ data.tar.gz: 32312015cdedf8a8c762c6ada818bae0e015914f
5
5
  SHA512:
6
- metadata.gz: eeb435785170703cdd0236bcb88dda6a0853851f896b26512f4e51b5a37c250ff3ebaba18bc23211d106123289f408f64dd925d550673ac157695a58237708be
7
- data.tar.gz: fac496dbe5636621c52452eeb509e67d9f5c6589b1ae6d2a04a9f40b5228f302cc41d2ca1e72c0ad93139518e72e4fd9bcbb27f026e09243580e3a8ba8d642a4
6
+ metadata.gz: fa05b677c8e4575ce61a4dce51247b3d80f8141a622672d05cf84e75e9948697564c9c6b9879eda66c9eb7074433c128a0d8e5653ded107251650fe7f4e45db0
7
+ data.tar.gz: 5fa64d45f1c8deedfd1892b87ea3a5e564a8deeee1078c7a9f6ca81d4c84d1f4e8ba186cff45e6415156cd92ea814a55a1900d705af274e619315f5b23e1eb6c
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  *.gem
2
+ Gemfile.lock
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.2
3
4
  - 1.9.3
4
5
  - 2.0.0
5
6
  - rbx-19mode
6
7
  - jruby-19mode
7
- script: rake
8
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/davejachimiak/minitest-spec-expect.png?branch=master)](https://travis-ci.org/davejachimiak/minitest-spec-expect)
4
4
 
5
- Expect syntax for [MiniTest](http://docs.seattlerb.org/minitest/index.html). Made out of love for
6
- both rspec2's expect syntax and MiniTest's lightweight feel.
5
+ Expect syntax for [Minitest](http://docs.seattlerb.org/minitest/index.html). Made out of love for
6
+ both rspec2's expect syntax and Minitest's lightweight feel.
7
7
  ## Install
8
8
  In your Gemfile:
9
9
  ```ruby
@@ -17,8 +17,15 @@ Then require it in the file that you require `minitest/autorun`:
17
17
  ```ruby
18
18
  require 'minitest/spec/expect'
19
19
  ```
20
+ minitest-spec-expect works in the following ruby versions and implementations:
21
+ * 1.9.2
22
+ * 1.9.3
23
+ * 2.0.0
24
+ * JRuby
25
+ * Rubinius
26
+
20
27
  ## Usage
21
- Wrap the object under test in an `expect()` object. Then call a MiniTest expectation on it,
28
+ Wrap the object under test in an `expect()` object. Then call a Minitest expectation on it,
22
29
  substituting `must` and `wont` with `to` and `to_not`.
23
30
 
24
31
  For example:
@@ -50,7 +57,7 @@ describe Integer do
50
57
  end
51
58
  ```
52
59
  ## API
53
- Please see the MiniTest [expectation](http://docs.seattlerb.org/minitest/Minitest/Expectations.html)
60
+ Please see the Minitest [expectation](http://docs.seattlerb.org/minitest/Minitest/Expectations.html)
54
61
  docs for details on corresponding `must_*` and `wont_*` methods.
55
62
  ### `#*be`
56
63
  ```ruby
@@ -1,7 +1,9 @@
1
1
  module Kernel
2
+ NO_ARG = Object.new
3
+
2
4
  def expect arg=NO_ARG, &block
3
5
  raise_errors arg, block
4
- MiniTest::Spec::Expect.create arg, &block
6
+ Minitest::Spec::Expect.create arg, &block
5
7
  end
6
8
 
7
9
  private
@@ -13,22 +15,20 @@ module Kernel
13
15
  raise ArgumentError, 'cannot handle both an argument and a block' if block
14
16
  end
15
17
  end
16
-
17
- NO_ARG = Object.new
18
18
  end
19
19
 
20
- require 'minitest/spec'
20
+ require 'minitest/autorun'
21
21
 
22
- class MiniTest::Spec::Expect
22
+ class Minitest::Spec::Expect
23
23
  OBJECT_UNDER_TEST = 'object'
24
24
 
25
25
  attr_reader OBJECT_UNDER_TEST
26
26
 
27
- class_eval <<-EOM
27
+ class_eval <<-CODE
28
28
  def initialize #{OBJECT_UNDER_TEST}
29
29
  @#{OBJECT_UNDER_TEST} = #{OBJECT_UNDER_TEST}
30
30
  end
31
- EOM
31
+ CODE
32
32
 
33
33
  def self.create arg, &block
34
34
  block ? ForBlock.new(block) : ForArg.new(arg)
@@ -36,11 +36,11 @@ class MiniTest::Spec::Expect
36
36
 
37
37
  class ForArg < self
38
38
  require 'minitest/spec/expect_syntax_for_arg'
39
- MiniTest::Spec::ExpectSyntaxForArg.new(self).set_expectations
39
+ Minitest::Spec::ExpectSyntaxForArg.new(self).set_expectations
40
40
  end
41
41
 
42
42
  class ForBlock < self
43
43
  require 'minitest/spec/expect_syntax_for_block'
44
- MiniTest::Spec::ExpectSyntaxForBlock.new(self).set_expectations
44
+ Minitest::Spec::ExpectSyntaxForBlock.new(self).set_expectations
45
45
  end
46
46
  end
@@ -1,9 +1,7 @@
1
- class MiniTest::Spec::ExpectSyntax
2
- TRANSPOSITIONS = { 'must' => 'to', 'wont' => 'to_not' }
1
+ class Minitest::Spec::ExpectSyntax
2
+ TRANSPOSITIONS = { 'must' => 'to', 'wont' => 'to_not' }
3
3
  TRANSPOSITION_REGEXP = Regexp.union TRANSPOSITIONS.keys
4
4
 
5
- attr_reader :expect_class
6
-
7
5
  def initialize expect_class
8
6
  @expect_class = expect_class
9
7
  end
@@ -20,21 +18,25 @@ class MiniTest::Spec::ExpectSyntax
20
18
  raise NotImplementedError
21
19
  end
22
20
 
21
+ def expectations_instance_methods
22
+ Minitest::Expectations.instance_methods
23
+ end
24
+
23
25
  def set_expectation expectation_name
24
- expect_class.class_eval <<-EOM
26
+ @expect_class.class_eval <<-CODE
25
27
  #{expect_method expectation_name }
26
- EOM
28
+ CODE
27
29
  end
28
30
 
29
31
  def expect_method expectation_name
30
32
  """
31
- def #{expect_method_name expectation_name } *args
32
- #{expect_class::OBJECT_UNDER_TEST}.#{expectation_name} *args
33
+ def #{expect_method_name expectation_name.to_s } *args
34
+ #{@expect_class::OBJECT_UNDER_TEST}.#{expectation_name} *args
33
35
  end
34
36
  """
35
37
  end
36
38
 
37
39
  def expect_method_name expectation_name
38
- expectation_name.to_s.gsub TRANSPOSITION_REGEXP, TRANSPOSITIONS
40
+ expectation_name.gsub TRANSPOSITION_REGEXP, TRANSPOSITIONS
39
41
  end
40
42
  end
@@ -1,9 +1,9 @@
1
1
  require 'minitest/spec/expect_syntax'
2
2
 
3
- class MiniTest::Spec::ExpectSyntaxForArg < MiniTest::Spec::ExpectSyntax
3
+ class Minitest::Spec::ExpectSyntaxForArg < Minitest::Spec::ExpectSyntax
4
4
  private
5
5
 
6
6
  def expectation_names
7
- MiniTest::Expectations.instance_methods
7
+ expectations_instance_methods
8
8
  end
9
9
  end
@@ -1,19 +1,17 @@
1
1
  require 'minitest/spec/expect_syntax'
2
2
 
3
- class MiniTest::Spec::ExpectSyntaxForBlock < MiniTest::Spec::ExpectSyntax
3
+ class Minitest::Spec::ExpectSyntaxForBlock < Minitest::Spec::ExpectSyntax
4
4
  BLOCK_PASSING_EXPECTATION_REGEXES = [/silent/, /output/, /raise/, /throw/]
5
5
 
6
6
  private
7
7
 
8
8
  def expectation_names
9
- MiniTest::Expectations.instance_methods.select do |method|
9
+ expectations_instance_methods.select do |method|
10
10
  detect_block_passing_expectation method
11
11
  end
12
12
  end
13
13
 
14
14
  def detect_block_passing_expectation method
15
- BLOCK_PASSING_EXPECTATION_REGEXES.detect do |regex|
16
- regex.match method
17
- end
15
+ BLOCK_PASSING_EXPECTATION_REGEXES.detect { |regex| regex.match method }
18
16
  end
19
17
  end
@@ -1,8 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  $:.push File.expand_path("../lib", __FILE__)
4
- require 'minitest/spec'
5
- require 'minitest/spec/expect/version'
6
4
 
7
5
  Gem::Specification.new do |s|
8
6
  s.name = 'minitest-spec-expect'
@@ -11,7 +9,7 @@ Gem::Specification.new do |s|
11
9
  s.authors = ['Dave Jachimiak']
12
10
  s.email = 'dave.jachimiak@gmail.com'
13
11
  s.homepage = 'http://github.com/davejachimiak/minitest-spec-expect'
14
- s.version = MiniTest::Spec::Expect::VERSION
12
+ s.version = '0.1.3'
15
13
  s.files = `git ls-files`.split("\n").reject do |file_name|
16
14
  /\.gem$/.match file_name
17
15
  end
@@ -19,4 +17,5 @@ Gem::Specification.new do |s|
19
17
  s.require_paths = ['lib']
20
18
 
21
19
  s.add_dependency 'minitest', '~> 5.0'
20
+ s.add_development_dependency 'rake'
22
21
  end
@@ -16,7 +16,7 @@ describe Kernel do
16
16
 
17
17
  describe 'when a block is passed' do
18
18
  before do
19
- expectations = MiniTest::Expectations.instance_methods
19
+ expectations = Minitest::Expectations.instance_methods
20
20
  block_expectation_regexes = [/silent/, /output/, /raise/, /throw/]
21
21
 
22
22
  non_block_expectations = expectations.reject do |method|
@@ -28,7 +28,7 @@ describe Kernel do
28
28
  transpositions = { 'must' => 'to', 'wont' => 'to_not' }
29
29
 
30
30
  @non_block_expect_methods = non_block_expectations.map do |expectation|
31
- non_block_expect_method = transpositions.inject('') do |memo, transposition|
31
+ transpositions.inject('') do |memo, transposition|
32
32
  string = memo.empty? ? expectation.to_s : memo
33
33
 
34
34
  string.gsub transposition.first, transposition.last
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-spec-expect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Jachimiak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Expect syntax for minitest specs.
28
42
  email: dave.jachimiak@gmail.com
29
43
  executables: []
@@ -33,10 +47,10 @@ files:
33
47
  - .gitignore
34
48
  - .travis.yml
35
49
  - CHANGELOG.md
50
+ - Gemfile
36
51
  - README.md
37
52
  - Rakefile
38
53
  - lib/minitest/spec/expect.rb
39
- - lib/minitest/spec/expect/version.rb
40
54
  - lib/minitest/spec/expect_syntax.rb
41
55
  - lib/minitest/spec/expect_syntax_for_arg.rb
42
56
  - lib/minitest/spec/expect_syntax_for_block.rb
@@ -1,3 +0,0 @@
1
- class MiniTest::Spec::Expect
2
- VERSION = '0.1.2'
3
- end