protest-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENSE +23 -0
- data/README.rdoc +39 -0
- data/Rakefile +7 -0
- data/lib/protest/rails.rb +80 -0
- data/protest-rails.gemspec +29 -0
- metadata +87 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2009 Nicolás Sanguinetti
|
4
|
+
Copyright (c) 2010 Matías Flores
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
'Software'), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= Protest, the simplicity rebel test framework
|
2
|
+
|
3
|
+
require "protest"
|
4
|
+
|
5
|
+
Protest.describe("A user") do
|
6
|
+
setup do
|
7
|
+
@user = User.new(:name => "John Doe", :email => "john@example.org")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has a name" do
|
11
|
+
assert_equal "John Doe", @user.name
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has an email" do
|
15
|
+
assert_equal "john@example.org", @user.email
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Protest is a small, simple, and easy-to-extend testing framework for ruby. It
|
20
|
+
was written as a replacement for Test::Unit, given how awful its code is, and
|
21
|
+
how difficult it is to extend in order to add new features.
|
22
|
+
|
23
|
+
I believe in minimalistic software, which is easily understood, easy to test,
|
24
|
+
and specially, easy to extend for third parties. That's where I'm aiming with
|
25
|
+
Protest.
|
26
|
+
|
27
|
+
Protest-rails brings the simplicity of Protest into the Rails world.
|
28
|
+
|
29
|
+
See http://github.com/matflores/protest for more info about Protest.
|
30
|
+
|
31
|
+
== Legal
|
32
|
+
|
33
|
+
Maintainer:: Matías Flores — http://matflores.com
|
34
|
+
Credits:: This gem was extracted from the original work of Nicolás Sanguinetti — http://nicolassanguinetti.info
|
35
|
+
License:: MIT (see bundled LICENSE file for more info)
|
36
|
+
|
37
|
+
== Disclaimer
|
38
|
+
|
39
|
+
Currently I am not using Protest heavily in any complex Rails app, so Protest-rails is not as tested and supported as vanilla Protest is.
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require "protest"
|
2
|
+
require "test/unit/assertions"
|
3
|
+
require "action_controller/test_case"
|
4
|
+
|
5
|
+
begin
|
6
|
+
require "webrat"
|
7
|
+
rescue LoadError
|
8
|
+
$no_webrat = true
|
9
|
+
end
|
10
|
+
|
11
|
+
module Protest
|
12
|
+
module Rails
|
13
|
+
# Exclude rails' files from the errors
|
14
|
+
class BacktraceFilter < Utils::BacktraceFilter
|
15
|
+
include ::Rails::BacktraceFilterForTestUnit
|
16
|
+
|
17
|
+
def filter_backtrace(backtrace, prefix=nil)
|
18
|
+
super(backtrace, prefix).reject do |line|
|
19
|
+
line.starts_with?("/")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Wrap all tests in a database transaction.
|
25
|
+
#
|
26
|
+
# TODO: make this optional somehow (yet enabled by default) so users of
|
27
|
+
# other ORMs don't run into problems.
|
28
|
+
module TransactionalTests
|
29
|
+
def run(*args, &block)
|
30
|
+
ActiveRecord::Base.connection.transaction do
|
31
|
+
super(*args, &block)
|
32
|
+
raise ActiveRecord::Rollback
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# You should inherit from this TestCase in order to get rails' helpers
|
38
|
+
# loaded into Protest. These include all the assertions bundled with rails
|
39
|
+
# and your tests being wrapped in a transaction.
|
40
|
+
class TestCase < ::Protest::TestCase
|
41
|
+
include ::Test::Unit::Assertions
|
42
|
+
include ActiveSupport::Testing::Assertions
|
43
|
+
include TransactionalTests
|
44
|
+
end
|
45
|
+
|
46
|
+
class RequestTest < TestCase #:nodoc:
|
47
|
+
%w(response selector tag dom routing model).each do |kind|
|
48
|
+
include ActionController::Assertions.const_get("#{kind.camelize}Assertions")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Make your integration tests inherit from this class, which bundles the
|
53
|
+
# integration runner included with rails, and webrat's test methods. You
|
54
|
+
# should use webrat for integration tests. Really.
|
55
|
+
class IntegrationTest < RequestTest
|
56
|
+
include ActionController::Integration::Runner
|
57
|
+
include Webrat::Methods unless $no_webrat
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# The preferred way to declare a context (top level) is to use
|
62
|
+
# +Protest.describe+ or +Protest.context+, which will ensure you're using
|
63
|
+
# rails adapter with the helpers you need.
|
64
|
+
def self.context(description, &block)
|
65
|
+
Rails::TestCase.context(description, &block)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Use +Protest.story+ to declare an integration test for your rails app. Note
|
69
|
+
# that the files should still be called 'test/integration/foo_test.rb' if you
|
70
|
+
# want the 'test:integration' rake task to pick them up.
|
71
|
+
def self.story(description, &block)
|
72
|
+
Rails::IntegrationTest.story(description, &block)
|
73
|
+
end
|
74
|
+
|
75
|
+
class << self
|
76
|
+
alias_method :describe, :context
|
77
|
+
end
|
78
|
+
|
79
|
+
self.backtrace_filter = Rails::BacktraceFilter.new
|
80
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = "protest-rails"
|
4
|
+
s.version = "0.1.0"
|
5
|
+
s.date = "2010-09-01"
|
6
|
+
|
7
|
+
s.description = "Protest is a tiny, simple, and easy-to-extend test framework. Protest-rails brings that simplicity into the Rails world."
|
8
|
+
s.summary = s.description
|
9
|
+
s.homepage = "http://matflores.github.com/protest"
|
10
|
+
|
11
|
+
s.authors = ["Matías Flores"]
|
12
|
+
s.email = "mflores@atlanware.com"
|
13
|
+
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.rubyforge_project = "protest-rails"
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.rubygems_version = "1.3.1"
|
18
|
+
|
19
|
+
s.files = %w[
|
20
|
+
.gitignore
|
21
|
+
LICENSE
|
22
|
+
README.rdoc
|
23
|
+
Rakefile
|
24
|
+
protest-rails.gemspec
|
25
|
+
lib/protest/rails.rb
|
26
|
+
]
|
27
|
+
|
28
|
+
s.add_dependency("protest", ["~> 0.4.0"])
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: protest-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Mat\xC3\xADas Flores"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-01 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: protest
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 4
|
33
|
+
- 0
|
34
|
+
version: 0.4.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Protest is a tiny, simple, and easy-to-extend test framework. Protest-rails brings that simplicity into the Rails world.
|
38
|
+
email: mflores@atlanware.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- protest-rails.gemspec
|
51
|
+
- lib/protest/rails.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://matflores.github.com/protest
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project: protest-rails
|
82
|
+
rubygems_version: 1.3.7
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Protest is a tiny, simple, and easy-to-extend test framework. Protest-rails brings that simplicity into the Rails world.
|
86
|
+
test_files: []
|
87
|
+
|