fakes-rspec 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,8 @@ require 'singleton'
5
5
  require 'fakes_rspec/block_criteria'
6
6
  require 'fakes_rspec/matcher'
7
7
  require 'fakes_rspec/nullo_specification'
8
- require 'fakes_rspec/occurances'
9
- require 'fakes_rspec/received_occurances_criteria'
8
+ require 'fakes_rspec/occurrences'
9
+ require 'fakes_rspec/received_occurrences_criteria'
10
10
  require 'fakes_rspec/received_criteria'
11
11
 
12
12
  RSpec.configure do |config|
@@ -3,41 +3,41 @@ module RSpec
3
3
  return Fakes::RSpec::ReceivedCriteria.new(the_call)
4
4
  end
5
5
  def self.create_received_occurences_criteria_from(the_call,occurence)
6
- return Fakes::RSpec::ReceivedOccurencesCriteria.new(create_received_criteria_from(the_call),the_call,occurence)
6
+ return Fakes::RSpec::ReceivedOccurrencesCriteria.new(create_received_criteria_from(the_call),the_call,occurence)
7
7
  end
8
8
 
9
9
  Matchers.define :have_received do|symbol,*args|
10
10
  @occurence_spec = Fakes::RSpec::NulloSpecification.instance
11
11
 
12
12
  chain :once do
13
- @occurence_spec = Fakes::RSpec::Occurances.exact(1)
13
+ @occurence_spec = Fakes::RSpec::Occurrences.exact(1)
14
14
  end
15
15
  chain :twice do
16
- @occurence_spec = Fakes::RSpec::Occurances.exact(2)
16
+ @occurence_spec = Fakes::RSpec::Occurrences.exact(2)
17
17
  end
18
18
  chain :at_least_once do
19
- @occurence_spec = Fakes::RSpec::Occurances.at_least(1)
19
+ @occurence_spec = Fakes::RSpec::Occurrences.at_least(1)
20
20
  end
21
21
  chain :at_least_twice do
22
- @occurence_spec = Fakes::RSpec::Occurances.at_least(2)
22
+ @occurence_spec = Fakes::RSpec::Occurrences.at_least(2)
23
23
  end
24
24
  chain :at_most_once do
25
- @occurence_spec = Fakes::RSpec::Occurances.at_most(1)
25
+ @occurence_spec = Fakes::RSpec::Occurrences.at_most(1)
26
26
  end
27
27
  chain :at_most_twice do
28
- @occurence_spec = Fakes::RSpec::Occurances.at_most(2)
28
+ @occurence_spec = Fakes::RSpec::Occurrences.at_most(2)
29
29
  end
30
30
  chain :at_least do|times|
31
- @occurence_spec = Fakes::RSpec::Occurances.at_least(times)
31
+ @occurence_spec = Fakes::RSpec::Occurrences.at_least(times)
32
32
  end
33
33
  chain :at_most do|times|
34
- @occurence_spec = Fakes::RSpec::Occurances.at_most(times)
34
+ @occurence_spec = Fakes::RSpec::Occurrences.at_most(times)
35
35
  end
36
36
  chain :exactly do|times|
37
- @occurence_spec = Fakes::RSpec::Occurances.exact(times)
37
+ @occurence_spec = Fakes::RSpec::Occurrences.exact(times)
38
38
  end
39
39
  chain :occurs do|the_proc|
40
- @occurence_spec = Fakes::RSpec::Occurances.from_block(the_proc)
40
+ @occurence_spec = Fakes::RSpec::Occurrences.from_block(the_proc)
41
41
  end
42
42
  match do|the_fake|
43
43
  RSpec.create_received_occurences_criteria_from(the_fake.received(symbol),@occurence_spec).is_satisfied_by(*args)
