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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be13699344821526b0f5bb5bd0be76401d32b24f
4
- data.tar.gz: d7f7f6e97097818c566be9ab78cd6a7226f7fa12
3
+ metadata.gz: ded13adb89cf39cbc783b42fec961b8d1918a0e5
4
+ data.tar.gz: 5a3842182ee81c1acb8fb1937208a0f40f7ca45e
5
5
  SHA512:
6
- metadata.gz: 6d4a07e77ef31ff590cda5c8fe437a1ed28d894424b0d95309bdf870903264d05f061a6c8e81a1409da48930117d26ef73898e96c74cc1d2e658d8befdfb6c87
7
- data.tar.gz: a4c3842bd70ab69c3953223b79cf9723c1814e6c316ccc81dfcd47a849d13b45354f79fe9aa38f5f35015ae7c17ba4e4cbb6aee8b2a3355c50e34a809731efc7
6
+ metadata.gz: 492883658952702e1d4edf14d76a148e3c080d293a3ac72aeca6339d397d115d87258693e7f931be9c6f863b6bf43a0ccfa356f95f874fb40d47aa94283949f8
7
+ data.tar.gz: 2e77e4ce36db26b0ff71a39ec85f70260e0fb981b57d425fee7949646b61c5753aa3e8e4c65eb6ae1780f62b280cbcda847541dbe3fc5b03fb317bd403a59097
@@ -1,7 +1,7 @@
1
1
  require 'great_pretender/controller'
2
2
 
3
3
  module GreatPretender
4
- class MockupsController < ::ApplicationController
4
+ class MockupsController < GreatPretender.config.base_controller
5
5
 
6
6
  include GreatPretender::Controller
7
7
 
@@ -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."
@@ -1,7 +1,14 @@
1
1
  module GreatPretender
2
2
 
3
3
  class Config
4
+
4
5
  attr_accessor :default_layout, :path_separator, :view_path
6
+ attr_writer :base_controller
7
+
8
+ def base_controller
9
+ @base_controller ||= ::ApplicationController
10
+ end
11
+
5
12
  end
6
13
 
7
14
  def self.config
@@ -11,7 +11,7 @@ module GreatPretender
11
11
  end
12
12
 
13
13
  def index
14
- render template: 'great_pretender/index'
14
+ render template: 'great_pretender/index', layout: GreatPretender.config.default_layout
15
15
  end
16
16
 
17
17
  def show
@@ -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,3 +1,3 @@
1
1
  module GreatPretender
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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
- it "delegates methods to pretenders named after mockups" do
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.2
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-08-08 00:00:00.000000000 Z
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.4.1
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