tu-context 0.5.7

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
@@ -0,0 +1,10 @@
1
+ == 0.0.3 2008-10-05
2
+
3
+ * 1 minor enhancement:
4
+ * Fiddled with the way contexts are defined; makes the object model make more sense and the code cleaner
5
+
6
+ == 0.0.1 2008-10-02
7
+
8
+ * 1 major enhancement:
9
+ * Initial release
10
+ * Contexts, lifecycle, and test methods
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Jeremy McAnally
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,30 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.rdoc
6
+ Rakefile
7
+ config/hoe.rb
8
+ config/requirements.rb
9
+ context.gemspec
10
+ countloc.rb
11
+ lib/context.rb
12
+ lib/context/context.rb
13
+ lib/context/core_ext/rails_hacks.rb
14
+ lib/context/core_ext/string.rb
15
+ lib/context/lifecycle.rb
16
+ lib/context/shared_behavior.rb
17
+ lib/context/suite.rb
18
+ lib/context/test.rb
19
+ lib/context/version.rb
20
+ setup.rb
21
+ tasks/deployment.rake
22
+ tasks/environment.rake
23
+ test/test_context.rb
24
+ test/test_core_ext.rb
25
+ test/test_helper.rb
26
+ test/test_lifecycle.rb
27
+ test/test_nested_lifecycle.rb
28
+ test/test_shared.rb
29
+ test/test_shared_lifecycle.rb
30
+ test/test_test.rb
File without changes
@@ -0,0 +1,159 @@
1
+ = tu-context – Adds context blocks for Test::Unit
2
+
3
+ http://github.com/djsun/context
4
+ http://github.com/jeremymcanally/context
5
+
6
+ == DESCRIPTION:
7
+
8
+ If you've ever wanted contexts in your Test::Unit tests, then context is for you. Your tests will be easier to read and write without all the magic and extra code smell!
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Add contexts to Test::Unit tests
13
+ * Small DSL for specifying tests that are pretty
14
+ * Ability to chain context lifecycle methods (coming soon)
15
+
16
+ == SYNOPSIS:
17
+
18
+ * Add contexts using familiar syntax:
19
+
20
+ class UserTest < Test::Unit::TestCase
21
+ context "A new User" do
22
+ # Before/after lifecycle blocks
23
+ before do
24
+ @user = User.first
25
+ end
26
+
27
+ # Specify tests using DSL
28
+ test "should have the right full_name" do
29
+ assert_equal "Dude Man", @user.full_name
30
+ end
31
+
32
+ test "should be able to set parts of the name" do
33
+ @user.first_name = "Mad"
34
+ @user.last_name = "Max"
35
+ @user.save
36
+ assert_equal "Mad Max", @user.full_name
37
+ end
38
+
39
+ after do
40
+ @user.first_name = "Dude"
41
+ @user.last_name = "Man"
42
+ @user.save!
43
+ end
44
+ end
45
+ end
46
+
47
+ * It also has aliases that match other library's syntaxes (all of which can be mixed and matched):
48
+
49
+ class UserTest < Test::Unit::TestCase
50
+ context "A new Account" do
51
+ test "should be new" do
52
+ Account.new.new_record?
53
+ end
54
+ end
55
+
56
+ # RSpec-esque
57
+ describe "A new User" do
58
+ it "should do things" do
59
+ User.first.do_things!
60
+ end
61
+ end
62
+
63
+ # Shoulda-esque
64
+ context "Another User" do
65
+ should "do things that are fun" do
66
+ User.first.do_things!(:fun)
67
+ end
68
+ end
69
+ end
70
+
71
+ * Contexts can also be nested:
72
+
73
+ class UserTest < Test::Unit::TestCase
74
+ context "A new User" do
75
+ context "with clown shoes" do
76
+ test "should squeak" do
77
+ assert_true User.find_by_shoes("clown").squeak?
78
+ end
79
+ end
80
+
81
+ context "without clown shoes" do
82
+ test "should not squeak" do
83
+ assert_false User.find_by_shoes("dressy").squeak?
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ * You can also share behavior among contexts:
90
+
91
+ class UserTest < Test::Unit::TestCase
92
+ shared "shared things" do
93
+ test "things are shared" do
94
+ # test logic here...
95
+ end
96
+ end
97
+
98
+ context "the first thing" do
99
+ uses "shared things"
100
+
101
+ test "other things..." do
102
+ # More testing...
103
+ end
104
+ end
105
+ end
106
+
107
+ * Shared behaviors can also use RSpec syntax
108
+
109
+ class UserTest < Test::Unit::TestCase
110
+ share_examples_for "shared things" do
111
+ it "things are shared" do
112
+ # test logic here...
113
+ end
114
+ end
115
+
116
+ describe "the first thing" do
117
+ it_should_behave_like "shared things"
118
+
119
+ it "other things..." do
120
+ # More testing...
121
+ end
122
+ end
123
+ end
124
+
125
+ == REQUIREMENTS:
126
+
127
+ * Test::Unit (you have it; trust me)
128
+
129
+ == INSTALL:
130
+
131
+ $ gem sources -a http://gems.github.com
132
+ $ sudo gem install jeremymcanally-context
133
+
134
+ == LICENSE:
135
+
136
+ Copyright (c) 2008 Jeremy McAnally
137
+
138
+ Permission is hereby granted, free of charge, to any person obtaining
139
+ a copy of this software and associated documentation files (the
140
+ 'Software'), to deal in the Software without restriction, including
141
+ without limitation the rights to use, copy, modify, merge, publish,
142
+ distribute, sublicense, and/or sell copies of the Software, and to
143
+ permit persons to whom the Software is furnished to do so, subject to
144
+ the following conditions:
145
+
146
+ The above copyright notice and this permission notice shall be
147
+ included in all copies or substantial portions of the Software.
148
+
149
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
150
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
151
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
152
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
153
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
154
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
155
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
156
+
157
+ == ACKNOWLEDGEMENTS:
158
+
159
+ Original implementation by Jeremy McAnally, but heavily tweaked and borrowed from Rails Core and Pratik Naik. Repackaged as the tu-context gem by David James after pulling together various Github forks.
@@ -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 = "tu-context"
8
+ gem.summary = %Q{Adds context blocks for Test::Unit}
9
+ gem.description = %Q{If you've ever wanted contexts in your Test::Unit tests, then context is for you. Your tests will be easier to read and write without all the magic and extra code smell!}
10
+ gem.email = "jeremymcanally@gmail.com"
11
+ gem.homepage = "http://github.com/djsun/tu-context"
12
+ gem.authors = ["Jeremy McAnally", "Rails Core", "Pratik Naik"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
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 = "tu-context #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.7
@@ -0,0 +1,73 @@
1
+ require 'context/version'
2
+
3
+ AUTHOR = 'Jeremy McAnally' # can also be an array of Authors
4
+ EMAIL = "jeremy@entp.com"
5
+ DESCRIPTION = "Contexts and DSL sugar for your tests"
6
+ GEM_NAME = 'context' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'context' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = Context::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'context documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README.rdoc",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,44 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "context"
3
+ s.version = "0.5.6"
4
+ s.date = "2008-10-03"
5
+ s.summary = "Contexts and DSL sugar for your tests"
6
+ s.email = "jeremy@entp.com"
7
+ s.homepage = "http://github.com/jeremymcanally/context"
8
+ s.description = "If you've ever wanted contexts in your Test::Unit tests, then context is for you. Your tests will be easier to read and write without all the magic and extra code smell!"
9
+ s.has_rdoc = true
10
+ s.authors = ["Jeremy McAnally"]
11
+ s.files = [
12
+ "README.rdoc",
13
+ "Rakefile",
14
+ "context.gemspec",
15
+ "History.txt",
16
+ "License.txt",
17
+ "Manifest.txt",
18
+ "PostInstall.txt",
19
+ "config/hoe.rb",
20
+ "config/requirements.rb",
21
+ "lib/context.rb",
22
+ "lib/context/version.rb",
23
+ "lib/context/lifecycle.rb",
24
+ "lib/context/suite.rb",
25
+ "lib/context/context.rb",
26
+ "lib/context/shared_behavior.rb",
27
+ "lib/context/test.rb",
28
+ "lib/context/version.rb",
29
+ "lib/context/core_ext/string.rb",
30
+ "lib/context/core_ext/rails_hacks.rb",
31
+ "setup.rb"
32
+ ]
33
+
34
+ s.test_files = [
35
+ "test/test_context.rb",
36
+ "test/test_core_ext.rb",
37
+ "test/test_lifecycle.rb",
38
+ "test/test_test.rb",
39
+ "test/test_helper.rb"
40
+ ]
41
+
42
+ s.rdoc_options = ["--main", "README.rdoc"]
43
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
44
+ end