jferris-rspec_macros 1.1.0
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/README.textile +0 -0
- data/Rakefile +61 -0
- data/lib/rspec_macros.rb +2 -0
- data/lib/rspec_macros/it_should.rb +15 -0
- data/spec/it_should_spec.rb +71 -0
- data/spec/spec_helper.rb +38 -0
- metadata +72 -0
data/README.textile
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
gem 'rspec', '1.1.11'
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
desc "Run all specs in spec directory"
|
13
|
+
Spec::Rake::SpecTask.new do |t|
|
14
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
15
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the rspec_macros plugin.'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'rspec_macros'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source' << "--main" << "README.textile"
|
23
|
+
rdoc.rdoc_files.include('README.textile')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
spec = Gem::Specification.new do |s|
|
28
|
+
s.name = %q{rspec_macros}
|
29
|
+
s.version = "1.1.0"
|
30
|
+
s.summary = %q{}
|
31
|
+
s.description = %q{}
|
32
|
+
|
33
|
+
s.files = FileList['[A-Z]*', 'lib/**/*.rb', 'spec/**/*.rb']
|
34
|
+
s.require_path = 'lib'
|
35
|
+
s.test_files = Dir[*['spec/**/*_spec.rb']]
|
36
|
+
|
37
|
+
s.has_rdoc = true
|
38
|
+
s.extra_rdoc_files = ["README.textile"]
|
39
|
+
s.rdoc_options = ['--line-numbers', '--inline-source', "--main", "README.textile"]
|
40
|
+
|
41
|
+
s.authors = ["Joe Ferris"]
|
42
|
+
s.email = %q{joe.r.ferris@gmail.com}
|
43
|
+
|
44
|
+
s.platform = Gem::Platform::RUBY
|
45
|
+
s.add_dependency(%q<rspec>, [">= 1.1"])
|
46
|
+
end
|
47
|
+
|
48
|
+
Rake::GemPackageTask.new spec do |pkg|
|
49
|
+
pkg.need_tar = true
|
50
|
+
pkg.need_zip = true
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Clean files generated by rake tasks"
|
54
|
+
task :clobber => [:clobber_rdoc, :clobber_package]
|
55
|
+
|
56
|
+
desc "Generate a gemspec file"
|
57
|
+
task :gemspec do
|
58
|
+
File.open("#{spec.name}.gemspec", 'w') do |f|
|
59
|
+
f.write spec.to_ruby
|
60
|
+
end
|
61
|
+
end
|
data/lib/rspec_macros.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Example
|
5
|
+
describe ExampleGroup do
|
6
|
+
|
7
|
+
describe "with an it { should ... } statement" do
|
8
|
+
with_sandboxed_options do
|
9
|
+
|
10
|
+
attr_reader :example_group, :example, :success
|
11
|
+
|
12
|
+
before do
|
13
|
+
@example_group = Class.new(ExampleGroup) do
|
14
|
+
def subject; @actual; end
|
15
|
+
before(:each) { @actual = 'expected' }
|
16
|
+
it { should eql('expected') }
|
17
|
+
end
|
18
|
+
@example = @example_group.examples.first
|
19
|
+
|
20
|
+
@success = example_group.run
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should create an example using the description from the matcher" do
|
24
|
+
example.description.should == 'should eql "expected"'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should test the matcher returned from the block" do
|
28
|
+
success.should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
ExampleGroup.reset
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "with an it { should_not ... } statement" do
|
39
|
+
with_sandboxed_options do
|
40
|
+
|
41
|
+
attr_reader :example_group, :example, :success
|
42
|
+
|
43
|
+
before do
|
44
|
+
@example_group = Class.new(ExampleGroup) do
|
45
|
+
def subject; @actual; end
|
46
|
+
before(:each) { @actual = 'expected' }
|
47
|
+
it { should_not eql('unexpected') }
|
48
|
+
end
|
49
|
+
@example = @example_group.examples.first
|
50
|
+
|
51
|
+
@success = example_group.run
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should create an example using the description from the matcher" do
|
55
|
+
example.description.should == 'should not eql "unexpected"'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should test the matcher returned from the block" do
|
59
|
+
success.should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
ExampleGroup.reset
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require 'rspec_macros'
|
5
|
+
|
6
|
+
def with_sandboxed_options
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@original_rspec_options = ::Spec::Runner.options
|
11
|
+
::Spec::Runner.use(@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new))
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
::Spec::Runner.use(@original_rspec_options)
|
16
|
+
end
|
17
|
+
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
|
21
|
+
def with_sandboxed_config
|
22
|
+
attr_reader :config
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
@config = ::Spec::Example::Configuration.new
|
26
|
+
@original_configuration = ::Spec::Runner.configuration
|
27
|
+
spec_configuration = @config
|
28
|
+
::Spec::Runner.instance_eval {@configuration = spec_configuration}
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:each) do
|
32
|
+
original_configuration = @original_configuration
|
33
|
+
::Spec::Runner.instance_eval {@configuration = original_configuration}
|
34
|
+
::Spec::Example::ExampleGroupFactory.reset
|
35
|
+
end
|
36
|
+
|
37
|
+
yield
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jferris-rspec_macros
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe Ferris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-07 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "1.1"
|
23
|
+
version:
|
24
|
+
description: ""
|
25
|
+
email: joe.r.ferris@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.textile
|
32
|
+
files:
|
33
|
+
- Rakefile
|
34
|
+
- README.textile
|
35
|
+
- lib/rspec_macros/instance.rb
|
36
|
+
- lib/rspec_macros/it_should.rb
|
37
|
+
- lib/rspec_macros.rb
|
38
|
+
- spec/instance_spec.rb
|
39
|
+
- spec/it_should_spec.rb
|
40
|
+
- spec/spec_helper.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage:
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --line-numbers
|
46
|
+
- --inline-source
|
47
|
+
- --main
|
48
|
+
- README.textile
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: ""
|
70
|
+
test_files:
|
71
|
+
- spec/instance_spec.rb
|
72
|
+
- spec/it_should_spec.rb
|