rspec-power_assert 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dc07315b0fe42f14b73e10bc8b56cebbb6b10430
4
+ data.tar.gz: 6068ba82044bda6076414be1aef6971afb193adc
5
+ SHA512:
6
+ metadata.gz: 627aa581373d83a39fded770279f90a171be94eeeb8f793b680aae6149ccb883b1a38ac03e3463f92f640758cad86da2f9865fb390a1581129b958572f516a61
7
+ data.tar.gz: f392fae46e096a9aac9cd94e5691b56e4d7ecf95a42422a452d01f53246e5c8bf33d81d5046e99cc7413178647a60373153d5997d9ab10f305e1b57f070a23c7
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-power_assert.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 joker1007
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # Rspec::PowerAssert
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'rspec-power_assert'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rspec-power_assert
18
+
19
+ ## Usage
20
+
21
+ ### spec
22
+ ```ruby
23
+ describe Array do
24
+ describe "#map" do
25
+ let(:array) { [1, 2, 3] }
26
+ subject { %w(a b c) }
27
+
28
+ before do
29
+ @array = [1, 2, 3]
30
+ end
31
+
32
+ it do
33
+ is_asserted_by { subject.map(&:upcase) == array }
34
+ end
35
+
36
+ it do
37
+ upcased = subject.map(&:upcase)
38
+ upcased.pop
39
+ is_asserted_by { upcased == @array }
40
+ end
41
+
42
+ it do
43
+ is_expected.to eq %w(a b c)
44
+ is_asserted_by { subject.map(&:upcase) == %w(A B C) }
45
+ end
46
+
47
+ it "should transform array" do
48
+ is_expected.to eq %w(a b c)
49
+ is_asserted_by { subject.map(&:upcase) == %w(A B C) }
50
+ end
51
+ end
52
+ end
53
+ ```
54
+
55
+ ### output
56
+ ```
57
+ Rspec::PowerAssert
58
+ Array
59
+ #map
60
+ example at ./spec/rspec/power_assert_spec.rb:13 (FAILED - 1)
61
+ example at ./spec/rspec/power_assert_spec.rb:17 (FAILED - 2)
62
+ is_asserted_by { subject.map(&:upcase) == %w(A B C) }
63
+ | | |
64
+ | | true
65
+ | ["A", "B", "C"]
66
+ ["a", "b", "c"]
67
+ should transform array
68
+
69
+ Failures:
70
+
71
+ 1) Rspec::PowerAssert Array#map
72
+ Failure/Error: is_asserted_by { subject.map(&:upcase) == array }
73
+ is_asserted_by { subject.map(&:upcase) == array }
74
+ | | | |
75
+ | | | [1, 2, 3]
76
+ | | false
77
+ | ["A", "B", "C"]
78
+ ["a", "b", "c"]
79
+ # ./lib/rspec/power_assert.rb:19:in `is_asserted_by'
80
+ # ./spec/rspec/power_assert_spec.rb:14:in `block (4 levels) in <top (required)>'
81
+
82
+ 2) Rspec::PowerAssert Array#map
83
+ Failure/Error: is_asserted_by { upcased == @array }
84
+ is_asserted_by { upcased == @array }
85
+ | | |
86
+ | | [1, 2, 3]
87
+ | false
88
+ ["A", "B"]
89
+ # ./lib/rspec/power_assert.rb:19:in `is_asserted_by'
90
+ # ./spec/rspec/power_assert_spec.rb:20:in `block (4 levels) in <top (required)>'
91
+
92
+ Finished in 0.00455 seconds (files took 0.10298 seconds to load)
93
+ 4 examples, 2 failures
94
+
95
+ Failed examples:
96
+
97
+ rspec ./spec/rspec/power_assert_spec.rb:13 # Rspec::PowerAssert Array#map
98
+ rspec ./spec/rspec/power_assert_spec.rb:17 # Rspec::PowerAssert Array#map
99
+ ```
100
+
101
+ ## Contributing
102
+
103
+ 1. Fork it ( https://github.com/joker1007/rspec-power_assert/fork )
104
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
105
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
106
+ 4. Push to the branch (`git push origin my-new-feature`)
107
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,5 @@
1
+ module Rspec
2
+ module PowerAssert
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,45 @@
1
+ require "rspec/power_assert/version"
2
+ require "rspec/core"
3
+ require "power_assert"
4
+
5
+ module RSpec
6
+ module PowerAssert
7
+ def is_asserted_by(&blk)
8
+ result = nil
9
+ msg = nil
10
+ ::PowerAssert.start(blk, assertion_method: __method__) do |tp|
11
+ result = tp.yield
12
+ msg = tp.message_proc.call
13
+ end
14
+
15
+ if result
16
+ RSpec::Matchers.last_expectation_handler = DummyExpectationHandler
17
+ RSpec::Matchers.last_matcher = DummyAssertionMatcher.new(msg)
18
+ else
19
+ raise RSpec::Expectations::ExpectationNotMetError, msg
20
+ end
21
+ end
22
+
23
+ # for generating description
24
+ class DummyExpectationHandler
25
+ def self.verb
26
+ ""
27
+ end
28
+ end
29
+
30
+ # for generating description
31
+ class DummyAssertionMatcher
32
+ def initialize(msg)
33
+ @msg = msg
34
+ end
35
+
36
+ def description
37
+ "\n#{@msg}"
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ RSpec.configure do |config|
44
+ config.include RSpec::PowerAssert
45
+ end
@@ -0,0 +1 @@
1
+ require 'rspec/power_assert'
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/power_assert/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-power_assert"
8
+ spec.version = Rspec::PowerAssert::VERSION
9
+ spec.authors = ["joker1007"]
10
+ spec.email = ["kakyoin.hierophant@gmail.com"]
11
+ spec.summary = %q{Power Assert for RSpec.}
12
+ spec.description = %q{Power Assert for RSpec..}
13
+ spec.homepage = "https://github.com/joker1007/rspec-power_assert"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "power_assert", ">= 0.1.4"
22
+ spec.add_runtime_dependency "rspec"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rspec::PowerAssert do
4
+ describe Array do
5
+ describe "#map" do
6
+ let(:array) { [1, 2, 3] }
7
+ subject { %w(a b c) }
8
+
9
+ before do
10
+ @array = [1, 2, 3]
11
+ end
12
+
13
+ it do
14
+ is_asserted_by { subject.map(&:upcase) == array }
15
+ end
16
+
17
+ it do
18
+ upcased = subject.map(&:upcase)
19
+ upcased.pop
20
+ is_asserted_by { upcased == @array }
21
+ end
22
+
23
+ it do
24
+ is_expected.to eq %w(a b c)
25
+ is_asserted_by { subject.map(&:upcase) == %w(A B C) }
26
+ end
27
+
28
+ it "should transform array" do
29
+ is_expected.to eq %w(a b c)
30
+ is_asserted_by { subject.map(&:upcase) == %w(A B C) }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rspec-power_assert'
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-power_assert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - joker1007
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: power_assert
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Power Assert for RSpec..
70
+ email:
71
+ - kakyoin.hierophant@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/rspec-power_assert.rb
84
+ - lib/rspec/power_assert.rb
85
+ - lib/rspec/power_assert/version.rb
86
+ - rspec-power_assert.gemspec
87
+ - spec/rspec/power_assert_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/joker1007/rspec-power_assert
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Power Assert for RSpec.
113
+ test_files:
114
+ - spec/rspec/power_assert_spec.rb
115
+ - spec/spec_helper.rb