spec-more 0.0.3

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John T. Prince
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.rdoc ADDED
@@ -0,0 +1,50 @@
1
+ = spec-more
2
+
3
+ Spec::More gives very terse aliases for spec'ing inspired by Perl's
4
+ Test::More.
5
+
6
+ == Synopsis
7
+
8
+ .is .should.equal
9
+ .isnt .should.not.equal
10
+ .isa .class.should.equal
11
+
12
+ .enums (all elements equal [using #each])
13
+ .matches .should.match
14
+
15
+ ok x == y assert x == y
16
+
17
+ xdescribe skip it
18
+ xit skip it
19
+
20
+
21
+ == Usage
22
+
23
+ require 'spec/more' # depends on bacon
24
+
25
+ # currently only works within a bacon context
26
+ describe 'a big dog' do
27
+ it 'barks loudly' do
28
+ dog.bark.is 'loud'
29
+ dog.bark.matches /oud/
30
+
31
+ [1,2,3].enums [1,2,3]
32
+ 'dog'.matches /og/
33
+ ok dog.bark == 'loud'
34
+ end
35
+ end
36
+
37
+ xdescribe 'a spec to be skipped' do
38
+ xit 'skip this spec' do
39
+ end
40
+ end
41
+
42
+ == Installation
43
+
44
+ gem install spec-more
45
+
46
+ Has bacon as a dependency so it should install that too.
47
+
48
+ == Limitations
49
+
50
+ For Bacon[http://github.com/chneukirchen/bacon/] only right now. (pull requests appreciated).
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+ require 'rcov/rcovtask'
5
+ require 'rake/rdoctask'
6
+
7
+
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = "spec-more"
10
+ gem.summary = %Q{very terse syntax for testing/specing ala Test::More}
11
+ gem.email = "jtprince@gmail.com"
12
+ gem.homepage = "http://github.com/jtprince/spec-more"
13
+ gem.authors = ["John T. Prince"]
14
+ gem.add_dependency("bacon")
15
+ end
16
+
17
+ require 'rake/testtask'
18
+ Rake::TestTask.new(:spec) do |spec|
19
+ spec.libs << 'lib' << 'spec'
20
+ spec.pattern = 'spec/**/*_spec.rb'
21
+ spec.verbose = true
22
+ end
23
+
24
+ Rcov::RcovTask.new do |spec|
25
+ spec.libs << 'spec'
26
+ spec.pattern = 'spec/**/*_spec.rb'
27
+ spec.verbose = true
28
+ end
29
+
30
+ task :default => :spec
31
+
32
+ Rake::RDocTask.new do |rdoc|
33
+ version = IO.readlines('VERSION').first.chomp
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "spec-more #{version}"
36
+ rdoc.rdoc_files.include('README*')
37
+ rdoc.rdoc_files.include('lib/**/*.rb')
38
+ end
39
+
40
+ task :build => :gemspec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
data/lib/spec/more.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'rubygems'
2
+ require 'bacon'
3
+
4
+ class Object
5
+
6
+ def is(other)
7
+ should.equal other
8
+ end
9
+
10
+ def isnt(other)
11
+ should.not.equal other
12
+ end
13
+
14
+ def isa(other)
15
+ self.class.should.equal other
16
+ end
17
+
18
+ def matches(other)
19
+ should.match other
20
+ end
21
+
22
+ # element wise matching using each
23
+ def enums(other)
24
+ self_ar = []
25
+ self.each do |v|
26
+ self_ar << v
27
+ end
28
+ other_ar = []
29
+ other.each do |v|
30
+ other_ar << v
31
+ end
32
+ self_ar.zip(other_ar) do |a,b|
33
+ a.should.equal b
34
+ end
35
+ end
36
+
37
+ def ok
38
+ should.equal true
39
+ end
40
+ end
41
+
42
+ module Bacon
43
+ class Context
44
+ def ok(arg)
45
+ arg.should.equal true
46
+ end
47
+
48
+ def hash_match(hash, obj)
49
+ hash.each do |k,v|
50
+ if v.is_a?(Hash)
51
+ hash_match(v, obj.send(k.to_sym))
52
+ else
53
+ puts "#{k}: #{v} but was #{obj.send(k.to_sym)}" if obj.send(k.to_sym) != v
54
+ obj.send(k.to_sym).should.equal v
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ def xit(*args, &block)
62
+ puts "\nSKIPPING: #{args}"
63
+ end
64
+
65
+ def xdescribe(*args, &block)
66
+ puts "\nSKIPPING: #{args}"
67
+ end
68
+
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ require 'ostruct'
4
+
5
+ require 'spec/more'
6
+
7
+ class MyClass
8
+ attr_accessor :color, :height
9
+ def initialize(color, height)
10
+ @color = color
11
+ @height = height
12
+ end
13
+
14
+ def each(&block)
15
+ [@color, @height].each(&block)
16
+ end
17
+ end
18
+
19
+ describe "spec more" do
20
+ before do
21
+ @obj1 = MyClass.new('blue', 52)
22
+ @obj2 = MyClass.new('blue', 52)
23
+ @obj3 = MyClass.new('red', 532)
24
+ end
25
+
26
+ it "has syntax like Test::More" do
27
+ @obj1.color.is 'blue'
28
+ @obj1.isa MyClass
29
+ @obj1.color.isnt 'purple'
30
+ ok @obj1.color == @obj2.color
31
+
32
+ # and the negations
33
+ prcs = [lambda { @obj1.color.is 'green' },
34
+ lambda { @obj1.isa Hash },
35
+ lambda { @obj1.color.isnt 'blue' },
36
+ lambda { ok @obj1.color == @obj3.color }]
37
+ prcs.each do |prc|
38
+ prc.should.raise(Bacon::Error)
39
+ end
40
+ end
41
+
42
+ it 'can check enumerable objects' do
43
+ @obj1.enums ['blue', 52]
44
+ @obj1.enums @obj2 # obj2 is also enumerable
45
+ lambda {@obj1.enums ['blue', 53]}.should.raise(Bacon::Error)
46
+ end
47
+
48
+ it 'can turn on and off specs and contexts' do
49
+ xit 'just skip this check for now' do end.should.be.nil
50
+ xdescribe 'just skip this context for now' do end.should.be.nil
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bacon'
3
+
4
+ #$LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ #$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+
7
+ require 'spec/more'
8
+
9
+ Bacon.summary_on_exit
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spec-more
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - John T. Prince
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-19 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bacon
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description:
26
+ email: jtprince@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - VERSION
41
+ - lib/spec/more.rb
42
+ - spec/spec/more_spec.rb
43
+ - spec/spec_helper.rb
44
+ has_rdoc: true
45
+ homepage: http://github.com/jtprince/spec-more
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: very terse syntax for testing/specing ala Test::More
72
+ test_files:
73
+ - spec/spec/more_spec.rb
74
+ - spec/spec_helper.rb