much-rails 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
  SHA256:
3
- metadata.gz: '08eb433f0b2e7fa04acaa6aec285a57d6c2988dc34067cb0ef401992a02125c4'
4
- data.tar.gz: dc1a2ddf9997e2aa2577a1100efedb52e4a3d89b2abc5ee6a8150626a5b42129
3
+ metadata.gz: e37cec5104bf60569eb8a0310184ed80c9083fa3fa0f68fcd02d0ee1a25aee92
4
+ data.tar.gz: e2cffa2635a4fe025913d78ce78f81dcaba12b232129969ed0a3646a6d8c9928
5
5
  SHA512:
6
- metadata.gz: d5178f432b4f6fd2712036e951742301b52565161e4d1387915315ea5a661beaa5b8d11935ae8eb7f761c76430f7afd1ba2243a0178d5fa7f155ac5a0751a934
7
- data.tar.gz: 7aa259619b17110e7ce6ec81defa760b2ae6494b2e4e1eb6677f9ba003d4ad4312f046ff806680c8bbed11b2af92a09d86640cec904be20627fec52870a2ae3b
6
+ metadata.gz: cfd22f4cdd2dd60540e417606990bdcd13ac92cb1e83d6175462ac37aa066de6c478c0c06dcb27af6112ec35eb0fcd1c0828375cdbbc9e8e60e6f1d4a2249cce
7
+ data.tar.gz: e7c12b68abe00c404d4ab361ea1a5f49150a8877bf30619b7f01b478190cd14a027f3fec543c0d604339993a5803d9340251d53989d780d692015960e40cb075
@@ -50,6 +50,14 @@ module MuchRails::Layout
50
50
  @javascripts ||= []
51
51
  end
52
52
 
53
+ def head_link(url, **attributes)
54
+ head_links << HeadLink.new(url, **attributes)
55
+ end
56
+
57
+ def head_links
58
+ @head_links ||= []
59
+ end
60
+
53
61
  def layout(value)
54
62
  layouts << value
55
63
  end
@@ -104,12 +112,31 @@ module MuchRails::Layout
104
112
  @javascripts ||= self.class.javascripts.map(&:call)
105
113
  end
106
114
 
107
- def any_breadcrumbs?
108
- breadcrumbs.any?
115
+ def head_links
116
+ @head_links ||= self.class.head_links
109
117
  end
110
118
 
111
119
  def layouts
112
120
  self.class.layouts
113
121
  end
122
+
123
+ def any_breadcrumbs?
124
+ breadcrumbs.any?
125
+ end
126
+ end
127
+
128
+ class HeadLink
129
+ attr_reader :href, :attributes
130
+
131
+ def initialize(href, **attributes)
132
+ @href = href
133
+ @attributes = attributes
134
+ end
135
+
136
+ def ==(other)
137
+ super unless other.is_a?(self.class)
138
+
139
+ href == other.href && attributes == other.attributes
140
+ end
114
141
  end
115
142
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuchRails
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -6,9 +6,9 @@ require "much-rails/layout"
6
6
  module MuchRails::Layout
7
7
  class UnitTests < Assert::Context
8
8
  desc "MuchRails::Layout"
9
- subject{ unit_class }
9
+ subject{ unit_module }
10
10
 
11
- let(:unit_class){ MuchRails::Layout }
11
+ let(:unit_module){ MuchRails::Layout }
12
12
 
13
13
  should "include MuchRails::Mixin" do
14
14
  assert_that(subject).includes(MuchRails::Mixin)
@@ -30,15 +30,16 @@ module MuchRails::Layout
30
30
  end
31
31
 
32
32
  should have_imeths :page_title, :page_titles, :application_page_title
33
- should have_imeths :breadcrumb, :breadcrumbs, :stylesheet, :stylesheets
34
- should have_imeths :javascript, :javascripts, :layout, :layouts
33
+ should have_imeths :breadcrumb, :breadcrumbs
34
+ should have_imeths :stylesheet, :stylesheets, :javascript, :javascripts
35
+ should have_imeths :head_link, :head_links, :layout, :layouts
35
36
  end
36
37
 
37
38
  class InitTests < ReceiverTests
38
39
  desc "when init"
39
40
  subject{ receiver_class.new }
40
41
 
41
- should "know its #page_title" do
42
+ should "know its page title" do
42
43
  assert_that(subject.page_title).is_nil
