rad_core 0.0.30 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require 'rake_ext'
2
2
 
3
3
  project(
4
4
  name: 'rad',
5
+ version: '0.2.0',
5
6
  official_name: 'rad_core',
6
7
  gem: true,
7
8
  summary: 'Simple and highly customizable Web Framework encouraging to build an app as a set of low-coupled components instead of monolith',
data/lib/rad/gems.rb CHANGED
@@ -1,23 +1,10 @@
1
- # core gems dependencies
2
- # gem 'i18n', '0.5.0'
3
- # gem 'polyglot', '0.3.1'
4
- # gem 'treetop', '1.4.9'
5
- # gem 'mime-types', '1.16'
6
-
7
- # core gems
8
1
  gem 'activesupport', '3.0.7'
9
- # gem 'builder', '2.1.2'
10
-
11
2
  gem 'haml', '3.0.25'
12
3
  gem 'tilt', '1.2.1'
13
-
14
4
  gem 'json', '1.4.6'
15
5
  gem 'addressable', '2.2.2'
16
- # gem 'nokogiri', '1.4.4'
17
-
18
6
  gem 'rack', '1.3.0'
19
7
  gem 'thin', '1.2.7'
20
-
21
8
  gem 'mail', '2.2.14'
22
9
 
23
10
  if respond_to? :fake_gem
@@ -25,4 +12,21 @@ if respond_to? :fake_gem
25
12
  fake_gem 'vfs'
26
13
  fake_gem 'micon'
27
14
  fake_gem 'class_loader'
28
- end
15
+ end
16
+
17
+ #
18
+ # Gems for specs
19
+ #
20
+ # gem 'nokogiri', '1.4.4'
21
+
22
+
23
+ #
24
+ # Old stuff
25
+ #
26
+ # core gems dependencies
27
+ # gem 'i18n', '0.5.0'
28
+ # gem 'polyglot', '0.3.1'
29
+ # gem 'treetop', '1.4.9'
30
+ # gem 'mime-types', '1.16'
31
+ # gem 'builder', '2.1.2'
32
+ #
@@ -1,4 +1,4 @@
1
- Rspec.configure do |config|
1
+ RSpec.configure do |config|
2
2
  config.before :all do |context|
3
3
  self.response, self.workspace = nil
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require 'rad/spec/controller'
2
2
 
3
- Rspec.configure do |config|
3
+ RSpec.configure do |config|
4
4
  config.after :all do |context|
5
5
  context.wcall_options = {}
6
6
  end
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  rspec.include Rad::MailerSpecHelper
12
12
 
13
- Rspec.configure do |config|
13
+ RSpec.configure do |config|
14
14
  config.before do
15
15
  Rad::MailerSpecHelper.sent_letters = []
16
16
  end
data/lib/rad/spec.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'rspec_ext'
2
+ require 'rspec_ext/xhtml'
3
+
2
4
  require 'rad'
3
5
 
4
6
  %w(
@@ -21,11 +21,13 @@ describe "FormHelper" do
21
21
  @t.file_field_tag('item').should == %(<input class=" file_input" name="item" type="file"></input>)
22
22
  end
23
23
 
24
- it "form_tag" do
25
- @t.form_tag(id: 'the_form', action: '/'){"content"}
26
- @t.buffer.to_xhtml('#the_form').should_be_fuzzy_equal_to(
27
- id: 'the_form', action: '/', content: 'content', method: 'post'
28
- )
24
+ if String.method_defined? :to_xhtml
25
+ it "form_tag" do
26
+ @t.form_tag(id: 'the_form', action: '/'){"content"}
27
+ @t.buffer.to_xhtml('#the_form').to_fuzzy_hash.should == {id: 'the_form', action: '/', content: 'content', method: 'post'}
28
+ end
29
+ else
30
+ warn "WARN: skipping spec"
29
31
  end
30
32
 
31
33
  it "hidden_field_tag" do
@@ -9,76 +9,78 @@ describe "ModelHelper" do
9
9
  @t = MockModelHelperContext.new
10
10
  end
11
11
 
12
- it "form_for" do
13
- @t.form_for(:aname, nil, id: 'the_form', action: '/'){"content"}
14
- @t.buffer.to_xhtml('#the_form').should_be_fuzzy_equal_to(
15
- id: 'the_form', action: '/', content: 'content', method: 'post'
16
- )
17
- end
12
+ if String.method_defined? :to_xhtml
13
+ it "form_for" do
14
+ @t.form_for(:aname, nil, id: 'the_form', action: '/'){"content"}
15
+ @t.buffer.to_xhtml('#the_form').to_fuzzy_hash.should == {id: 'the_form', action: '/', content: 'content', method: 'post'}
16
+ end
18
17
 
19
- it "error_messages" do
20
- @t.form_for(:aname, nil){|f| f.error_messages}
21
- lambda{@t.buffer.to_xhtml('form div')}.should raise_error(/not found/)
18
+ it "error_messages" do
19
+ @t.form_for(:aname, nil){|f| f.error_messages}
20
+ lambda{@t.buffer.to_xhtml('form div')}.should raise_error(/not found/)
22
21
 
23
- model = {errors: {base: ['some error']}}
24
- @t.buffer = ""
25
- @t.form_for(:book, model){|f| f.error_messages}
26
- @t.buffer.to_xhtml('form div').should_be_fuzzy_equal_to class: 'error_messages', content: 'some error'
27
- end
22
+ model = {errors: {base: ['some error']}}
23
+ @t.buffer = ""
24
+ @t.form_for(:book, model){|f| f.error_messages}
25
+ @t.buffer.to_xhtml('form div').to_fuzzy_hash.should == {class: 'error_messages', content: 'some error'}
26
+ end
28
27
 
29
- it "field error" do
30
- model = {
31
- title: "Super Hero",
32
- errors: {title: ['some error in title']}
33
- }
34
- @t.form_for(:book, model){|f| f.text_field(:title)}
35
- doc = @t.buffer.to_xhtml
36
- doc.css("form div.field_error_messages").first.content.should == "some error in title"
37
- doc.css("form span.field_with_errors input").first.should_be_fuzzy_equal_to name: "book[title]", value: "Super Hero"
38
- end
28
+ it "field error" do
29
+ model = {
30
+ title: "Super Hero",
31
+ errors: {title: ['some error in title']}
32
+ }
33
+ @t.form_for(:book, model){|f| f.text_field(:title)}
34
+ doc = @t.buffer.to_xhtml
35
+ doc.css("form div.field_error_messages").first.content.should == "some error in title"
36
+ doc.css("form span.field_with_errors input").first.to_fuzzy_hash.should == {name: "book[title]", value: "Super Hero"}
37
+ end
39
38
 
40
- it "should insert human readable label if not specified" do
41
- model = {}
42
- model.stub(:t).and_return{|k| "translated #{k}"}
39
+ it "should insert human readable label if not specified" do
40
+ model = {}
41
+ model.stub(:t).and_return{|k| "translated #{k}"}
43
42
 
44
- @t.form_for(:book, model){|f| f.text_field(:title)}
45
- @t.buffer.should =~ /translated title/
43
+ @t.form_for(:book, model){|f| f.text_field(:title)}
44
+ @t.buffer.should =~ /translated title/
46
45
 
47
- @t.form_for(:book, model){|f| f.text_field(:title, label: 'some label')}
48
- @t.buffer.should =~ /some label/
49
- end
46
+ @t.form_for(:book, model){|f| f.text_field(:title, label: 'some label')}
47
+ @t.buffer.should =~ /some label/
48
+ end
50
49
 
51
- it "field_helpers" do
52
- model = {
53
- available: false,
54
- title: "Super Hero",
55
- theme: 'simple'
56
- }
50
+ it "field_helpers" do
51
+ model = {
52
+ available: false,
53
+ title: "Super Hero",
54
+ theme: 'simple'
55
+ }
57
56
 
58
- @t.form_for(:book, model){|f| %{
59
- #{f.check_box :available}
60
- #{f.file_field :title}
61
- #{f.hidden_field :title}
62
- #{f.password_field :title}
63
- #{f.radio_button :available}
64
- #{f.submit 'Ok'}
65
- #{f.text_field :title}
66
- #{f.text_area :title}
67
- #{f.select :theme, %w(a b)}
68
- } }
69
- doc = @t.buffer.to_xhtml
57
+ @t.form_for(:book, model){|f| %{
58
+ #{f.check_box :available}
59
+ #{f.file_field :title}
60
+ #{f.hidden_field :title}
61
+ #{f.password_field :title}
62
+ #{f.radio_button :available}
63
+ #{f.submit 'Ok'}
64
+ #{f.text_field :title}
65
+ #{f.text_area :title}
66
+ #{f.select :theme, %w(a b)}
67
+ } }
68
+ doc = @t.buffer.to_xhtml
70
69
 
71
- # checkbox is special case, we are using it with <input type='hidden' .../> tag.
72
- doc.css("*[type='hidden']").first.should_be_fuzzy_equal_to name: "book[available]", value: '0'
73
- doc.css("*[type='checkbox']").first.should_be_fuzzy_equal_to name: "book[available]", value: '1'
70
+ # checkbox is special case, we are using it with <input type='hidden' .../> tag.
71
+ doc.css("*[type='hidden']").first.to_fuzzy_hash.should == {name: "book[available]", value: '0'}
72
+ doc.css("*[type='checkbox']").first.to_fuzzy_hash.should == {name: "book[available]", value: '1'}
74
73
 
75
- doc.css("*[type='file']").first.should_be_fuzzy_equal_to name: "book[title]"
76
- doc.css("*[type='hidden']").last.should_be_fuzzy_equal_to name: "book[title]", value: 'Super Hero'
77
- doc.css("*[type='password']").first.should_be_fuzzy_equal_to name: "book[title]"
78
- doc.css("*[type='radio']").first.should_be_fuzzy_equal_to name: "book[available]", value: '1'
79
- doc.css("*[type='submit']").first.should_be_fuzzy_equal_to value: 'Ok'
80
- doc.css("*[type='text']").first.should_be_fuzzy_equal_to name: "book[title]", value: 'Super Hero'
81
- doc.css("textarea").first.should_be_fuzzy_equal_to name: "book[title]", content: 'Super Hero'
82
- doc.css("select").first.should_be_fuzzy_equal_to name: "book[theme]"
74
+ doc.css("*[type='file']").first.to_fuzzy_hash.should == {name: "book[title]"}
75
+ doc.css("*[type='hidden']").last.to_fuzzy_hash.should == {name: "book[title]", value: 'Super Hero'}
76
+ doc.css("*[type='password']").first.to_fuzzy_hash.should == {name: "book[title]"}
77
+ doc.css("*[type='radio']").first.to_fuzzy_hash.should == {name: "book[available]", value: '1'}
78
+ doc.css("*[type='submit']").first.to_fuzzy_hash.should == {value: 'Ok'}
79
+ doc.css("*[type='text']").first.to_fuzzy_hash.should == {name: "book[title]", value: 'Super Hero'}
80
+ doc.css("textarea").first.to_fuzzy_hash.should == {name: "book[title]", content: 'Super Hero'}
81
+ doc.css("select").first.to_fuzzy_hash.should == {name: "book[theme]"}
82
+ end
83
+ else
84
+ warn "WARN: skipping spec"
83
85
  end
84
86
  end
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'rad/spec/xhtml'
3
2
 
4
3
  class Rad::MockTemplateContext
5
4
  inherit Rad::Html::BasicHtmlHelper
@@ -54,89 +54,93 @@ describe "UrlHelper" do
54
54
  @t = MockUrlHelperContext.new
55
55
  end
56
56
 
57
- describe "link_to" do
58
- it "should works with url_for attributes" do
59
- @t.link_to('Book', Object, :method, {format: 'html'}, class: 'highlight').to_xhtml('a').
60
- should_be_fuzzy_equal_to(class: "highlight", href: "url_for: Object.method?format=html", content: 'Book')
57
+ if String.method_defined? :to_xhtml
58
+ describe "link_to" do
59
+ it "should works with url_for attributes" do
60
+ @t.link_to('Book', Object, :method, {format: 'html'}, class: 'highlight').to_xhtml('a').
61
+ to_fuzzy_hash.should == {class: "highlight", href: "url_for: Object.method?format=html", content: 'Book'}
61
62
 
62
- @t.link_to(Object, :method, {format: 'html'}, class: 'highlight'){'Book'}.to_xhtml('a').
63
- should_be_fuzzy_equal_to(class: "highlight", href: "url_for: Object.method?format=html", content: 'Book')
63
+ @t.link_to(Object, :method, {format: 'html'}, class: 'highlight'){'Book'}.to_xhtml('a').
64
+ to_fuzzy_hash.should == {class: "highlight", href: "url_for: Object.method?format=html", content: 'Book'}
64
65
 
65
- @t.link_to('Book', :method).to_xhtml('a').
66
- should_be_fuzzy_equal_to(href: "url_for: .method", content: 'Book')
67
- end
66
+ @t.link_to('Book', :method).to_xhtml('a').
67
+ to_fuzzy_hash.should == {href: "url_for: .method", content: 'Book'}
68
+ end
68
69
 
69
- it "should works with url_for_path attributes" do
70
- @t.link_to('Book', '/some_book', class: 'highlight').to_xhtml('a').
71
- should_be_fuzzy_equal_to(class: "highlight", href: "/some_book", content: 'Book')
70
+ it "should works with url_for_path attributes" do
71
+ @t.link_to('Book', '/some_book', class: 'highlight').to_xhtml('a').
72
+ to_fuzzy_hash.should == {class: "highlight", href: "/some_book", content: 'Book'}
72
73
 
73
- @t.link_to('/some_book', class: 'highlight'){'Book'}.to_xhtml('a').
74
- should_be_fuzzy_equal_to(class: "highlight", href: "/some_book", content: 'Book')
74
+ @t.link_to('/some_book', class: 'highlight'){'Book'}.to_xhtml('a').
75
+ to_fuzzy_hash.should == {class: "highlight", href: "/some_book", content: 'Book'}
75
76
 
76
- @t.link_to('/some_book'){'Book'}.to_xhtml('a').
77
- should_be_fuzzy_equal_to(href: "/some_book", content: 'Book')
78
- end
77
+ @t.link_to('/some_book'){'Book'}.to_xhtml('a').
78
+ to_fuzzy_hash.should == {href: "/some_book", content: 'Book'}
79
+ end
79
80
 
80
- it "links for 'js', 'json' formats should be automatically became remote" do
81
- @t.link_to('Book', @t.url_for('/some_book', format: 'json')).to_xhtml('a').should_be_fuzzy_equal_to(
82
- href: '#', content: 'Book',
83
- 'data-action' => 'url_for: /some_book?format=json', 'data-method' => 'post', 'data-remote' => 'true'
84
- )
81
+ it "links for 'js', 'json' formats should be automatically became remote" do
82
+ @t.link_to('Book', @t.url_for('/some_book', format: 'json')).to_xhtml('a').to_fuzzy_hash.should == {
83
+ href: '#', content: 'Book',
84
+ 'data-action' => 'url_for: /some_book?format=json', 'data-method' => 'post', 'data-remote' => 'true'
85
+ }
85
86
 
86
- @t.link_to('Book', :method, format: 'js').to_xhtml('a').should_be_fuzzy_equal_to(
87
- href: '#', content: 'Book',
88
- 'data-action' => 'url_for: .method?format=js', 'data-method' => 'post', 'data-remote' => 'true'
89
- )
87
+ @t.link_to('Book', :method, format: 'js').to_xhtml('a').to_fuzzy_hash.should == {
88
+ href: '#', content: 'Book',
89
+ 'data-action' => 'url_for: .method?format=js', 'data-method' => 'post', 'data-remote' => 'true'
90
+ }
90
91
 
91
- @t.link_to('Book', :method, {format: 'js'}, class: 'highlight').to_xhtml('a').should_be_fuzzy_equal_to(
92
- href: '#', content: 'Book', class: 'highlight',
93
- 'data-action' => 'url_for: .method?format=js', 'data-method' => 'post', 'data-remote' => 'true'
94
- )
95
- end
92
+ @t.link_to('Book', :method, {format: 'js'}, class: 'highlight').to_xhtml('a').to_fuzzy_hash.should == {
93
+ href: '#', content: 'Book', class: 'highlight',
94
+ 'data-action' => 'url_for: .method?format=js', 'data-method' => 'post', 'data-remote' => 'true'
95
+ }
96
+ end
96
97
 
97
- it "confirm" do
98
- attrs = @t.link_to('Book', '/some_book', confirm: 'Are you shure?').to_xhtml('a')
99
- attrs.should_not include('data-remote')
100
- attrs.should_not include('data-action')
101
- attrs.should_not include('data-method')
102
- attrs.should_be_fuzzy_equal_to(
103
- href: "/some_book", content: 'Book',
104
- 'data-confirm' => "Are you shure?"
105
- )
106
- end
98
+ it "confirm" do
99
+ attrs = @t.link_to('Book', '/some_book', confirm: 'Are you shure?').to_xhtml('a')
100
+ attrs.should_not include('data-remote')
101
+ attrs.should_not include('data-action')
102
+ attrs.should_not include('data-method')
103
+ attrs.to_fuzzy_hash.should == {
104
+ href: "/some_book", content: 'Book',
105
+ 'data-confirm' => "Are you shure?"
106
+ }
107
+ end
107
108
 
108
- it "POST method" do
109
- attrs = @t.link_to('Book', '/some_book', method: :post).to_xhtml('a')
110
- attrs.should_not include('data-remote')
111
- attrs.should_be_fuzzy_equal_to(
112
- href: "#", content: 'Book',
113
- 'data-action' => '/some_book', 'data-method' => 'post'
114
- )
115
- end
109
+ it "POST method" do
110
+ attrs = @t.link_to('Book', '/some_book', method: :post).to_xhtml('a')
111
+ attrs.should_not include('data-remote')
112
+ attrs.to_fuzzy_hash.should == {
113
+ href: "#", content: 'Book',
114
+ 'data-action' => '/some_book', 'data-method' => 'post'
115
+ }
116
+ end
116
117
 
117
- it "remote" do
118
- @t.link_to('Book', '/some_book', remote: true).to_xhtml('a').should_be_fuzzy_equal_to(
119
- href: "#", content: 'Book',
120
- 'data-action' => '/some_book', 'data-method' => 'post', 'data-remote' => 'true'
121
- )
122
- end
118
+ it "remote" do
119
+ @t.link_to('Book', '/some_book', remote: true).to_xhtml('a').to_fuzzy_hash.should == {
120
+ href: "#", content: 'Book',
121
+ 'data-action' => '/some_book', 'data-method' => 'post', 'data-remote' => 'true'
122
+ }
123
+ end
123
124
 
124
- it ":back" do
125
- env = Object.new
126
- env.stub(:[]).and_return('/go_back')
127
- request = Object.new
128
- request.stub(:env).and_return(env)
129
- workspace = Object.new
130
- workspace.stub(:request).and_return(request)
131
- @t.stub(:workspace).and_return(workspace)
125
+ it ":back" do
126
+ env = Object.new
127
+ env.stub(:[]).and_return('/go_back')
128
+ request = Object.new
129
+ request.stub(:env).and_return(env)
130
+ workspace = Object.new
131
+ workspace.stub(:request).and_return(request)
132
+ @t.stub(:workspace).and_return(workspace)
132
133
 
133
- @t.link_to('Book', :back).to_xhtml('a').should_be_fuzzy_equal_to(href: "/go_back", content: 'Book')
134
- @t.link_to('Book', :back, class: '_some_js_mark').to_xhtml('a').
135
- should_be_fuzzy_equal_to(href: "/go_back", class: '_some_js_mark', content: 'Book')
136
- end
134
+ @t.link_to('Book', :back).to_xhtml('a').to_fuzzy_hash.should == {href: "/go_back", content: 'Book'}
135
+ @t.link_to('Book', :back, class: '_some_js_mark').to_xhtml('a').
136
+ to_fuzzy_hash.should == {href: "/go_back", class: '_some_js_mark', content: 'Book'}
137
+ end
137
138
 
138
- it "#" do
139
- @t.link_to('Book', '#').to_xhtml('a').should_be_fuzzy_equal_to(href: "#", content: 'Book')
139
+ it "#" do
140
+ @t.link_to('Book', '#').to_xhtml('a').to_fuzzy_hash.should == {href: "#", content: 'Book'}
141
+ end
140
142
  end
143
+ else
144
+ warn "WARN: skipping spec"
141
145
  end
142
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rad_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -307,7 +307,6 @@ files:
307
307
  - lib/rad/spec/router.rb
308
308
  - lib/rad/spec/template.rb
309
309
  - lib/rad/spec/web.rb
310
- - lib/rad/spec/xhtml.rb
311
310
  - lib/rad/spec.rb
312
311
  - lib/rad/tasks.rb
313
312
  - lib/rad/template/_context.rb
@@ -1,33 +0,0 @@
1
- require 'nokogiri'
2
-
3
- class String
4
- def to_xhtml css = nil
5
- node = Nokogiri::HTML(self)
6
- unless css
7
- node
8
- else
9
- nodes = node.css(css)
10
- raise "Elements for '#{css}' CSS query not found!" if nodes.size < 1
11
- raise "Found more than one elment for '#{css}' CSS query!" if nodes.size > 1
12
- nodes.first
13
- end
14
- end
15
- end
16
-
17
- require 'nokogiri'
18
- ::Nokogiri::XML::Node.class_eval do
19
- def should_be_fuzzy_equal_to attributes
20
- node_attributes = {}
21
-
22
- attributes.each do |k, v|
23
- nv = if k.to_s == 'content'
24
- self.content
25
- else
26
- self[k.to_s]
27
- end
28
- node_attributes[k] = nv
29
- end
30
-
31
- node_attributes.should == attributes
32
- end
33
- end