apotomo 1.1.3 → 1.1.4
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/.travis.yml +3 -0
- data/CHANGES.textile +2 -2
- data/README.rdoc +2 -0
- data/apotomo.gemspec +1 -1
- data/lib/apotomo/event_handler.rb +1 -0
- data/lib/apotomo/test_case.rb +38 -30
- data/lib/apotomo/version.rb +1 -1
- data/lib/generators/templates/widget_test.rb +2 -2
- data/test/rails/widget_generator_test.rb +1 -1
- data/test/test_helper.rb +2 -0
- data/test/unit/test_case_test.rb +18 -0
- metadata +6 -5
data/.travis.yml
ADDED
data/CHANGES.textile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
h2. 1.
|
1
|
+
h2. 1.1.4
|
2
2
|
|
3
3
|
h3. Changes
|
4
4
|
* New signature: @TestCase#trigger(type, source, options)@. This method no longer messes around with the widget's options hash but simply passes any additional options to @evt#data@. Also, the event @source@ is now the required second argument.
|
5
|
-
|
5
|
+
* We now got @TestCase#view_assigns@ to access instance variables from the last rendered widget.
|
6
6
|
|
7
7
|
h2. 1.1.1
|
8
8
|
|
data/README.rdoc
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
<em>Web Components for Rails.</em>
|
4
4
|
|
5
|
+
{<img src="https://secure.travis-ci.org/apotonick/apotomo.png" />}[http://travis-ci.org/apotonick/apotomo]
|
6
|
+
|
5
7
|
== Overview
|
6
8
|
|
7
9
|
Do you need an <b>interactive user interface</b> for your Rails application? A cool Rich Client Application with dashboards, portlets and AJAX, Drag&Drop and jQuery?
|
data/apotomo.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "cells", ">= 3.
|
22
|
+
s.add_dependency "cells", ">= 3.6.7"
|
23
23
|
s.add_dependency "onfire", "~> 0.2.0"
|
24
24
|
s.add_dependency "hooks", "~> 0.1.3"
|
25
25
|
|
data/lib/apotomo/test_case.rb
CHANGED
@@ -10,10 +10,10 @@ module Apotomo
|
|
10
10
|
# has_widgets do |root|
|
11
11
|
# root << widget(:comments_widget, 'post-comments')
|
12
12
|
# end
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# it "should be rendered nicely" do
|
15
15
|
# render_widget 'post-comments'
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# assert_select "div#post-comments", "Comments for this post"
|
18
18
|
# end
|
19
19
|
#
|
@@ -29,17 +29,36 @@ module Apotomo
|
|
29
29
|
# end
|
30
30
|
#
|
31
31
|
# See also in Cell::TestCase.
|
32
|
-
class TestCase < Cell::TestCase
|
32
|
+
class TestCase < Cell::TestCase # TODO: re-arrange modules in Cell::TestCase and include instead of inheritance.
|
33
33
|
# Generic test methods to be used in Test::Unit, RSpec, etc.
|
34
34
|
module TestMethods
|
35
35
|
extend ActiveSupport::Concern
|
36
|
-
|
36
|
+
|
37
37
|
module InstanceMethods
|
38
|
+
include Cell::TestCase::CommonTestMethods
|
39
|
+
|
40
|
+
attr_reader :view_assigns
|
41
|
+
|
42
|
+
def setup
|
43
|
+
super # defined in Cell::TestCase::CommonTestMethods.
|
44
|
+
|
45
|
+
@controller.instance_eval do
|
46
|
+
def controller_path
|
47
|
+
'barn'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
@controller.extend Apotomo::Rails::ControllerMethods
|
51
|
+
end
|
52
|
+
|
38
53
|
# Renders the widget +name+.
|
39
54
|
def render_widget(*args)
|
40
|
-
@
|
55
|
+
@view_assigns = extract_state_ivars_for(root[args.first]) do
|
56
|
+
@last_invoke = root.render_widget(*args)
|
57
|
+
end
|
58
|
+
|
59
|
+
@last_invoke
|
41
60
|
end
|
42
|
-
|
61
|
+
|
43
62
|
# Triggers an event of +type+. You have to pass the +source+ as second options.
|
44
63
|
#
|
45
64
|
# Example:
|
@@ -50,7 +69,7 @@ module Apotomo
|
|
50
69
|
source.fire(type, options)
|
51
70
|
root.page_updates
|
52
71
|
end
|
53
|
-
|
72
|
+
|
54
73
|
# Returns the widget tree from TestCase.has_widgets.
|
55
74
|
def root
|
56
75
|
blk = self.class.has_widgets_blocks or raise "Please setup a widget tree using has_widgets()"
|
@@ -58,36 +77,25 @@ module Apotomo
|
|
58
77
|
self.instance_exec(root, &blk)
|
59
78
|
end
|
60
79
|
end
|
80
|
+
|
81
|
+
def parent_controller
|
82
|
+
@controller
|
83
|
+
end
|
61
84
|
end
|
62
|
-
|
85
|
+
|
63
86
|
module ClassMethods
|
64
87
|
def has_widgets_blocks
|
65
88
|
@has_widgets
|
66
89
|
end
|
67
|
-
|
90
|
+
|
68
91
|
# Setup a widget tree as you're used to it from your controller. Executed in test context.
|
69
92
|
def has_widgets(&block)
|
70
93
|
@has_widgets = block
|
71
94
|
end
|
72
95
|
end
|
73
96
|
end
|
74
|
-
|
75
|
-
|
76
|
-
def setup
|
77
|
-
super
|
78
|
-
@controller.instance_eval do
|
79
|
-
def controller_path
|
80
|
-
'barn'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
@controller.extend Apotomo::Rails::ControllerMethods
|
84
|
-
end
|
85
|
-
|
86
|
-
def parent_controller
|
87
|
-
@controller
|
88
|
-
end
|
89
|
-
|
90
|
-
# After a #trigger this assertion compares the actually triggered page updates with the passed.
|
97
|
+
|
98
|
+
# After a #trigger this assertion compares the actually triggered page updates with the passed.
|
91
99
|
#
|
92
100
|
# Example:
|
93
101
|
#
|
@@ -95,19 +103,19 @@ module Apotomo
|
|
95
103
|
# assert_response "alert(\":submit clicked!\")", /\$\("post-comments"\).update/
|
96
104
|
def assert_response(*content)
|
97
105
|
updates = root.page_updates
|
98
|
-
|
106
|
+
|
99
107
|
i = 0
|
100
108
|
content.each do |assertion|
|
101
109
|
if assertion.kind_of? Regexp
|
102
|
-
assert_match assertion, updates[i]
|
110
|
+
assert_match assertion, updates[i]
|
103
111
|
else
|
104
112
|
assert_equal assertion, updates[i]
|
105
113
|
end
|
106
|
-
|
114
|
+
|
107
115
|
i+=1
|
108
116
|
end
|
109
117
|
end
|
110
|
-
|
118
|
+
|
111
119
|
include Apotomo::WidgetShortcuts
|
112
120
|
include TestMethods
|
113
121
|
end
|
data/lib/apotomo/version.rb
CHANGED
@@ -2,11 +2,11 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class <%= class_name %>WidgetTest < Apotomo::TestCase
|
4
4
|
has_widgets do |root|
|
5
|
-
root << widget(:<%= file_name
|
5
|
+
root << widget(:<%= file_name %>)
|
6
6
|
end
|
7
7
|
|
8
8
|
test "display" do
|
9
|
-
render_widget
|
9
|
+
render_widget :<%= file_name %>
|
10
10
|
assert_select "h1"
|
11
11
|
end
|
12
12
|
end
|
@@ -20,7 +20,7 @@ class WidgetGeneratorTest < Rails::Generators::TestCase
|
|
20
20
|
assert_file "app/widgets/gerbil/squeak.html.erb", %r(app/widgets/gerbil/squeak\.html\.erb)
|
21
21
|
|
22
22
|
assert_file "test/widgets/gerbil_widget_test.rb", %r(class GerbilWidgetTest < Apotomo::TestCase)
|
23
|
-
assert_file "test/widgets/gerbil_widget_test.rb", %r(widget\(:gerbil
|
23
|
+
assert_file "test/widgets/gerbil_widget_test.rb", %r(widget\(:gerbil\))
|
24
24
|
end
|
25
25
|
|
26
26
|
should "create haml assets with -e haml" do
|
data/test/test_helper.rb
CHANGED
data/test/unit/test_case_test.rb
CHANGED
@@ -77,6 +77,24 @@ class TestCaseTest < Test::Unit::TestCase
|
|
77
77
|
assert @test.assert_response("{}")
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
context "#view_assigns" do
|
82
|
+
should "be emtpy when nothing was set" do
|
83
|
+
@test.render_widget('mum')
|
84
|
+
assert_equal({}, @test.view_assigns)
|
85
|
+
end
|
86
|
+
|
87
|
+
should "return the instance variables from the last #render_widget" do
|
88
|
+
@mum = @test.root['mum']
|
89
|
+
@mum.instance_eval do
|
90
|
+
def sleep
|
91
|
+
@duration = "8h"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
@test.render_widget('mum', :sleep)
|
95
|
+
assert_equal({:duration => "8h"}, @test.view_assigns)
|
96
|
+
end
|
97
|
+
end
|
80
98
|
end
|
81
99
|
|
82
100
|
context "responding to parent_controller" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 4
|
9
|
+
version: 1.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Sutterer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-09-
|
17
|
+
date: 2011-09-28 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,9 +27,9 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 3
|
30
|
-
- 5
|
31
30
|
- 6
|
32
|
-
|
31
|
+
- 7
|
32
|
+
version: 3.6.7
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -138,6 +138,7 @@ extra_rdoc_files: []
|
|
138
138
|
|
139
139
|
files:
|
140
140
|
- .gitignore
|
141
|
+
- .travis.yml
|
141
142
|
- CHANGES.textile
|
142
143
|
- Gemfile
|
143
144
|
- README.rdoc
|