rspec-apotomo 0.9.1 → 0.9.2
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/CHANGES.mkd +5 -0
- data/README.mkd +1 -1
- data/lib/rspec-apotomo/version.rb +1 -1
- data/lib/rspec/rails/example/widget_example_group.rb +46 -12
- data/rspec-apotomo.gemspec +2 -1
- data/spec/rspec-apotomo/widget_example_group_spec.rb +12 -25
- data/spec/rspec-apotomo/with_capybara_spec.rb +15 -0
- data/spec/spec_helper.rb +29 -1
- metadata +22 -8
data/CHANGES.mkd
CHANGED
data/README.mkd
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
*Spec your widgets!*
|
4
4
|
|
5
|
-
[](http://travis-ci.org/apotonick/rspec-apotomo)
|
6
6
|
|
7
7
|
This gem allows you to test widgets with [Apotomo](http://apotomo.de) via RSpec.
|
8
8
|
|
@@ -1,32 +1,66 @@
|
|
1
1
|
require 'apotomo'
|
2
2
|
require 'apotomo/test_case'
|
3
|
+
require 'rspec/rails'
|
3
4
|
|
4
5
|
module RSpec::Rails
|
5
6
|
module WidgetExampleGroup
|
6
7
|
extend ActiveSupport::Concern
|
7
8
|
|
9
|
+
include RSpec::Rails::RailsExampleGroup
|
10
|
+
|
8
11
|
include Apotomo::TestCase::TestMethods
|
9
|
-
|
12
|
+
|
13
|
+
if defined?(Webrat)
|
14
|
+
include Webrat::Matchers
|
15
|
+
include Webrat::Methods
|
16
|
+
end
|
17
|
+
|
18
|
+
if defined?(Capybara)
|
19
|
+
begin
|
20
|
+
include Capybara::DSL
|
21
|
+
rescue NameError
|
22
|
+
include Capybara
|
23
|
+
end
|
24
|
+
|
25
|
+
# Overwrite to wrap render_widget into a Capybara custom string with a
|
26
|
+
# lot of matchers.
|
27
|
+
#
|
28
|
+
# Read more at:
|
29
|
+
#
|
30
|
+
# The Capybara.string method documentation:
|
31
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara#string-class_method
|
32
|
+
#
|
33
|
+
# Return value is an instance of Capybara::Node::Simple
|
34
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Simple
|
35
|
+
#
|
36
|
+
# That expose all the methods from the following capybara modules:
|
37
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers
|
38
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders
|
39
|
+
def render_widget(*args)
|
40
|
+
@last_invoke = Capybara.string super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
10
44
|
included do
|
11
45
|
before do
|
12
|
-
|
13
|
-
@
|
14
|
-
|
15
|
-
|
46
|
+
setup # defined in Apotomo::TestCase.
|
47
|
+
@routes = ::Rails.application.routes
|
48
|
+
ActionController::Base.allow_forgery_protection = false
|
49
|
+
@controller.request = ::ActionController::TestRequest.new
|
50
|
+
@controller.class_eval do
|
51
|
+
include Rails.application.routes.url_helpers
|
16
52
|
end
|
17
|
-
|
18
|
-
@parent_controller.request = ::ActionController::TestRequest.new
|
19
53
|
end
|
54
|
+
|
55
|
+
subject { controller }
|
20
56
|
end
|
21
|
-
|
22
|
-
|
57
|
+
|
23
58
|
module InstanceMethods
|
24
|
-
|
25
|
-
def response
|
59
|
+
def rendered
|
26
60
|
@last_invoke
|
27
61
|
end
|
28
62
|
|
29
|
-
attr_reader :
|
63
|
+
attr_reader :controller, :routes
|
30
64
|
include ::Apotomo::WidgetShortcuts
|
31
65
|
end
|
32
66
|
end
|
data/rspec-apotomo.gemspec
CHANGED
@@ -17,8 +17,9 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_runtime_dependency('rails', ['~> 3.0'])
|
19
19
|
gem.add_runtime_dependency('rspec-rails', ['~> 2.6'])
|
20
|
-
gem.add_runtime_dependency('apotomo', ['>= 1.1.
|
20
|
+
gem.add_runtime_dependency('apotomo', ['>= 1.1.4'])
|
21
21
|
|
22
|
+
gem.add_development_dependency('capybara')
|
22
23
|
gem.add_development_dependency('guard-rspec')
|
23
24
|
gem.add_development_dependency('rb-fsevent')
|
24
25
|
gem.add_development_dependency('growl')
|
@@ -1,22 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require "action_controller/railtie"
|
3
|
-
require 'rspec/rails/example/widget_example_group'
|
4
|
-
|
5
|
-
# This class is used as a dummy widget for testing
|
6
|
-
class DummyWidget < Apotomo::Widget
|
7
|
-
responds_to_event :doo
|
8
|
-
|
9
|
-
def display
|
10
|
-
render
|
11
|
-
end
|
12
|
-
end
|
13
|
-
DummyWidget.append_view_path "spec/fixtures"
|
14
|
-
|
15
|
-
|
16
|
-
Rails.application = Class.new(Rails::Application)
|
17
|
-
#Rails.application.routes.append do |r|
|
18
|
-
# r.match "/render_event_response", :as => :apotomo_event_path
|
19
|
-
#end
|
20
2
|
|
21
3
|
module RSpec::Rails
|
22
4
|
describe WidgetExampleGroup do
|
@@ -41,13 +23,13 @@ module RSpec::Rails
|
|
41
23
|
root << widget(:dummy)
|
42
24
|
root[:dummy].instance_eval do
|
43
25
|
def apotomo_event_path(*args)
|
44
|
-
"
|
26
|
+
"I should be mixed in properly from @routes"
|
45
27
|
end
|
46
28
|
end
|
47
29
|
end
|
48
30
|
|
49
31
|
it "should render a view" do
|
50
|
-
render_widget(:dummy).should == "Hey from DummyWidget!
|
32
|
+
render_widget(:dummy).text.should == "Hey from DummyWidget! I should be mixed in properly from @routes\n"
|
51
33
|
end
|
52
34
|
end
|
53
35
|
|
@@ -71,10 +53,10 @@ module RSpec::Rails
|
|
71
53
|
render_widget(:some_widget)
|
72
54
|
end
|
73
55
|
|
74
|
-
it "can use
|
56
|
+
it "can use rendered to get the result of render_widget" do
|
75
57
|
::Apotomo::Widget.any_instance.stub(:render_widget).and_return("expected string")
|
76
58
|
render_widget(:some_widget)
|
77
|
-
|
59
|
+
rendered.should have_content 'expected string'
|
78
60
|
end
|
79
61
|
end
|
80
62
|
|
@@ -89,15 +71,20 @@ module RSpec::Rails
|
|
89
71
|
end
|
90
72
|
end
|
91
73
|
|
92
|
-
context "- #
|
74
|
+
context "- #view_assigns" do
|
93
75
|
has_widgets do |root|
|
94
76
|
root << widget(:dummy)
|
95
77
|
end
|
96
78
|
|
97
79
|
it "gets the widget controller variables" do
|
98
|
-
|
80
|
+
DummyWidget.class_eval do
|
81
|
+
def show
|
82
|
+
@user = "Justin"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
render_widget(:dummy, :show)
|
86
|
+
view_assigns[:user].should == "Justin"
|
99
87
|
end
|
100
|
-
pending "sets the widget view variables"
|
101
88
|
end
|
102
89
|
end
|
103
90
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Capybara support" do
|
4
|
+
include RSpec::Rails::WidgetExampleGroup
|
5
|
+
|
6
|
+
has_widgets do |root|
|
7
|
+
root << widget(:dummy)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can use rendered to get the result of render_widget" do
|
11
|
+
::Apotomo::Widget.any_instance.stub(:render_widget).and_return("<html><body><h1>Hello!</h1></body></html>")
|
12
|
+
render_widget(:some_widget)
|
13
|
+
rendered.should have_xpath('//h1')
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,30 @@
|
|
1
1
|
require 'bundler'
|
2
|
-
Bundler.setup
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require "action_controller/railtie"
|
5
|
+
|
6
|
+
Rails.application = Class.new(Rails::Application)
|
7
|
+
# Rails.application.routes.append do |r|
|
8
|
+
# r.match "/render_event_response", :as => :apotomo_event_path
|
9
|
+
# end
|
10
|
+
|
11
|
+
# This class is used as a dummy widget for testing
|
12
|
+
|
13
|
+
module Rails
|
14
|
+
def root
|
15
|
+
Pathname.new(__FILE__).dirname.dirname.dirname
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rspec/rails/example/widget_example_group'
|
20
|
+
|
21
|
+
# This class is used as a dummy widget for testing
|
22
|
+
class DummyWidget < Apotomo::Widget
|
23
|
+
responds_to_event :doo
|
24
|
+
|
25
|
+
def display
|
26
|
+
@some_variable = :some_value
|
27
|
+
render
|
28
|
+
end
|
29
|
+
end
|
30
|
+
DummyWidget.append_view_path "spec/fixtures"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 2
|
9
|
+
version: 0.9.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Sutterer
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-09-
|
19
|
+
date: 2011-09-28 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -58,12 +58,12 @@ dependencies:
|
|
58
58
|
segments:
|
59
59
|
- 1
|
60
60
|
- 1
|
61
|
-
-
|
62
|
-
version: 1.1.
|
61
|
+
- 4
|
62
|
+
version: 1.1.4
|
63
63
|
type: :runtime
|
64
64
|
version_requirements: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
66
|
+
name: capybara
|
67
67
|
prerelease: false
|
68
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
type: :development
|
77
77
|
version_requirements: *id004
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: guard-rspec
|
80
80
|
prerelease: false
|
81
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
type: :development
|
90
90
|
version_requirements: *id005
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
92
|
+
name: rb-fsevent
|
93
93
|
prerelease: false
|
94
94
|
requirement: &id006 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
@@ -101,6 +101,19 @@ dependencies:
|
|
101
101
|
version: "0"
|
102
102
|
type: :development
|
103
103
|
version_requirements: *id006
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: growl
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id007
|
104
117
|
description: Use render_widget in your specs
|
105
118
|
email:
|
106
119
|
- apotonick@gmail.com
|
@@ -130,6 +143,7 @@ files:
|
|
130
143
|
- rspec-apotomo.gemspec
|
131
144
|
- spec/fixtures/dummy/display.html.erb
|
132
145
|
- spec/rspec-apotomo/widget_example_group_spec.rb
|
146
|
+
- spec/rspec-apotomo/with_capybara_spec.rb
|
133
147
|
- spec/spec_helper.rb
|
134
148
|
has_rdoc: true
|
135
149
|
homepage: http://rubygems.org/gems/rspec-apotomo
|