fakes 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,6 @@ blah.rb
3
3
  .bundle
4
4
  Gemfile.lock
5
5
  pkg/*
6
+ .rmvrc
7
+ .ruby-version
8
+ .ruby-gemset
data/fakes.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib",__FILE__)
3
- require "core/version"
3
+ require "fakes/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "fakes"
@@ -21,5 +21,4 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency "rake"
22
22
  s.add_development_dependency "guard"
23
23
  s.add_development_dependency "guard-rspec"
24
- s.add_runtime_dependency "developwithpassion_arrays"
25
24
  end
data/lib/fakes.rb CHANGED
@@ -1,36 +1,17 @@
1
- require 'developwithpassion_arrays'
1
+ require 'fakes/arg_matching/arg_match_factory'
2
+ require 'fakes/arg_matching/block_arg_matcher'
3
+ require 'fakes/arg_matching/combined_arg_matcher'
4
+ require 'fakes/arg_matching/matches'
5
+ require 'fakes/arg_matching/regular_arg_matcher'
6
+ require 'fakes/arg_behaviour'
7
+ require 'fakes/arg_set'
8
+ require 'fakes/class_swap'
9
+ require 'fakes/class_swaps'
10
+ require 'fakes/fake'
11
+ require 'fakes/ignore_set'
12
+ require 'fakes/method_stub'
13
+ require 'fakes/fakes'
2
14
 
3
- require 'core/arg_matching/arg_match_factory'
4
- require 'core/arg_matching/block_arg_matcher'
5
- require 'core/arg_matching/combined_arg_matcher'
6
- require 'core/arg_matching/matches'
7
- require 'core/arg_matching/regular_arg_matcher'
8
- require 'core/arg_behaviour'
9
- require 'core/arg_set'
10
- require 'core/class_swap'
11
- require 'core/class_swaps'
12
- require 'core/fake'
13
- require 'core/ignore_set'
14
- require 'core/method_stub'
15
15
  require 'singleton'
16
16
 
17
- module Fakes
18
- def fake(invocations = {})
19
- item = Fakes::Fake.new
20
- invocations.each{|method,return_value| item.stub(method).and_return(return_value)}
21
- item
22
- end
23
- def arg_match
24
- return Fakes::Matches
25
- end
26
- def fake_class(klass,invocations = {})
27
- item = fake(invocations)
28
- Fakes::ClassSwaps.instance.add_fake_for(klass,item)
29
- item
30
- end
31
- def reset_fake_classes
32
- Fakes::ClassSwaps.instance.reset
33
- end
34
- end
35
-
36
17
  include Fakes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,22 @@
1
+ module Fakes
2
+ def fake(invocations = {})
3
+ item = Fakes::Fake.new
4
+ invocations.each{|method,return_value| item.stub(method).and_return(return_value)}
5
+ item
6
+ end
7
+
8
+ def arg_match
9
+ return Fakes::Matches
10
+ end
11
+
12
+ def fake_class(klass,invocations = {})
13
+ item = fake(invocations)
14
+ Fakes::ClassSwaps.instance.add_fake_for(klass,item)
15
+ item
16
+ end
17
+
18
+ def reset_fake_classes
19
+ Fakes::ClassSwaps.instance.reset
20
+ end
21
+ end
22
+
@@ -3,22 +3,25 @@ module Fakes
3
3
  include ArgBehaviour
4
4
 
5
5
  def initialize
6
- array :arg_sets do|a|
7
- a.mutator :capture_args do|args|
8
- @times_called += 1
9
- @arg_sets << args
10
- end
11
- end
12
6
  @times_called = 0
13
7
  end
14
8
 
9
+ def arg_sets
10
+ @arg_sets ||= []
11
+ end
12
+
13
+ def capture_args(args)
14
+ @times_called += 1
15
+ arg_sets << args
16
+ end
17
+
15
18
  def matches?(args)
16
19
  return true
17
20
  end
18
21
 
19
22
  def was_called_with?(args)
20
23
  matcher = ArgMatchFactory.create_arg_matcher_using(args)
21
- return @arg_sets.select{|set| matcher.matches?(set)}.count > 0
24
+ return arg_sets.select{|set| matcher.matches?(set)}.count > 0
22
25
  end
23
26
  end
24
27
  end
@@ -1,17 +1,20 @@
1
1
  module Fakes
2
2
  class MethodStub
3
3
  def initialize(arg_sets = [])
4
- array :arg_sets do|a|
5
- a.mutator :add_new_set do|set|
6
- @arg_sets << set
7
- set
8
- end
9
- end
10
4
  @arg_sets = arg_sets
11
5
  end
12
6
 
7
+ def arg_sets
8
+ @arg_sets ||= []
9
+ end
10
+
11
+ def add_new_argument_set(set)
12
+ arg_sets << set
13
+ set
14
+ end
15
+
13
16
  def with(*args)
14
- return add_new_set(ArgSet.new(args))
17
+ return add_new_argument_set(ArgSet.new(args))
15
18
  end
16
19
 
17
20
  def throws(exception)
@@ -19,7 +22,7 @@ module Fakes
19
22
  end
20
23
 
21
24
  def ignore_arg
22
- return add_new_set(IgnoreSet.new)
25
+ return add_new_argument_set(IgnoreSet.new)
23
26
  end
24
27
 
25
28
  def and_return(item)
@@ -0,0 +1,3 @@
1
+ module Fakes
2
+ VERSION = "1.0.6"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -75,22 +75,6 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: developwithpassion_arrays
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
78
  description: Faking library that allows inspection of received calls after they have
95
79
  been made. Also supports tracking calls with multiple argument sets.
96
80
  email:
@@ -100,27 +84,27 @@ extensions: []
100
84
  extra_rdoc_files: []
101
85
  files:
102
86
  - .gitignore
103
- - .rvmrc
104
87
  - Gemfile
105
88
  - Guardfile
106
89
  - LICENSE
107
90
  - README.md
108
91
  - Rakefile
109
92
  - fakes.gemspec
110
- - lib/core/arg_behaviour.rb
111
- - lib/core/arg_matching/arg_match_factory.rb
112
- - lib/core/arg_matching/block_arg_matcher.rb
113
- - lib/core/arg_matching/combined_arg_matcher.rb
114
- - lib/core/arg_matching/matches.rb
115
- - lib/core/arg_matching/regular_arg_matcher.rb
116
- - lib/core/arg_set.rb
117
- - lib/core/class_swap.rb
118
- - lib/core/class_swaps.rb
119
- - lib/core/fake.rb
120
- - lib/core/ignore_set.rb
121
- - lib/core/method_stub.rb
122
- - lib/core/version.rb
123
93
  - lib/fakes.rb
94
+ - lib/fakes/arg_behaviour.rb
95
+ - lib/fakes/arg_matching/arg_match_factory.rb
96
+ - lib/fakes/arg_matching/block_arg_matcher.rb
97
+ - lib/fakes/arg_matching/combined_arg_matcher.rb
98
+ - lib/fakes/arg_matching/matches.rb
99
+ - lib/fakes/arg_matching/regular_arg_matcher.rb
100
+ - lib/fakes/arg_set.rb
101
+ - lib/fakes/class_swap.rb
102
+ - lib/fakes/class_swaps.rb
103
+ - lib/fakes/fake.rb
104
+ - lib/fakes/fakes.rb
105
+ - lib/fakes/ignore_set.rb
106
+ - lib/fakes/method_stub.rb
107
+ - lib/fakes/version.rb
124
108
  - spec/spec_helper.rb
125
109
  - spec/specs/arg_behaviour_spec.rb
126
110
  - spec/specs/arg_match_factory_spec.rb
@@ -150,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
134
  version: '0'
151
135
  segments:
152
136
  - 0
153
- hash: 3549454683975842118
137
+ hash: -3352977076602882520
154
138
  required_rubygems_version: !ruby/object:Gem::Requirement
155
139
  none: false
156
140
  requirements:
@@ -159,10 +143,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
143
  version: '0'
160
144
  segments:
161
145
  - 0
162
- hash: 3549454683975842118
146
+ hash: -3352977076602882520
163
147
  requirements: []
164
148
  rubyforge_project: fakes
165
- rubygems_version: 1.8.24
149
+ rubygems_version: 1.8.25
166
150
  signing_key:
167
151
  specification_version: 3
168
152
  summary: Simple faking library
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.3@fakes --create
data/lib/core/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Fakes
2
- VERSION = "1.0.5"
3
- end