namlet 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/namlet.rb +3 -0
- data/lib/namlet/expectation.rb +8 -0
- data/lib/namlet/memorized_helpers.rb +2 -6
- data/lib/namlet/version.rb +1 -1
- data/lib/namlet/wrapper.rb +4 -0
- data/spec/namlet_spec.rb +25 -1
- data/spec/spec_helper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 513275a9d169108eea61074bb1b7042a21b932c7
|
4
|
+
data.tar.gz: 6e074b09732328f8def1d5ef19e334dd55f2edfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3790acb8154b4aca30b8c4b7a4e4b0040d9d7a9dba1f0a613535d5bf91b3dabc98ca180b072f03992d58033b85ece75da493a71b45297bca5fd1948776feed5c
|
7
|
+
data.tar.gz: 4fb527463c931755907b01bad5b0b367e3c6cd52278baa05d78e8b211c65c1ba6fe3552c1d38dedb90f13fa33cb0d017d24c20746261438c89189dca4cf428c8
|
data/lib/namlet.rb
CHANGED
@@ -3,7 +3,10 @@ require "namlet/version"
|
|
3
3
|
require "rspec"
|
4
4
|
require "namlet/wrapper"
|
5
5
|
require "namlet/memorized_helpers"
|
6
|
+
require "namlet/expectation"
|
6
7
|
|
7
8
|
module Namlet
|
8
9
|
::RSpec::Core::ExampleGroup.send(:include, Namlet::MemorizedHelpers)
|
10
|
+
::RSpec::Expectations::ExpectationTarget.send(:prepend, Namlet::Expectation)
|
11
|
+
::RSpec::Mocks::TargetBase.send(:prepend, Namlet::Expectation)
|
9
12
|
end
|
@@ -7,12 +7,8 @@ module Namlet
|
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
def let(name, &block)
|
10
|
-
super("___wrapped_#{name}", &block)
|
11
|
-
super(name) { Namlet::Wrapper.new(name, send("___wrapped_#{name}")) }
|
12
|
-
end
|
13
|
-
def let!(name, &block)
|
14
|
-
super("___wrapped_#{name}", &block)
|
15
|
-
super(name) { Namlet::Wrapper.new(name, send("___wrapped_#{name}")) }
|
10
|
+
super("___wrapped_#{name}".to_sym, &block)
|
11
|
+
super(name.to_sym) { Namlet::Wrapper.new(name.to_sym, send("___wrapped_#{name}".to_sym)) }
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|
data/lib/namlet/version.rb
CHANGED
data/lib/namlet/wrapper.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
module Namlet
|
2
4
|
class Wrapper < SimpleDelegator
|
5
|
+
extend Forwardable
|
3
6
|
def initialize(name, actual)
|
4
7
|
super(actual)
|
5
8
|
@name = name
|
6
9
|
@actual = actual
|
7
10
|
end
|
8
11
|
|
12
|
+
def_delegators :@actual, :class, :is_a?, :kind_of?, :nil?
|
9
13
|
def inspect ; @name ; end
|
10
14
|
end
|
11
15
|
end
|
data/spec/namlet_spec.rb
CHANGED
@@ -10,12 +10,36 @@ describe Namlet do
|
|
10
10
|
let(:user_a) { dummy_class.new(name: "aaaa") }
|
11
11
|
let(:user_b) { dummy_class.new(name: "bbbb") }
|
12
12
|
let(:user_c) { dummy_class.new(name: "aaaa") }
|
13
|
+
let(:expected_hash) { {a: 1} }
|
14
|
+
let(:let_nil) { nil }
|
15
|
+
|
16
|
+
it { expect(expected_hash).to be_a Hash }
|
17
|
+
it { expect({a: 1}).to eq expected_hash }
|
13
18
|
|
14
|
-
it { expect(user_a).to be_a Namlet::Wrapper }
|
15
19
|
it { expect(user_a).not_to eq user_b }
|
16
20
|
it { expect(user_a).to eq user_c }
|
21
|
+
|
22
|
+
it { expect(let_nil).to be_nil }
|
23
|
+
|
24
|
+
describe :subject do
|
25
|
+
subject { expected_hash }
|
26
|
+
it { expect(subject).to eq a: 1 }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe :nested do
|
30
|
+
let(:hash_of_users) { {a: user_a, b: user_b } }
|
31
|
+
it { expect({a: user_a, b: user_b}).to eq hash_of_users }
|
32
|
+
end
|
33
|
+
|
17
34
|
describe :override_let do
|
18
35
|
let(:user_b) { dummy_class.new(name: 'aaaa') }
|
19
36
|
it { expect(user_a).to eq user_b }
|
20
37
|
end
|
38
|
+
|
39
|
+
describe :expect do
|
40
|
+
it "expect target actual instance" do
|
41
|
+
expect(user_a).to receive(:size)
|
42
|
+
user_a.instance_variable_get(:@actual).size
|
43
|
+
end
|
44
|
+
end
|
21
45
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namlet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masarakki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
112
|
- lib/namlet.rb
|
113
|
+
- lib/namlet/expectation.rb
|
113
114
|
- lib/namlet/memorized_helpers.rb
|
114
115
|
- lib/namlet/version.rb
|
115
116
|
- lib/namlet/wrapper.rb
|