rspec-apotomo 0.9.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/.gitignore +18 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/MIT-LICENSE +20 -0
- data/README.mkd +67 -0
- data/Rakefile +7 -0
- data/lib/rspec-apotomo.rb +18 -0
- data/lib/rspec-apotomo/tasks.rake +8 -0
- data/lib/rspec-apotomo/version.rb +5 -0
- data/lib/rspec/rails/example/widget_example_group.rb +20 -0
- data/rspec-apotomo.gemspec +25 -0
- data/spec/rspec-apotomo/widget_example_group_spec.rb +76 -0
- data/spec/spec_helper.rb +2 -0
- metadata +163 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2, :cli => "--color --format documentation" do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)/([^/]+)\.rb$}) { |m| "spec/rspec-apotomo/#{m[2]}_spec.rb"}
|
7
|
+
end
|
8
|
+
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Vivisimo, Inc., Christian Höltje, Jake Goulding, Nick Sutterer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.mkd
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# RSpec Apotomo
|
2
|
+
|
3
|
+
*Spec your widgets!*
|
4
|
+
|
5
|
+
[](http://travis-ci.org/apotonick/rspec-apotomo)
|
6
|
+
|
7
|
+
This gem allows you to test widgets with [Apotomo](http://apotomo.de) via RSpec.
|
8
|
+
|
9
|
+
Works with Rails 3.x and RSpec 2.
|
10
|
+
|
11
|
+
# Installation
|
12
|
+
|
13
|
+
In your Rails `Gemfile` add this line:
|
14
|
+
|
15
|
+
```
|
16
|
+
group :test do
|
17
|
+
gem 'rspec-apotomo'
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
# Usage
|
22
|
+
|
23
|
+
Put specs in the `spec/widgets` directory.
|
24
|
+
|
25
|
+
*TODO Add the generator and generator docs.*
|
26
|
+
|
27
|
+
An example spec could look like the following code.
|
28
|
+
|
29
|
+
```
|
30
|
+
describe CommentsWidget do
|
31
|
+
has_widgets do |root|
|
32
|
+
root << widget(:comments)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'renders properly' do
|
36
|
+
render_widget(:comments).should == "<h1>No Comment!</h1>"
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'responds to :post events' do
|
40
|
+
trigger(:post, :comments, :text => "I like you!").should == ["Thanks!"]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
# Running the specs
|
46
|
+
|
47
|
+
Run your examples with:
|
48
|
+
|
49
|
+
```
|
50
|
+
rake spec:widgets
|
51
|
+
```
|
52
|
+
|
53
|
+
# Contributors
|
54
|
+
|
55
|
+
* [Christian Höltje](http://docwhat.org/)
|
56
|
+
* [Jake Goulding](http://jakegoulding.com/)
|
57
|
+
* [Vivisimo, Inc.](http://vivisimo.com/)
|
58
|
+
|
59
|
+
# LICENSE
|
60
|
+
|
61
|
+
Copyright © 2011 Vivisimo, Inc., Christian Höltje, Jake Goulding, Nick Sutterer
|
62
|
+
|
63
|
+
Released under the MIT License
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rspec-apotomo/version"
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Apotomo
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
rake_tasks do
|
7
|
+
load "rspec-apotomo/tasks.rake"
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer 'apotomo.rspec' do
|
11
|
+
require 'rspec/rails/example/widget_example_group'
|
12
|
+
RSpec.configure do |c|
|
13
|
+
c.include RSpec::Rails::WidgetExampleGroup, :example_group => { :file_path => /spec\/widgets/ }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'apotomo'
|
2
|
+
require 'apotomo/test_case'
|
3
|
+
|
4
|
+
module RSpec::Rails
|
5
|
+
module WidgetExampleGroup
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
include Apotomo::TestCase::TestMethods
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
# TODO documentation
|
12
|
+
def response
|
13
|
+
@last_invoke
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :parent_controller
|
17
|
+
include ::Apotomo::WidgetShortcuts
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rspec-apotomo/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nick Sutterer", "Christian Holtje", "Jake Goulding"]
|
6
|
+
gem.email = ["apotonick@gmail.com", "docwhat@gerf.org", "jake.goulding@gmail.com"]
|
7
|
+
gem.description = %q{Use render_widget in your specs}
|
8
|
+
gem.summary = %q{Spec your widgets}
|
9
|
+
gem.homepage = "http://rubygems.org/gems/rspec-apotomo"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "rspec-apotomo"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rspec::Apotomo::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency('rails', ['~> 3.0'])
|
19
|
+
gem.add_runtime_dependency('rspec-rails', ['~> 2.6'])
|
20
|
+
gem.add_runtime_dependency('apotomo', ['>= 1.1.3'])
|
21
|
+
|
22
|
+
gem.add_development_dependency('guard-rspec')
|
23
|
+
gem.add_development_dependency('rb-fsevent')
|
24
|
+
gem.add_development_dependency('growl')
|
25
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails/all' # TODO This probably should be someplace else
|
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
|
+
end
|
9
|
+
|
10
|
+
module RSpec::Rails
|
11
|
+
describe WidgetExampleGroup do
|
12
|
+
context "as RSpec" do
|
13
|
+
it "responds to render_widget" do
|
14
|
+
group = RSpec::Core::ExampleGroup.describe do
|
15
|
+
include WidgetExampleGroup
|
16
|
+
end
|
17
|
+
|
18
|
+
# Why is this weird? See https://github.com/rspec/rspec-core/issues/460
|
19
|
+
group.new.__should_for_example_group__ respond_to(:render_widget)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "as a test writer" do
|
24
|
+
# A real user wouldn't use WidgetExampleGroup because
|
25
|
+
# the rails rspec would include it automagically.
|
26
|
+
include WidgetExampleGroup
|
27
|
+
|
28
|
+
context "- ::has_widget" do
|
29
|
+
has_widgets do |root|
|
30
|
+
root << widget(:dummy)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "adds the widget to root" do
|
34
|
+
root.find_widget(:dummy).should_not be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "- #render_widget" do
|
39
|
+
has_widgets do |root|
|
40
|
+
root << widget(:dummy)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "calls render_widget in apotomo's widget" do
|
44
|
+
::Apotomo::Widget.any_instance.should_receive(:render_widget)
|
45
|
+
render_widget(:some_widget)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "can use response to get the result of render_widget" do
|
49
|
+
::Apotomo::Widget.any_instance.stub(:render_widget).and_return("expected string")
|
50
|
+
render_widget(:some_widget)
|
51
|
+
response.should == "expected string"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "- #trigger" do
|
56
|
+
has_widgets do |root|
|
57
|
+
root << widget(:dummy)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "triggers events and returns the page updates" do
|
61
|
+
DummyWidget.any_instance.stub(:doo).and_return("unexpected string")
|
62
|
+
trigger(:doo, :dummy).should == ["unexpected string"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "- #assign" do
|
67
|
+
has_widgets do |root|
|
68
|
+
root << widget(:dummy)
|
69
|
+
end
|
70
|
+
|
71
|
+
pending "gets the widget controller variables"
|
72
|
+
pending "sets the widget view variables"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-apotomo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 9
|
8
|
+
- 0
|
9
|
+
version: 0.9.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Nick Sutterer
|
13
|
+
- Christian Holtje
|
14
|
+
- Jake Goulding
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-09-26 00:00:00 +02:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: rails
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
version: "3.0"
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 6
|
47
|
+
version: "2.6"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: apotomo
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 1
|
61
|
+
- 3
|
62
|
+
version: 1.1.3
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: guard-rspec
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rb-fsevent
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
type: :development
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: growl
|
93
|
+
prerelease: false
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id006
|
104
|
+
description: Use render_widget in your specs
|
105
|
+
email:
|
106
|
+
- apotonick@gmail.com
|
107
|
+
- docwhat@gerf.org
|
108
|
+
- jake.goulding@gmail.com
|
109
|
+
executables: []
|
110
|
+
|
111
|
+
extensions: []
|
112
|
+
|
113
|
+
extra_rdoc_files: []
|
114
|
+
|
115
|
+
files:
|
116
|
+
- .gitignore
|
117
|
+
- .travis.yml
|
118
|
+
- Gemfile
|
119
|
+
- Guardfile
|
120
|
+
- MIT-LICENSE
|
121
|
+
- README.mkd
|
122
|
+
- Rakefile
|
123
|
+
- lib/rspec-apotomo.rb
|
124
|
+
- lib/rspec-apotomo/tasks.rake
|
125
|
+
- lib/rspec-apotomo/version.rb
|
126
|
+
- lib/rspec/rails/example/widget_example_group.rb
|
127
|
+
- rspec-apotomo.gemspec
|
128
|
+
- spec/rspec-apotomo/widget_example_group_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
has_rdoc: true
|
131
|
+
homepage: http://rubygems.org/gems/rspec-apotomo
|
132
|
+
licenses: []
|
133
|
+
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
155
|
+
requirements: []
|
156
|
+
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 1.3.7
|
159
|
+
signing_key:
|
160
|
+
specification_version: 3
|
161
|
+
summary: Spec your widgets
|
162
|
+
test_files: []
|
163
|
+
|