testopia 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Cyril David
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.
@@ -0,0 +1,47 @@
1
+ Testopia
2
+ ========
3
+ Testing is cool, but sometimes, you have to gauge the ROI of everything you do,
4
+ especially if the project is on a tight budget, and you know that every hour
5
+ hurts your clients' pockets.
6
+
7
+ No tests aren't good either. The answer? Test lazily. (This ain't new btw, but
8
+ it's new in the space of monk / ohm / sinatra afaik)
9
+
10
+ Examples?
11
+ ---------
12
+
13
+ # To clarify, Order is an Ohm model using it's assert_* assertions
14
+
15
+ class OrderTest < Test::Unit::TestCase
16
+ subject { Order.new }
17
+
18
+ should_assert_present :amount, :description
19
+ should_assert_numeric :amount
20
+
21
+ # or you can do some generic validation assertions
22
+ should_assert_error [:status, :invalid], :given => "FooBared"
23
+ end
24
+
25
+ # Another example for users
26
+ class UserTest < Test::Unit::TestCase
27
+ subject { User.new }
28
+
29
+ should_assert_present :email, :password, :first_name, :last_name
30
+ should_assert_error [:password, :not_confirmed], :given => 'pass'
31
+ should_assert_error [:email, :not_email], :given => 'notemail'
32
+ end
33
+
34
+ ### Note on Patches/Pull Requests
35
+
36
+ * Fork the project.
37
+ * Make your feature addition or bug fix.
38
+ * Add tests for it. This is important so I don't break it in a
39
+ future version unintentionally.
40
+ * Commit, do not mess with rakefile, version, or history.
41
+ (if you want to have your own version, that is fine but bump version in a
42
+ commit by itself I can ignore when I pull)
43
+ * Send me a pull request. Bonus points for topic branches.
44
+
45
+ ### Copyright
46
+
47
+ Copyright (c) 2010 Cyril David. See LICENSE for details.
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "testopia"
8
+ gem.summary = %Q{Because laziness is the new cuil}
9
+ gem.description = %Q{a collection of test helpers for Ohm, Sinatra, Rack}
10
+ gem.email = "cyx.ucron@gmail.com"
11
+ gem.homepage = "http://github.com/cyx/testopia"
12
+ gem.authors = ["Cyril David"]
13
+ gem.add_development_dependency "contest"
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "testopia #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,4 @@
1
+ module Testopia
2
+ autoload :Ohm, 'testopia/ohm'
3
+ autoload :ActiveMerchant, 'testopia/active_merchant'
4
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_merchant'
2
+
3
+ module Testopia
4
+ module ActiveMerchant
5
+ def credit_card_hash(options = {})
6
+ {
7
+ :number => '1',
8
+ :first_name => 'John',
9
+ :last_name => 'Doe',
10
+ :month => '8',
11
+ :year => "#{Time.now.year + 1}",
12
+ :verification_value => '123',
13
+ :type => 'visa'
14
+ }.update(options)
15
+ end
16
+
17
+ def credit_card(options = {})
18
+ ::ActiveMerchant::Billing::CreditCard.new( credit_card_hash(options) )
19
+ end
20
+
21
+ def address(options = {})
22
+ {
23
+ :name => "John Doe",
24
+ :address1 => "2500 Oak Mills Road",
25
+ :address2 => "Suite 1000",
26
+ :city => "Beverly Hills",
27
+ :state => "CA",
28
+ :country => "US",
29
+ :zip => '90210'
30
+ }.update(options)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ module Testopia
2
+ module Ohm
3
+ def self.included(base)
4
+ base.extend Macros
5
+ end
6
+
7
+ module Macros
8
+ def subject(&block)
9
+ define_method :subject do
10
+ @__subject__ ||= block.call
11
+ end
12
+ end
13
+
14
+ def should_assert_error(pair, options = {})
15
+ value = options[:given]
16
+ field, error = pair
17
+
18
+ should 'assert %s of %s' % [error, field] do
19
+ subject.send '%s=' % field, value
20
+
21
+ assert ! subject.valid?, '%s should not be valid' % subject.inspect
22
+ assert subject.errors.include?(pair),
23
+ '%s should have a %s error' % [field, error]
24
+ end
25
+ end
26
+
27
+ def should_assert_present(*atts)
28
+ atts.each { |a| should_assert_error [a, :not_present], :given => nil }
29
+ end
30
+
31
+ def should_assert_numeric(*atts)
32
+ atts.each { |a| should_assert_error [a, :not_numeric], :given => 'aa' }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'testopia'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestTestopia < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testopia
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Cyril David
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-06 00:00:00 +08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: contest
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ description: a collection of test helpers for Ohm, Sinatra, Rack
33
+ email: cyx.ucron@gmail.com
34
+ executables: []
35
+
36
+ extensions: []
37
+
38
+ extra_rdoc_files:
39
+ - LICENSE
40
+ - README.md
41
+ files:
42
+ - .document
43
+ - .gitignore
44
+ - LICENSE
45
+ - README.md
46
+ - Rakefile
47
+ - VERSION
48
+ - lib/testopia.rb
49
+ - lib/testopia/active_merchant.rb
50
+ - lib/testopia/ohm.rb
51
+ - test/helper.rb
52
+ - test/test_testopia.rb
53
+ has_rdoc: true
54
+ homepage: http://github.com/cyx/testopia
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --charset=UTF-8
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.3.6
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Because laziness is the new cuil
83
+ test_files:
84
+ - test/helper.rb
85
+ - test/test_testopia.rb