43
44
 
44
45
  receiver_class.page_title{ "Some Portal" }
@@ -47,7 +48,7 @@ module MuchRails::Layout
47
48
  assert_that(subject.page_title).equals("Some Resource attribute1")
48
49
  end
49
50
 
50
- should "know its #application_page_title" do
51
+ should "know its application page title" do
51
52
  assert_that(subject.application_page_title).is_nil
52
53
 
53
54
  receiver_class.application_page_title{ "Some App" }
@@ -56,12 +57,12 @@ module MuchRails::Layout
56
57
  assert_that(subject.application_page_title).equals("Some App attribute1")
57
58
  end
58
59
 
59
- should "know its #full_page_title "\
60
+ should "know its full page title "\
60
61
  "given no application page title or page title segments" do
61
62
  assert_that(subject.full_page_title).is_nil
62
63
  end
63
64
 
64
- should "know its #full_page_title "\
65
+ should "know its full page title "\
65
66
  "given an application page title but no page title segments" do
66
67
  receiver_class.application_page_title{ "Some App" }
67
68
 
@@ -69,7 +70,7 @@ module MuchRails::Layout
69
70
  .equals(subject.application_page_title)
70
71
  end
71
72
 
72
- should "know its #full_page_title "\
73
+ should "know its full page title "\
73
74
  "given no application page title but page title segments" do
74
75
  receiver_class.page_title{ "Some Portal" }
75
76
  receiver_class.page_title{ "Some Resource #{attribute1}" }
@@ -78,7 +79,7 @@ module MuchRails::Layout
78
79
  .equals("Some Resource attribute1 - Some Portal")
79
80
  end
80
81
 
81
- should "know its #full_page_title "\
82
+ should "know its full page title "\
82
83
  "given both an application page title and page title segments" do
83
84
  receiver_class.application_page_title{ "Some App" }
84
85
  receiver_class.page_title{ "Some Portal" }
@@ -88,13 +89,14 @@ module MuchRails::Layout
88
89
  .equals("Some Resource attribute1 - Some Portal | Some App")
89
90
  end
90
91
 
91
- should "know its #breadcrumbs" do
92
+ should "know its breadcrumbs" do
92
93
  receiver = receiver_class.new
94
+ assert_that(receiver.any_breadcrumbs?).is_false
93
95
  assert_that(receiver.breadcrumbs).is_empty
94
96
 
95
97
  receiver_class.breadcrumb{ ["Item1", "item1-url"] }
96
98
  receiver_class.breadcrumb{ "Item2" }
97
-
99
+ assert_that(subject.any_breadcrumbs?).is_true
98
100
  assert_that(subject.breadcrumbs)
99
101
  .equals([
100
102
  MuchRails::ViewModels::Breadcrumb.new("Item1", "item1-url"),
@@ -102,7 +104,7 @@ module MuchRails::Layout
102
104
  ])
103
105
  end
104
106
 
105
- should "know its #stylesheets" do
107
+ should "know its stylesheets" do
106
108
  receiver = receiver_class.new
107
109
  assert_that(receiver.stylesheets).is_empty
108
110
 
@@ -116,7 +118,7 @@ module MuchRails::Layout
116
118
  ])
117
119
  end
118
120
 
119
- should "know its #javascripts" do
121
+ should "know its javascripts" do
120
122
  receiver = receiver_class.new
121
123
  assert_that(receiver.javascripts).is_empty
122
124
 
@@ -134,12 +136,16 @@ module MuchRails::Layout
134
136
  ])
135
137
  end
136
138
 
137
- should "know its #any_breadcrumbs?" do
139
+ should "know its head links" do
138
140
  receiver = receiver_class.new
139
- assert_that(receiver.any_breadcrumbs?).is_false
141
+ assert_that(receiver.head_links).is_empty
140
142
 
141
- receiver_class.breadcrumb{ "Item2" }
142
- assert_that(subject.any_breadcrumbs?).is_true
143
+ url1 = Factory.url
144
+ attributes1 = { some_attribute: Factory.string }
145
+ receiver_class.head_link(url1, **attributes1)
146
+
147
+ assert_that(subject.head_links)
148
+ .equals([unit_module::HeadLink.new(url1, **attributes1)])
143
149
  end
144
150
 
145
151
  should "know its #layouts" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: much-rails
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
  - Kelly Redding