@@ -0,0 +1,29 @@
1
+ module Fakes
2
+ module RSpec
3
+ class Occurrences
4
+ class << self
5
+ def from_block(the_block)
6
+ return BlockCriteria.new(the_block)
7
+ end
8
+
9
+ def exact(times)
10
+ condition = lambda { |occurances| occurances == times }
11
+
12
+ return from_block(condition)
13
+ end
14
+
15
+ def at_least(times)
16
+ condition = lambda { |occurrences| occurrences >= times }
17
+
18
+ return from_block(condition)
19
+ end
20
+
21
+ def at_most(times)
22
+ condition = lambda { |occurrences| occurrences <= times }
23
+
24
+ return from_block(condition)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module Fakes
2
+ module RSpec
3
+ class ReceivedOccurrencesCriteria
4
+ def initialize(received_criteria,the_call,occurrence)
5
+ @received_criteria = received_criteria
6
+ @the_call = the_call
7
+ @occurrence = occurrence
8
+ end
9
+
10
+ def is_satisfied_by(*args)
11
+ return @received_criteria.is_satisfied_by(*args) &&
12
+ @occurrence.is_satisfied_by((args.count == 0 ? @the_call.total_times_called : @the_call.called_with(*args).times_called))
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module Fakes
2
2
  module RSpec
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
@@ -2,29 +2,29 @@ require 'spec_helper'
2
2
 
3
3
  module Fakes
4
4
  module RSpec
5
- describe Occurances do
6
- context "when creating an exact occurance matcher" do
7
- subject{Occurances.exact(1)}
5
+ describe Occurrences do
6
+ context "when creating an exact occurrence matcher" do
7
+ subject{Occurrences.exact(1)}
8
8
 
9
- it "should create a matcher that matches an exact number of occurances" do
9
+ it "should create a matcher that matches an exact number of occurrences" do
10
10
  subject.is_satisfied_by(1).should be_true
11
11
  subject.is_satisfied_by(2).should be_false
12
12
  end
13
13
  end
14
14
 
15
- context "when creating an at least occurance matcher" do
16
- subject{Occurances.at_least(3)}
15
+ context "when creating an at least occurrence matcher" do
16
+ subject{Occurrences.at_least(3)}
17
17
 
18
- it "should create a matcher that matches an exact number of occurances" do
18
+ it "should create a matcher that matches an exact number of occurrences" do
19
19
  subject.is_satisfied_by(3).should be_true
20
20
  subject.is_satisfied_by(4).should be_true
21
21
  subject.is_satisfied_by(2).should be_false
22
22
  end
23
23
  end
24
- context "when creating an at most occurance matcher" do
25
- subject{Occurances.at_most(3)}
24
+ context "when creating an at most occurrence matcher" do
25
+ subject{Occurrences.at_most(3)}
26
26
 
27
- it "should create a matcher that matches an exact number of occurances" do
27
+ it "should create a matcher that matches an exact number of occurrences" do
28
28
  subject.is_satisfied_by(3).should be_true
29
29
  subject.is_satisfied_by(2).should be_true
30
30
  subject.is_satisfied_by(1).should be_true
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  module Fakes
4
4
  module RSpec
5
- describe ReceivedOccurencesCriteria do
5
+ describe ReceivedOccurrencesCriteria do
6
6
  let(:original){fake}
7
- let(:occurence){fake}
7
+ let(:occurrence){fake}
8
8
  let(:the_call){fake}
9
9
  let(:arg_set){fake}
10
10
  let(:the_arg){1}
11
- subject{ReceivedOccurencesCriteria.new(original,the_call,occurence)}
11
+ subject{ReceivedOccurrencesCriteria.new(original,the_call,occurrence)}
12
12
  context "when matching a call made" do
13
13
  context "and the original criteria is not satisfied" do
14
14
  before (:each) do
@@ -17,8 +17,8 @@ module Fakes
17
17
  it "should not match" do
18
18
  subject.is_satisfied_by(the_arg).should be_false
19
19
  end
20
- it "should not use the occurence or the call" do
21
- occurence.should_not have_received(:is_satified_by)
20
+ it "should not use the occurrence or the call" do
21
+ occurrence.should_not have_received(:is_satified_by)
22
22
  the_call.should_not have_received(:called_with)
23
23
  end
24
24
  end
@@ -32,26 +32,26 @@ module Fakes
32
32
  before (:each) do
33
33
  original.stub(:is_satisfied_by).and_return(true)
34
34
  the_call.stub(:total_times_called).and_return(1)
35
- occurence.stub(:is_satisfied_by).with(1).and_return(true)
35
+ occurrence.stub(:is_satisfied_by).with(1).and_return(true)
36
36
  end
37
37
  before (:each) do
38
38
  @result = subject.is_satisfied_by
39
39
  end
