great_pretender 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/great_pretender/mockups_controller.rb +1 -1
- data/config/locales/en.yml +1 -0
- data/lib/great_pretender/config.rb +7 -0
- data/lib/great_pretender/controller.rb +1 -1
- data/lib/great_pretender/pretender.rb +5 -0
- data/lib/great_pretender/version.rb +1 -1
- data/spec/lib/great_pretender/pretender_spec.rb +29 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded13adb89cf39cbc783b42fec961b8d1918a0e5
|
4
|
+
data.tar.gz: 5a3842182ee81c1acb8fb1937208a0f40f7ca45e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492883658952702e1d4edf14d76a148e3c080d293a3ac72aeca6339d397d115d87258693e7f931be9c6f863b6bf43a0ccfa356f95f874fb40d47aa94283949f8
|
7
|
+
data.tar.gz: 2e77e4ce36db26b0ff71a39ec85f70260e0fb981b57d425fee7949646b61c5753aa3e8e4c65eb6ae1780f62b280cbcda847541dbe3fc5b03fb317bd403a59097
|
data/config/locales/en.yml
CHANGED
@@ -2,3 +2,4 @@ en:
|
|
2
2
|
great_pretender:
|
3
3
|
missing_helper_methods: "Great Pretender couldn't find a path helper to a mockup from %s. I tried '%s' to no avail. Have you named your mockup routes?"
|
4
4
|
not_found: "No mockup found at %s"
|
5
|
+
deprecated_pretender: "DEPRECATION WARNING: Using Pretender methods (`%s') directly is deprectated. Use `%s.%s' instead."
|
@@ -15,6 +15,11 @@ module GreatPretender
|
|
15
15
|
pretender = pretenders.find { |p| p.respond_to?(method_name) }
|
16
16
|
|
17
17
|
if pretender
|
18
|
+
if defined? Rails
|
19
|
+
deprecation_warning = I18n.t('great_pretender.deprecated_pretender')
|
20
|
+
deprecation_warning_args = [method_name, pretender.class.name.underscore.gsub(/_pretender$/, ''), method_name]
|
21
|
+
Rails.logger.debug deprecation_warning % deprecation_warning_args
|
22
|
+
end
|
18
23
|
pretender.send(method_name, *args, &block)
|
19
24
|
else
|
20
25
|
super(method_name, *args, &block)
|
@@ -1,8 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'great_pretender/pretender'
|
4
|
+
require 'i18n'
|
4
5
|
require 'ostruct'
|
5
6
|
|
7
|
+
module Rails
|
8
|
+
def self.logger
|
9
|
+
@logger ||= Class.new do
|
10
|
+
def debug(msg)
|
11
|
+
puts msg
|
12
|
+
end
|
13
|
+
end.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
6
17
|
class PrefixSlugPretender
|
7
18
|
def say_hello
|
8
19
|
"Hello, guest!"
|
@@ -29,6 +40,10 @@ class TestSlugsPretender
|
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
43
|
+
|
44
|
+
I18n.load_path = Dir['config/locales/*.yml']
|
45
|
+
I18n.enforce_available_locales = false
|
46
|
+
|
32
47
|
describe GreatPretender::Pretender do
|
33
48
|
|
34
49
|
let(:mockup) { OpenStruct.new(slug: "prefix_slug/test_slug") }
|
@@ -38,15 +53,25 @@ describe GreatPretender::Pretender do
|
|
38
53
|
Class.new { include mod }.new
|
39
54
|
end
|
40
55
|
|
41
|
-
|
56
|
+
let(:deprecation_warning) { }
|
57
|
+
|
58
|
+
before do |example, options|
|
59
|
+
if example.metadata[:deprecations]
|
60
|
+
deprecation_warning = I18n.t('great_pretender.deprecated_pretender')
|
61
|
+
deprecation_warning = deprecation_warning % example.metadata[:deprecations]
|
62
|
+
expect(Rails.logger).to receive(:debug).with(deprecation_warning)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "delegates methods to pretenders named after mockups", deprecations: %w(ohai test_slugs ohai) do
|
42
67
|
expect(recipient.ohai).to eq("ohai")
|
43
68
|
end
|
44
69
|
|
45
|
-
it "delegates methods to pretenders in the slug chain" do
|
70
|
+
it "delegates methods to pretenders in the slug chain", deprecations: %w(say_hello prefix_slug say_hello) do
|
46
71
|
expect(recipient.say_hello).to eq("Hello, guest!")
|
47
72
|
end
|
48
73
|
|
49
|
-
it "delegates methods to the most specific responder" do
|
74
|
+
it "delegates methods to the most specific responder", deprecations: %w(name test_slugs name) do
|
50
75
|
expect(recipient.name).to eq("Avery")
|
51
76
|
end
|
52
77
|
|
@@ -63,4 +88,5 @@ describe GreatPretender::Pretender do
|
|
63
88
|
pretenderless_mockup = OpenStruct.new(slug: "no_pretender_mockup")
|
64
89
|
expect(-> { GreatPretender::Pretender.new(pretenderless_mockup) } ).not_to raise_error
|
65
90
|
end
|
91
|
+
|
66
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: great_pretender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flip Sasser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.2.2
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Ridiculously easy-to-use Rails mockups for those enlightened individuals
|