text_helpers 0.7.0 → 0.7.1

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: 903554bdd7d36e4e370e3ee49c9b4fea2ce583c0
4
- data.tar.gz: a44bc31df0e1ee330828bc7fce8c744cef1b851a
3
+ metadata.gz: aab61ab2ec51e7a9457ad3fc762341ecc59862b7
4
+ data.tar.gz: 687b06a1b1ee2447c5fb29248307f74726550589
5
5
  SHA512:
6
- metadata.gz: cd7cbf44933933fde4fef80f20346ce5f69acef7c5faf5842f73397db143ec3a13b59b2ada6ced119fc9500b76f0a1ff832d81d3bce9cf8f4054168c8f712a1b
7
- data.tar.gz: ce8278cd00a6b9ec4df5e4aaaf9ae6486fb5a4e7212b9f4d0528647f05a32104958b01df0fe2e333ef0350130070f41357f8ec011c8e0a6b7094e94077c3b74d
6
+ metadata.gz: c03051dbfce0714ee802493eb44ecabeeb669b9eef87a847b5a21c3a03380832f247ed9192032b804dd8363046fe8c474600fbd3bc16c221587d7337bf380f2a
7
+ data.tar.gz: 800a199fde5ee931a01078e1a08f2587952b577c9852b30dae3ea726f24cd3d6740edd96d1277871718df97f815b72bb80f16bc1cb1dd1c65d09ce2dbfbe7438
data/README.md CHANGED
@@ -60,7 +60,9 @@ The controller text helpers described above can be accessed in controller specs
60
60
 
61
61
  ### Temporary/Stub Localizations
62
62
 
63
- `text_helpers/rspec.rb` contains some helpers for setting up a test localization environment during your test runs.
63
+ `text_helpers/rspec.rb` contains some helpers for setting up a test localization
64
+ environment during your test runs. You can enable the helper methods by adding
65
+ the `:text_helpers` tag to the examples that require them.
64
66
 
65
67
  To configure it, `require "text_helpers/rspec"` and configure the `before` and
66
68
  `after` hooks appropriately:
@@ -69,11 +71,13 @@ To configure it, `require "text_helpers/rspec"` and configure the `before` and
69
71
  require 'text_helpers/rspec'
70
72
 
71
73
  RSpec.configure do |config|
74
+ config.include TextHelpers::RSpec::TestHelpers, text_helpers: true
75
+
72
76
  config.before(:suite) do
73
77
  TextHelpers::RSpec.setup_spec_translations
74
78
  end
75
79
 
76
- config.after(:each) do
80
+ config.after(:each, :text_helpers) do
77
81
  TextHelpers::RSpec.reset_spec_translations
78
82
  end
79
83
  end
@@ -83,7 +87,13 @@ Temporary localizations can then be defined within your examples via the
83
87
  `#set_translation` method, like so:
84
88
 
85
89
  ```
86
- set_translation('models.user.attributes.name', 'Name')
90
+ describe "with a translation set", :text_helpers do
91
+ before do
92
+ set_translation('models.user.attributes.name', 'Name')
93
+ end
94
+
95
+ it { ... }
96
+ end
87
97
  ```
88
98
 
89
99
  ## Configuration & Initialization
@@ -22,7 +22,7 @@ module TextHelpers
22
22
 
23
23
  module Translation
24
24
 
25
- ORPHAN_MATCHER = /\s(?![^<]*>)(\S+\s*<\/(?:p|li)>)/.freeze
25
+ ORPHAN_MATCHER = /[ \t](?![^<]*>)(\S+\s*<\/(?:p|li)>)/.freeze
26
26
 
27
27
  # Public: Get the I18n localized text for the passed key.
28
28
  #
@@ -82,7 +82,7 @@ module TextHelpers
82
82
  smartify(@renderer.render(text))
83
83
  end
84
84
 
85
- # Protected: Auto-apply smart quotes and to the passed text.
85
+ # Internal: Auto-apply smart quotes to the passed text.
86
86
  #
87
87
  # text - A String which should be passed through the SmartyPants renderer.
88
88
  #
@@ -91,16 +91,16 @@ module TextHelpers
91
91
  Redcarpet::Render::SmartyPants.render(text)
92
92
  end
93
93
 
94
- # Protected: The proper scope for I18n translation.
94
+ # Internal: The proper scope for I18n translation.
95
95
  #
96
96
  # Must be implemented by any classes which include this module.
97
97
  #
98
98
  # Raises NotImplementedError.
99
99
  def translation_scope
100
- raise NotImplementedError
100
+ raise NotImplementedError, "must implement a public method `translation_scope` to determine I18n scope"
101
101
  end
102
102
 
103
- # Protected: Convert all passed in arguments into html-safe strings
103
+ # Internal: Convert all passed in arguments into html-safe strings
104
104
  #
105
105
  # hash - a set of key-value pairs, which converts the second argument into an html-safe string
106
106
  #
@@ -1,3 +1,3 @@
1
1
  module TextHelpers
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -9,6 +9,7 @@ describe TextHelpers::Translation do
9
9
  before do
10
10
  @scoped_text = "Scoped lookup"
11
11
  @global_text = "Global lookup"
12
+ @single_word_text = "Single"
12
13
  @email_address = "user@example.org"
13
14
  @multiline_text = <<-MULTI.gsub(/^[ \t]+/, '')
14
15
  This is some multiline text.
@@ -30,6 +31,7 @@ describe TextHelpers::Translation do
30
31
  email_key: "<#{@email_address}>",
31
32
  test_key: "*#{@scoped_text}*",
32
33
  list_key: "* #{@scoped_text}",
34
+ single_word_list_key: "* #{@single_word_text}",
33
35
  interpolated_key: "Global? (!test_key!)",
34
36
  interpolated_scoped_key: "Global? (!test_scoped_key!)",
35
37
  interpol_arg_key: "Interpolate global? (!interpolated_key!)",
@@ -74,6 +76,16 @@ describe TextHelpers::Translation do
74
76
  assert_equal expected, @helper.html(:list_key)
75
77
  end
76
78
 
79
+ it "does not inject `&nbsp;` entities in HTML list items unnecessarily" do
80
+ expected = <<-EXPECTED.gsub(/^[ \t]+/, '')
81
+ <ul>
82
+ <li>#{@single_word_text}</li>
83
+ </ul>
84
+ EXPECTED
85
+
86
+ assert_equal expected, @helper.html(:single_word_list_key)
87
+ end
88
+
77
89
  it "does not modify HTML tags" do
78
90
  expected = "<p><a href=\"mailto:#{@email_address}\">#{@email_address}</a></p>\n"
79
91
  assert_equal expected, @helper.html(:email_key)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
11
+ date: 2019-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport