rspec-spy 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Version 1.1.0
2
+
3
+ * `rspec-spy` no longer sets up the before hook for you, you need to do that manually. See the README
4
+
1
5
  ## Version 1.0.0
2
6
 
3
7
  * Removed `strict_mode` and use `should_have_received` and `should_have_not_received` instead
data/README.md CHANGED
@@ -37,10 +37,14 @@ Or install it yourself as:
37
37
 
38
38
  $ gem install rspec-spy
39
39
 
40
- Add to your spec_helper.rb:
40
+ Add to your spec_helper.rb in `RSpec.configure` **AFTER any other global before hooks, especially DatabaseCleaner**:
41
41
 
42
42
  ``` ruby
43
- require 'rspec-spy'
43
+ # any config.before hooks should go above
44
+
45
+ config.before(:each, :spy => true) do |example|
46
+ RSpec::Spy(example)
47
+ end
44
48
  ```
45
49
 
46
50
  ## Usage
data/lib/rspec-spy.rb CHANGED
@@ -11,9 +11,3 @@ RSpec::Core::Example.class_eval do
11
11
  end
12
12
  end
13
13
 
14
- RSpec.configure do |config|
15
- config.before(:each, :spy => true) do |example|
16
- example.example.run_spy
17
- end
18
- end
19
-
data/lib/rspec/spy.rb CHANGED
@@ -9,5 +9,9 @@ module RSpec
9
9
  end
10
10
  end
11
11
  end
12
+
13
+ def self.Spy(example)
14
+ example.example.run_spy
15
+ end
12
16
  end
13
17
 
@@ -20,13 +20,13 @@ RSpec::Mocks::Methods.class_eval do
20
20
 
21
21
  def spy_check(method)
22
22
  return if RSpec::Spy.ok_to_spy?
23
- raise "#{method} should not be used outside of a spy block. Please put it in a spy block or use #{method}!."
23
+ raise "#{method} was called before RSpec::Spy(example). Make sure that your example is properly tagged (generally with :spy => true) and you have a before hook in your RSpec.configure that calls RSpec::Spy(example)."
24
24
  end
25
25
 
26
26
  def nil_check(method)
27
27
  return if RSpec::Mocks::Proxy.allow_message_expectations_on_nil?
28
28
  return unless nil?
29
- raise "You set an expectation on nil, maybe you're using an @instance_var? If you want to do this, use allow_message_expectations_on_nil."
29
+ raise "You set an expectation on nil, maybe you're using an @instance_var before it is set? If you want to do this, use allow_message_expectations_on_nil."
30
30
  end
31
31
  end
32
32
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Spy
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -4,4 +4,8 @@ RSpec.configure do |config|
4
4
  config.treat_symbols_as_metadata_keys_with_true_values = true
5
5
  config.run_all_when_everything_filtered = true
6
6
  config.filter_run :focus
7
+
8
+ config.before(:each, :spy => true) do |example|
9
+ RSpec::Spy(example)
10
+ end
7
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-spy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
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: 2012-04-25 00:00:00.000000000 Z
12
+ date: 2012-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -104,7 +104,7 @@ rubyforge_project:
104
104
  rubygems_version: 1.8.21
105
105
  signing_key:
106
106
  specification_version: 3
107
- summary: rspec-spy-1.0.0
107
+ summary: rspec-spy-1.1.0
108
108
  test_files:
109
109
  - spec/rspec-spy_spec.rb
110
110
  - spec/spec_helper.rb