40
- it "should match if the occurence matches the total number of invocations" do
40
+ it "should match if the occurrence matches the total number of invocations" do
41
41
  @result.should be_true
42
42
  end
43
43
  end
44
- context "and its occurence is satisfied" do
44
+ context "and its occurrence is satisfied" do
45
45
  before (:each) do
46
- occurence.stub(:is_satisfied_by).with(1).and_return(true)
46
+ occurrence.stub(:is_satisfied_by).with(1).and_return(true)
47
47
  end
48
48
  it "should match" do
49
49
  subject.is_satisfied_by(the_arg).should be_true
50
50
  end
51
51
  end
52
- context "and its occurence is not satisfied" do
52
+ context "and its occurrence is not satisfied" do
53
53
  before (:each) do
54
- occurence.stub(:is_satisfied_by).with(1).and_return(false)
54
+ occurrence.stub(:is_satisfied_by).with(1).and_return(false)
55
55
  end
56
56
  it "should not match" do
57
57
  subject.is_satisfied_by(the_arg).should be_false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakes-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
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-05-31 00:00:00.000000000 Z
12
+ date: 2013-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -126,16 +126,16 @@ files:
126
126
  - lib/fakes_rspec/block_criteria.rb
127
127
  - lib/fakes_rspec/matcher.rb
128
128
  - lib/fakes_rspec/nullo_specification.rb
129
- - lib/fakes_rspec/occurances.rb
129
+ - lib/fakes_rspec/occurrences.rb
130
130
  - lib/fakes_rspec/received_criteria.rb
131
- - lib/fakes_rspec/received_occurances_criteria.rb
131
+ - lib/fakes_rspec/received_occurrences_criteria.rb
132
132
  - lib/fakes_rspec/version.rb
133
133
  - spec/spec_helper.rb
134
134
  - spec/specs/block_criteria_spec.rb
135
135
  - spec/specs/nullo_specification_spec.rb
136
- - spec/specs/occurances_spec.rb
136
+ - spec/specs/occurrences_spec.rb
137
137
  - spec/specs/received_criteria_spec.rb
138
- - spec/specs/received_occurences_criteria_spec.rb
138
+ - spec/specs/received_occurrences_criteria_spec.rb
139
139
  - spec/specs/usage_spec.rb
140
140
  homepage: http://www.developwithpassion.com
141
141
  licenses: []
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: -3560833146225028214
154
+ hash: -1802133210709367804
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements:
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: -3560833146225028214
163
+ hash: -1802133210709367804
164
164
  requirements: []
165
165
  rubyforge_project: fakes-rspec
166
166
  rubygems_version: 1.8.25
@@ -171,7 +171,7 @@ test_files:
171
171
  - spec/spec_helper.rb
172
172
  - spec/specs/block_criteria_spec.rb
173
173
  - spec/specs/nullo_specification_spec.rb
174
- - spec/specs/occurances_spec.rb
174
+ - spec/specs/occurrences_spec.rb
175
175
  - spec/specs/received_criteria_spec.rb
176
- - spec/specs/received_occurences_criteria_spec.rb
176
+ - spec/specs/received_occurrences_criteria_spec.rb
177
177
  - spec/specs/usage_spec.rb
@@ -1,20 +0,0 @@
1
- module Fakes
2
- module RSpec
3
- class Occurances
4
- class << self
5
- def from_block(the_block)
6
- return BlockCriteria.new(the_block)
7
- end
8
- def exact(times)
9
- return from_block(lambda{|occurances| return occurances == times})
10
- end
11
- def at_least(times)
12
- return from_block(lambda { |occurences| return occurences >= times})
13
- end
14
- def at_most(times)
15
- return from_block(lambda { |occurences| return occurences <= times})
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,16 +0,0 @@
1
- module Fakes
2
- module RSpec
3
- class ReceivedOccurencesCriteria
4
- def initialize(received_criteria,the_call,occurence)
5
- @received_criteria = received_criteria
6
- @the_call = the_call
7
- @occurence = occurence
8
- end
9
-
10
- def is_satisfied_by(*args)
11
- return @received_criteria.is_satisfied_by(*args) &&
12
- @occurence.is_satisfied_by((args.count == 0 ? @the_call.total_times_called : @the_call.called_with(*args).times_called))
13
- end
14
- end
15
- end
16
- end