minitest-spec-expect 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,6 +10,10 @@ or from the command line:
10
10
  ```
11
11
  $ gem install minitest-spec-expect
12
12
  ```
13
+ Then require it in the file that you require `minitest/autorun`:
14
+ ```ruby
15
+ require 'minitest/spec/expect'
16
+ ```
13
17
  ## Usage
14
18
  Wrap the object under test in an `expect()` object. Then call a minitest expectation on it,
15
19
  substituting `must` and `wont` with `to` and `to_not`.
@@ -1,23 +1,21 @@
1
1
  module Kernel
2
2
  def expect object
3
- Minitest::Spec::Expect.new object
3
+ MiniTest::Spec::Expect.new object
4
4
  end
5
5
  end
6
6
 
7
- module Minitest
8
- class Spec
9
- class Expect
10
- require 'minitest/spec/expect_syntax'
7
+ require 'minitest/spec'
11
8
 
12
- OBJECT = 'object'
9
+ class MiniTest::Spec::Expect
10
+ require 'minitest/spec/expect_syntax'
13
11
 
14
- attr_reader OBJECT.to_sym
12
+ OBJECT = 'object'
15
13
 
16
- def initialize object
17
- @object = object
18
- end
14
+ attr_reader OBJECT.to_sym
19
15
 
20
- Minitest::Spec::ExpectSyntax.new(self).set_expectations
21
- end
16
+ def initialize object
17
+ @object = object
22
18
  end
19
+
20
+ MiniTest::Spec::ExpectSyntax.new(self).set_expectations
23
21
  end
@@ -1,7 +1,3 @@
1
- module Minitest
2
- class Spec
3
- class Expect
4
- VERSION = '0.0.1'
5
- end
6
- end
1
+ class MiniTest::Spec::Expect
2
+ VERSION = '0.0.2'
7
3
  end
@@ -1,56 +1,43 @@
1
- require 'minitest/spec'
1
+ class MiniTest::Spec::ExpectSyntax
2
+ TRANSPOSITIONS = {'must' => 'to', 'wont' => 'to_not'}
2
3
 
3
- module Minitest
4
- class Spec
5
- class ExpectSyntax
6
- TRANSPOSITIONS = {'must' => 'to', 'wont' => 'to_not'}
7
- INTERESTING_AUXILIARY_VERB_REGEXES = [/must/, /wont/]
4
+ attr_reader :expect_class
8
5
 
9
- attr_reader :expect_class
10
-
11
- def initialize expect_class
12
- @expect_class = expect_class
13
- end
14
-
15
- def set_expectations
16
- spec_expectation_names.each do |spec_expectation_name|
17
- set_expectation spec_expectation_name
18
- end
19
- end
6
+ def initialize expect_class
7
+ @expect_class = expect_class
8
+ end
20
9
 
21
- private
10
+ def set_expectations
11
+ spec_expectation_names.each do |spec_expectation_name|
12
+ set_expectation spec_expectation_name
13
+ end
14
+ end
22
15
 
23
- def spec_expectation_names
24
- Object.instance_methods.select { |method_name| expectation? method_name }
25
- end
16
+ private
26
17
 
27
- def expectation? method_name
28
- !!INTERESTING_AUXILIARY_VERB_REGEXES.detect do |regex|
29
- method_name.to_s.match regex
30
- end
31
- end
18
+ def spec_expectation_names
19
+ MiniTest::Expectations.instance_methods
20
+ end
32
21
 
33
- def set_expectation expectation_name
34
- expect_class.class_eval <<-EOM
35
- #{expect_method expectation_name }
36
- EOM
37
- end
22
+ def set_expectation expectation_name
23
+ expect_class.class_eval <<-EOM
24
+ #{expect_method expectation_name }
25
+ EOM
26
+ end
38
27
 
39
- def expect_method expectation_name
40
- """
41
- def #{expect_method_name expectation_name } *args
42
- #{expect_class::OBJECT}.#{expectation_name} *args
43
- end
44
- """
28
+ def expect_method expectation_name
29
+ """
30
+ def #{expect_method_name expectation_name } *args
31
+ #{expect_class::OBJECT}.#{expectation_name} *args
45
32
  end
33
+ """
34
+ end
46
35
 
47
- def expect_method_name expectation_name
48
- TRANSPOSITIONS.inject('') do |memo, transposition|
49
- string = memo.empty? ? expectation_name.to_s : memo
36
+ def expect_method_name expectation_name
37
+ TRANSPOSITIONS.inject('') do |memo, transposition|
38
+ string = memo.empty? ? expectation_name.to_s : memo
50
39
 
51
- string.gsub transposition.first, transposition.last
52
- end
53
- end
40
+ string.gsub transposition.first, transposition.last
54
41
  end
55
42
  end
56
43
  end
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  $:.push File.expand_path("../lib", __FILE__)
4
+ require 'minitest/spec'
4
5
  require 'minitest/spec/expect/version'
5
6
 
6
7
  Gem::Specification.new do |s|
@@ -9,8 +10,8 @@ Gem::Specification.new do |s|
9
10
  s.summary = 'Use the expect syntax with transposed minitest expectations.'
10
11
  s.authors = ['Dave Jachimiak']
11
12
  s.email = 'dave.jachimiak@gmail.com'
12
- s.homepage = 'http://github.com/davejachimiak/minitest-expect'
13
- s.version = Minitest::Spec::Expect::VERSION
13
+ s.homepage = 'http://github.com/davejachimiak/minitest-spec-expect'
14
+ s.version = MiniTest::Spec::Expect::VERSION
14
15
  s.files = `git ls-files`.split("\n").reject do |file_name|
15
16
  /\.gem$/.match file_name
16
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-spec-expect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -25,7 +25,7 @@ files:
25
25
  - lib/minitest/spec/expect_syntax.rb
26
26
  - minitest-spec-expect.gemspec
27
27
  - spec/integration_spec.rb
28
- homepage: http://github.com/davejachimiak/minitest-expect
28
+ homepage: http://github.com/davejachimiak/minitest-spec-expect
29
29
  licenses: []
30
30
  post_install_message:
31
31
  rdoc_options: []