shoulda-context 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/CONTRIBUTING.md +38 -0
- data/README.md +54 -0
- data/Rakefile +2 -31
- data/lib/shoulda/context.rb +4 -1
- data/lib/shoulda/context/version.rb +1 -1
- data/shoulda-context.gemspec +24 -0
- data/tasks/shoulda.rake +1 -0
- data/test/fake_rails_root/vendor/plugins/.keep +0 -0
- metadata +79 -84
- data/CONTRIBUTION_GUIDELINES.rdoc +0 -10
- data/Gemfile.lock +0 -20
- data/README.rdoc +0 -53
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
We love pull requests. Here's a quick guide:
|
2
|
+
|
3
|
+
1. Fork the repo.
|
4
|
+
|
5
|
+
2. Run the tests. We only take pull requests with passing tests, and it's great
|
6
|
+
to know that you have a clean slate: `bundle && rake`
|
7
|
+
|
8
|
+
3. Add a test for your change. Only refactoring and documentation changes
|
9
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
10
|
+
a test!
|
11
|
+
|
12
|
+
4. Make the test pass.
|
13
|
+
|
14
|
+
5. Push to your fork and submit a pull request.
|
15
|
+
|
16
|
+
|
17
|
+
At this point you're waiting on us. We like to at least comment on, if not
|
18
|
+
accept, pull requests within three business days (and, typically, one business
|
19
|
+
day). We may suggest some changes or improvements or alternatives.
|
20
|
+
|
21
|
+
Some things that will increase the chance that your pull request is accepted,
|
22
|
+
taken straight from the Ruby on Rails guide:
|
23
|
+
|
24
|
+
* Use Rails idioms and helpers
|
25
|
+
* Include tests that fail without your code, and pass with it
|
26
|
+
* Update the documentation, the surrounding one, examples elsewhere, guides,
|
27
|
+
whatever is affected by your contribution
|
28
|
+
|
29
|
+
Syntax:
|
30
|
+
|
31
|
+
* Two spaces, no tabs.
|
32
|
+
* No trailing whitespace. Blank lines should not have any space.
|
33
|
+
* Prefer &&/|| over and/or.
|
34
|
+
* MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
35
|
+
* a = b and not a=b.
|
36
|
+
* Follow the conventions you see used in the source already.
|
37
|
+
|
38
|
+
And in case we didn't emphasize it enough: we love tests!
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# shoulda-context
|
2
|
+
|
3
|
+
[Official Documentation](http://rubydoc.info/github/thoughtbot/shoulda-context/master/frames)
|
4
|
+
|
5
|
+
Shoulda's contexts make it easy to write understandable and maintainable tests for Test::Unit.
|
6
|
+
It's fully compatible with your existing tests in Test::Unit, and requires no retooling to use.
|
7
|
+
|
8
|
+
Refer to the [shoulda](https://github.com/thoughtbot/shoulda) gem if you want to know more
|
9
|
+
about using shoulda with Rails or RSpec.
|
10
|
+
|
11
|
+
## Contexts
|
12
|
+
|
13
|
+
Instead of writing Ruby methods with `lots_of_underscores`, shoulda-context adds
|
14
|
+
context, setup, and should blocks...
|
15
|
+
|
16
|
+
class CalculatorTest < Test::Unit::TestCase
|
17
|
+
context "a calculator" do
|
18
|
+
setup do
|
19
|
+
@calculator = Calculator.new
|
20
|
+
end
|
21
|
+
|
22
|
+
should "add two numbers for the sum" do
|
23
|
+
assert_equal 4, @calculator.sum(2, 2)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "multiply two numbers for the product" do
|
27
|
+
assert_equal 10, @calculator.product(2, 5)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
... which combine to produce the following test methods:
|
33
|
+
|
34
|
+
"test: a calculator should add two numbers for the sum."
|
35
|
+
"test: a calculator should multiply two numbers for the product."
|
36
|
+
|
37
|
+
## Assertions
|
38
|
+
|
39
|
+
It also has two additional Test::Unit assertions for working with Ruby's Array:
|
40
|
+
|
41
|
+
assert_same_elements([:a, :b, :c], [:c, :a, :b])
|
42
|
+
assert_contains(['a', '1'], /\d/)
|
43
|
+
assert_contains(['a', '1'], 'a')
|
44
|
+
|
45
|
+
## Credits
|
46
|
+
|
47
|
+
Shoulda is maintained and funded by [thoughtbot](http://thoughtbot.com/community).
|
48
|
+
shoulda-context is maintained by [Travis Jeffery](https://github.com/travisjeffery).
|
49
|
+
Thank you to all the [contributors](https://github.com/thoughtbot/shoulda-context/contributors).
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
Shoulda is Copyright © 2006-2012 thoughtbot, inc.
|
54
|
+
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
data/Rakefile
CHANGED
@@ -1,44 +1,15 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler/setup'
|
3
|
-
require '
|
2
|
+
require 'bundler/gem_tasks'
|
4
3
|
require 'rake/testtask'
|
5
|
-
require 'rake/rdoctask'
|
6
|
-
require 'rake/gempackagetask'
|
7
4
|
|
8
5
|
$LOAD_PATH.unshift("lib")
|
9
6
|
load 'tasks/shoulda.rake'
|
10
7
|
|
11
|
-
test_files_pattern = 'test/**/*_test.rb'
|
12
8
|
Rake::TestTask.new do |t|
|
13
9
|
t.libs << 'lib' << 'test'
|
14
|
-
t.pattern =
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
15
11
|
t.verbose = false
|
16
12
|
end
|
17
13
|
|
18
|
-
Rake::RDocTask.new { |rdoc|
|
19
|
-
rdoc.rdoc_dir = 'doc'
|
20
|
-
rdoc.title = "shoulda-context -- Context framework for Test::Unit"
|
21
|
-
rdoc.options << '--line-numbers'
|
22
|
-
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
23
|
-
rdoc.rdoc_files.include('README.rdoc', 'CONTRIBUTION_GUIDELINES.rdoc', 'lib/**/*.rb')
|
24
|
-
}
|
25
|
-
|
26
|
-
desc "Run code-coverage analysis using rcov"
|
27
|
-
task :coverage do
|
28
|
-
rm_rf "coverage"
|
29
|
-
files = Dir[test_files_pattern]
|
30
|
-
system "rcov --rails --sort coverage -Ilib #{files.join(' ')}"
|
31
|
-
end
|
32
|
-
|
33
|
-
eval("$specification = begin; #{IO.read('shoulda-context.gemspec')}; end")
|
34
|
-
Rake::GemPackageTask.new $specification do |pkg|
|
35
|
-
pkg.need_tar = true
|
36
|
-
pkg.need_zip = true
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "Clean files generated by rake tasks"
|
40
|
-
task :clobber => [:clobber_rdoc, :clobber_package]
|
41
|
-
|
42
14
|
desc 'Default: run tests'
|
43
15
|
task :default => [:test]
|
44
|
-
|
data/lib/shoulda/context.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
|
3
|
+
require 'shoulda/context/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{shoulda-context}
|
7
|
+
s.version = Shoulda::Context::VERSION.dup
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["thoughtbot, inc.", "Tammer Saleh", "Joe Ferris",
|
10
|
+
"Ryan McGeary", "Dan Croak", "Matt Jankowski"]
|
11
|
+
s.email = %q{support@thoughtbot.com}
|
12
|
+
s.homepage = %q{http://thoughtbot.com/community/}
|
13
|
+
s.summary = %q{Context framework extracted from Shoulda}
|
14
|
+
s.description = %q{Context framework extracted from Shoulda}
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency("mocha", "~> 0.9.10")
|
22
|
+
s.add_development_dependency("rake")
|
23
|
+
s.add_development_dependency("test-unit", "~> 2.1.0")
|
24
|
+
end
|
data/tasks/shoulda.rake
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load File.join(File.dirname(__FILE__), "..", "lib", "shoulda", "context", "tasks.rb")
|
File without changes
|
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda-context
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 1.0.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- thoughtbot, inc.
|
14
9
|
- Tammer Saleh
|
15
10
|
- Joe Ferris
|
@@ -19,84 +14,87 @@ authors:
|
|
19
14
|
autorequire:
|
20
15
|
bindir: bin
|
21
16
|
cert_chain: []
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
26
20
|
name: mocha
|
27
|
-
|
28
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
29
22
|
none: false
|
30
|
-
requirements:
|
23
|
+
requirements:
|
31
24
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
hash: 47
|
34
|
-
segments:
|
35
|
-
- 0
|
36
|
-
- 9
|
37
|
-
- 10
|
25
|
+
- !ruby/object:Gem::Version
|
38
26
|
version: 0.9.10
|
39
27
|
type: :development
|
40
|
-
version_requirements: *id001
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
28
|
prerelease: false
|
44
|
-
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.9.10
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
45
38
|
none: false
|
46
|
-
requirements:
|
47
|
-
- -
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
|
50
|
-
segments:
|
51
|
-
- 0
|
52
|
-
version: "0"
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
53
43
|
type: :development
|
54
|
-
version_requirements: *id002
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: test-unit
|
57
44
|
prerelease: false
|
58
|
-
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
46
|
none: false
|
60
|
-
requirements:
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: test-unit
|
53
|
+
requirement: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
61
56
|
- - ~>
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
segments:
|
65
|
-
- 2
|
66
|
-
- 0
|
67
|
-
version: "2.0"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 2.1.0
|
68
59
|
type: :development
|
69
|
-
|
60
|
+
prerelease: false
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.1.0
|
70
67
|
description: Context framework extracted from Shoulda
|
71
68
|
email: support@thoughtbot.com
|
72
|
-
executables:
|
69
|
+
executables:
|
73
70
|
- convert_to_should_syntax
|
74
71
|
extensions: []
|
75
|
-
|
76
|
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
files:
|
80
|
-
- CONTRIBUTION_GUIDELINES.rdoc
|
72
|
+
extra_rdoc_files: []
|
73
|
+
files:
|
74
|
+
- .gitignore
|
75
|
+
- CONTRIBUTING.md
|
81
76
|
- Gemfile
|
82
|
-
- Gemfile.lock
|
83
77
|
- MIT-LICENSE
|
78
|
+
- README.md
|
84
79
|
- Rakefile
|
85
|
-
- README.rdoc
|
86
80
|
- bin/convert_to_should_syntax
|
81
|
+
- init.rb
|
82
|
+
- lib/shoulda-context.rb
|
83
|
+
- lib/shoulda/context.rb
|
87
84
|
- lib/shoulda/context/assertions.rb
|
88
85
|
- lib/shoulda/context/autoload_macros.rb
|
89
86
|
- lib/shoulda/context/context.rb
|
90
87
|
- lib/shoulda/context/proc_extensions.rb
|
88
|
+
- lib/shoulda/context/tasks.rb
|
91
89
|
- lib/shoulda/context/tasks/list_tests.rake
|
92
90
|
- lib/shoulda/context/tasks/yaml_to_shoulda.rake
|
93
|
-
- lib/shoulda/context/tasks.rb
|
94
91
|
- lib/shoulda/context/version.rb
|
95
|
-
- lib/shoulda/context.rb
|
96
|
-
- lib/shoulda-context.rb
|
97
92
|
- rails/init.rb
|
93
|
+
- shoulda-context.gemspec
|
94
|
+
- tasks/shoulda.rake
|
98
95
|
- test/fake_rails_root/test/shoulda_macros/custom_macro.rb
|
99
96
|
- test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
|
97
|
+
- test/fake_rails_root/vendor/plugins/.keep
|
100
98
|
- test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
|
101
99
|
- test/shoulda/autoload_macro_test.rb
|
102
100
|
- test/shoulda/context_test.rb
|
@@ -104,41 +102,38 @@ files:
|
|
104
102
|
- test/shoulda/helpers_test.rb
|
105
103
|
- test/shoulda/should_test.rb
|
106
104
|
- test/test_helper.rb
|
107
|
-
- init.rb
|
108
105
|
homepage: http://thoughtbot.com/community/
|
109
106
|
licenses: []
|
110
|
-
|
111
107
|
post_install_message:
|
112
|
-
rdoc_options:
|
113
|
-
|
114
|
-
- --main
|
115
|
-
- README.rdoc
|
116
|
-
require_paths:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
117
110
|
- lib
|
118
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
112
|
none: false
|
120
|
-
requirements:
|
121
|
-
- -
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
|
124
|
-
|
125
|
-
- 0
|
126
|
-
version: "0"
|
127
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
118
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
segments:
|
134
|
-
- 0
|
135
|
-
version: "0"
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
136
123
|
requirements: []
|
137
|
-
|
138
124
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.8.
|
125
|
+
rubygems_version: 1.8.23
|
140
126
|
signing_key:
|
141
127
|
specification_version: 3
|
142
128
|
summary: Context framework extracted from Shoulda
|
143
|
-
test_files:
|
144
|
-
|
129
|
+
test_files:
|
130
|
+
- test/fake_rails_root/test/shoulda_macros/custom_macro.rb
|
131
|
+
- test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
|
132
|
+
- test/fake_rails_root/vendor/plugins/.keep
|
133
|
+
- test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
|
134
|
+
- test/shoulda/autoload_macro_test.rb
|
135
|
+
- test/shoulda/context_test.rb
|
136
|
+
- test/shoulda/convert_to_should_syntax_test.rb
|
137
|
+
- test/shoulda/helpers_test.rb
|
138
|
+
- test/shoulda/should_test.rb
|
139
|
+
- test/test_helper.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
We're using GitHub[http://github.com/thoughtbot/shoulda-context], and we've been getting any combination of github pull requests, tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
|
2
|
-
|
3
|
-
* Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda-context].
|
4
|
-
* We prefer git branches over patches, but we can take either.
|
5
|
-
* If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier.
|
6
|
-
* If you're submitting patches, please cut each fix or feature into a separate patch.
|
7
|
-
* There should be an issue[http://github.com/thoughtbot/shoulda-context/issues] for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
|
8
|
-
* Please <b>don't send pull requests</b> Just update the issue with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox.
|
9
|
-
* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
|
10
|
-
|
data/Gemfile.lock
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
shoulda-context (1.0.0.beta1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
mocha (0.9.12)
|
10
|
-
rake (0.9.2.2)
|
11
|
-
test-unit (2.4.0)
|
12
|
-
|
13
|
-
PLATFORMS
|
14
|
-
ruby
|
15
|
-
|
16
|
-
DEPENDENCIES
|
17
|
-
mocha (~> 0.9.10)
|
18
|
-
rake
|
19
|
-
shoulda-context!
|
20
|
-
test-unit (~> 2.0)
|
data/README.rdoc
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
= shoulda-context
|
2
|
-
|
3
|
-
{Official Documentation}[http://rubydoc.info/github/thoughtbot/shoulda-context/master/frames]
|
4
|
-
|
5
|
-
Shoulda's contexts make it easy to write understandable and maintainable tests for Test::Unit.
|
6
|
-
It's fully compatible with your existing tests in Test::Unit, and requires no retooling to use.
|
7
|
-
|
8
|
-
Refer to the {shoulda}[https://github.com/thoughtbot/shoulda] gem if you want to know more
|
9
|
-
about using shoulda with Rails or RSpec.
|
10
|
-
|
11
|
-
== Contexts
|
12
|
-
|
13
|
-
Instead of writing Ruby methods with lots_of_underscores, shoulda-context adds
|
14
|
-
context, setup, and should blocks...
|
15
|
-
|
16
|
-
class CalculatorTest < Test::Unit::TestCase
|
17
|
-
context "a calculator" do
|
18
|
-
setup do
|
19
|
-
@calculator = Calculator.new
|
20
|
-
end
|
21
|
-
|
22
|
-
should "add two numbers for the sum" do
|
23
|
-
assert_equal 4, @calculator.sum(2, 2)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "multiply two numbers for the product" do
|
27
|
-
assert_equal 10, @calculator.product(2, 5)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
... which combine to produce the following test methods:
|
33
|
-
|
34
|
-
"test: A User instance should return its full name."
|
35
|
-
"test: A User instance with a profile should return true when sent #has_profile?."
|
36
|
-
|
37
|
-
== Assertions
|
38
|
-
|
39
|
-
It also has two additional Test::Unit assertions for working with Ruby's Array:
|
40
|
-
|
41
|
-
assert_same_elements([:a, :b, :c], [:c, :a, :b])
|
42
|
-
assert_contains(['a', '1'], /\d/)
|
43
|
-
assert_contains(['a', '1'], 'a')
|
44
|
-
|
45
|
-
= Credits
|
46
|
-
|
47
|
-
Shoulda is maintained and funded by {thoughtbot}[http://thoughtbot.com/community].
|
48
|
-
Thank you to all the {contributors}[https://github.com/thoughtbot/shoulda-context/contributors].
|
49
|
-
|
50
|
-
= License
|
51
|
-
|
52
|
-
Shoulda is Copyright © 2006-2010 thoughtbot, inc.
|
53
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|