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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82d97c34686380fc90c0e8e0028aae7b0daeb66d
4
- data.tar.gz: 575f6fb8e43ad29f684cd23705aed08f6ee039d9
3
+ metadata.gz: 513275a9d169108eea61074bb1b7042a21b932c7
4
+ data.tar.gz: 6e074b09732328f8def1d5ef19e334dd55f2edfe
5
5
  SHA512:
6
- metadata.gz: 78f19bf62efbe5cb83d37925bacff548959e509396c24c2fa484226a65a6790de47ac9a06bad3f9a70c3ff74fd37dd4509a3e807f400f1401313941837ec431c
7
- data.tar.gz: a2f41cfe71ab894f6cf301ed555a14decd7b811fed5b9b4839b575b2f0ef76c96c9237fe89581c3f789b29ddf0afced9829daf49f55a008900d205c077545413
6
+ metadata.gz: 3790acb8154b4aca30b8c4b7a4e4b0040d9d7a9dba1f0a613535d5bf91b3dabc98ca180b072f03992d58033b85ece75da493a71b45297bca5fd1948776feed5c
7
+ data.tar.gz: 4fb527463c931755907b01bad5b0b367e3c6cd52278baa05d78e8b211c65c1ba6fe3552c1d38dedb90f13fa33cb0d017d24c20746261438c89189dca4cf428c8
@@ -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
@@ -0,0 +1,8 @@
1
+ module Namlet
2
+ module Expectation
3
+ def initialize(target)
4
+ target = target.instance_variable_get(:@actual) if Namlet::Wrapper === target
5
+ super(target)
6
+ end
7
+ end
8
+ 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
@@ -1,3 +1,3 @@
1
1
  module Namlet
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
@@ -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
@@ -1,3 +1,4 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'pry'
3
3
  require 'namlet'
4
+
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.1
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-24 00:00:00.000000000 Z
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