rspec-core 2.0.0.beta.9 → 2.0.0.beta.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/features/configuration/custom_settings.feature +86 -0
- data/features/formatters/custom_formatter.feature +1 -1
- data/lib/rspec/core.rb +6 -1
- data/lib/rspec/core/backward_compatibility.rb +3 -5
- data/lib/rspec/core/command_line.rb +52 -0
- data/lib/rspec/core/configuration.rb +106 -118
- data/lib/rspec/core/configuration_options.rb +30 -88
- data/lib/rspec/core/deprecation.rb +3 -4
- data/lib/rspec/core/drb_command_line.rb +29 -0
- data/lib/rspec/core/formatters/base_formatter.rb +3 -8
- data/lib/rspec/core/formatters/base_text_formatter.rb +2 -2
- data/lib/rspec/core/formatters/documentation_formatter.rb +2 -2
- data/lib/rspec/core/kernel_extensions.rb +1 -1
- data/lib/rspec/core/metadata.rb +11 -11
- data/lib/rspec/core/option_parser.rb +84 -0
- data/lib/rspec/core/runner.rb +17 -42
- data/lib/rspec/core/world.rb +2 -2
- data/lib/rspec/monkey.rb +1 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +7 -0
- data/rspec-core.gemspec +18 -59
- data/spec/rspec/core/configuration_options_spec.rb +91 -7
- data/spec/rspec/core/configuration_spec.rb +52 -18
- data/spec/rspec/core/deprecations_spec.rb +4 -2
- data/spec/rspec/core/drb_command_line_spec.rb +151 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +1 -2
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +1 -2
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -2
- data/spec/rspec/core/resources/a_spec.rb +1 -1
- data/spec/rspec/core/runner_spec.rb +38 -27
- data/spec/rspec/core/shared_example_group_spec.rb +1 -1
- data/spec/spec_helper.rb +56 -41
- metadata +17 -58
- data/example_specs/failing/README.txt +0 -7
- data/example_specs/failing/diffing_spec.rb +0 -38
- data/example_specs/failing/failing_implicit_docstrings_example.rb +0 -19
- data/example_specs/failing/failure_in_after.rb +0 -10
- data/example_specs/failing/failure_in_before.rb +0 -10
- data/example_specs/failing/mocking_example.rb +0 -40
- data/example_specs/failing/mocking_with_flexmock.rb +0 -26
- data/example_specs/failing/mocking_with_mocha.rb +0 -25
- data/example_specs/failing/mocking_with_rr.rb +0 -27
- data/example_specs/failing/partial_mock_example.rb +0 -20
- data/example_specs/failing/pending_example.rb +0 -9
- data/example_specs/failing/predicate_example.rb +0 -34
- data/example_specs/failing/raising_example.rb +0 -47
- data/example_specs/failing/spec_helper.rb +0 -1
- data/example_specs/failing/syntax_error_example.rb +0 -7
- data/example_specs/failing/team_spec.rb +0 -43
- data/example_specs/failing/timeout_behaviour.rb +0 -7
- data/example_specs/passing/custom_formatter.rb +0 -12
- data/example_specs/passing/custom_matchers.rb +0 -54
- data/example_specs/passing/dynamic_spec.rb +0 -9
- data/example_specs/passing/file_accessor.rb +0 -19
- data/example_specs/passing/file_accessor_spec.rb +0 -38
- data/example_specs/passing/filtered_formatter.rb +0 -18
- data/example_specs/passing/filtered_formatter_example.rb +0 -31
- data/example_specs/passing/greeter_spec.rb +0 -31
- data/example_specs/passing/helper_method_example.rb +0 -14
- data/example_specs/passing/implicit_docstrings_example.rb +0 -18
- data/example_specs/passing/io_processor.rb +0 -8
- data/example_specs/passing/io_processor_spec.rb +0 -21
- data/example_specs/passing/mocking_example.rb +0 -27
- data/example_specs/passing/multi_threaded_example_group_runner.rb +0 -26
- data/example_specs/passing/nested_classes_example.rb +0 -36
- data/example_specs/passing/options_example.rb +0 -31
- data/example_specs/passing/options_formatter.rb +0 -20
- data/example_specs/passing/partial_mock_example.rb +0 -29
- data/example_specs/passing/pending_example.rb +0 -20
- data/example_specs/passing/predicate_example.rb +0 -27
- data/example_specs/passing/shared_example_group_example.rb +0 -81
- data/example_specs/passing/shared_stack_examples.rb +0 -36
- data/example_specs/passing/spec_helper.rb +0 -1
- data/example_specs/passing/stack.rb +0 -36
- data/example_specs/passing/stack_spec.rb +0 -64
- data/example_specs/passing/stack_spec_with_nested_example_groups.rb +0 -67
- data/example_specs/passing/stubbing_example.rb +0 -69
- data/example_specs/passing/subject_example.rb +0 -45
- data/example_specs/passing/yielding_example.rb +0 -33
- data/example_specs/ruby1.9.compatibility/access_to_constants_spec.rb +0 -85
- data/example_specs/spec_helper.rb +0 -10
- data/features/configuration/custom_options.feature +0 -71
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
class FileAccessor
|
3
|
-
def open_and_handle_with(pathname, processor)
|
4
|
-
pathname.open do |io|
|
5
|
-
processor.process(io)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
if __FILE__ == $0
|
11
|
-
require File.dirname(__FILE__) + '/io_processor'
|
12
|
-
require 'pathname'
|
13
|
-
|
14
|
-
accessor = FileAccessor.new
|
15
|
-
io_processor = IoProcessor.new
|
16
|
-
file = Pathname.new ARGV[0]
|
17
|
-
|
18
|
-
accessor.open_and_handle_with(file, io_processor)
|
19
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/file_accessor'
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
describe "A FileAccessor" do
|
6
|
-
# This sequence diagram illustrates what this spec specifies.
|
7
|
-
#
|
8
|
-
# +--------------+ +----------+ +-------------+
|
9
|
-
# | FileAccessor | | Pathname | | IoProcessor |
|
10
|
-
# +--------------+ +----------+ +-------------+
|
11
|
-
# | | |
|
12
|
-
# open_and_handle_with | | |
|
13
|
-
# -------------------->| | open | |
|
14
|
-
# | |--------------->| | |
|
15
|
-
# | | io | | |
|
16
|
-
# | |<...............| | |
|
17
|
-
# | | | process(io) |
|
18
|
-
# | |---------------------------------->| |
|
19
|
-
# | | | | |
|
20
|
-
# | |<..................................| |
|
21
|
-
# | | |
|
22
|
-
#
|
23
|
-
it "should open a file and pass it to the processor's process method" do
|
24
|
-
# This is the primary actor
|
25
|
-
accessor = FileAccessor.new
|
26
|
-
|
27
|
-
# These are the primary actor's neighbours, which we mock.
|
28
|
-
file = mock "Pathname"
|
29
|
-
io_processor = mock "IoProcessor"
|
30
|
-
|
31
|
-
io = StringIO.new "whatever"
|
32
|
-
file.should_receive(:open).and_yield io
|
33
|
-
io_processor.should_receive(:process).with(io)
|
34
|
-
|
35
|
-
accessor.open_and_handle_with(file, io_processor)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "/../../lib")
|
2
|
-
require 'spec/runner/formatter/nested_text_formatter'
|
3
|
-
|
4
|
-
class FilteredFormatter < Spec::Runner::Formatter::NestedTextFormatter
|
5
|
-
def add_example_group(example_group)
|
6
|
-
if example_group.options[:show] == false
|
7
|
-
@showing = false
|
8
|
-
else
|
9
|
-
@showing = true
|
10
|
-
puts example_group.description
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def example_passed(example)
|
15
|
-
puts " " << example.description if @showing unless example.options[:show] == false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# This demonstrates how you can write custom formatters to handle arbitrary
|
2
|
-
# options passed to the +describe+ and +it+ methods. To see it in action, stand
|
3
|
-
# in the project root and say:
|
4
|
-
#
|
5
|
-
# bin/spec -r examples/passing/filtered_formatter.rb examples/passing/filtered_formatter_example.rb -f FilteredFormatter
|
6
|
-
#
|
7
|
-
# You should only see the examples and groups below that are not explicitly
|
8
|
-
# marked :show => false
|
9
|
-
#
|
10
|
-
# group 1
|
11
|
-
# example 1 a
|
12
|
-
# group 3
|
13
|
-
# example 3
|
14
|
-
|
15
|
-
|
16
|
-
describe "group 1", :show => true do
|
17
|
-
it "example 1 a", :show => true do
|
18
|
-
end
|
19
|
-
it "example 1 b", :show => false do
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "group 2", :show => false do
|
24
|
-
it "example 2" do
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "group 3" do
|
29
|
-
it "example 3" do
|
30
|
-
end
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
# greeter.rb
|
3
|
-
#
|
4
|
-
# Based on http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle
|
5
|
-
#
|
6
|
-
# Run with:
|
7
|
-
#
|
8
|
-
# spec greeter_spec.rb --heckle Greeter
|
9
|
-
#
|
10
|
-
class Greeter
|
11
|
-
def initialize(person = nil)
|
12
|
-
@person = person
|
13
|
-
end
|
14
|
-
|
15
|
-
def greet
|
16
|
-
@person.nil? ? "Hi there!" : "Hi #{@person}!"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "Greeter" do
|
21
|
-
it "should say Hi to person" do
|
22
|
-
greeter = Greeter.new("Kevin")
|
23
|
-
greeter.greet.should == "Hi Kevin!"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should say Hi to nobody" do
|
27
|
-
greeter = Greeter.new
|
28
|
-
# Uncomment the next line to make Heckle happy
|
29
|
-
#greeter.greet.should == "Hi there!"
|
30
|
-
end
|
31
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
module HelperMethodExample
|
4
|
-
describe "an example group with helper a method" do
|
5
|
-
def helper_method
|
6
|
-
"received call"
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should make that method available to specs" do
|
10
|
-
helper_method.should == "received call"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
# Run "spec implicit_docstrings_example.rb --format specdoc" to see the output of this file
|
4
|
-
|
5
|
-
describe "Examples with no docstrings generate their own:" do
|
6
|
-
|
7
|
-
specify { 3.should be < 5 }
|
8
|
-
|
9
|
-
specify { ["a"].should include("a") }
|
10
|
-
|
11
|
-
specify { [1,2,3].should respond_to(:size) }
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 1 do
|
16
|
-
it { should == 1 }
|
17
|
-
it { should be < 2}
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/io_processor'
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
describe "An IoProcessor" do
|
6
|
-
before(:each) do
|
7
|
-
@processor = IoProcessor.new
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should raise nothing when the file is exactly 32 bytes" do
|
11
|
-
lambda {
|
12
|
-
@processor.process(StringIO.new("z"*32))
|
13
|
-
}.should_not raise_error
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should raise an exception when the file length is less than 32 bytes" do
|
17
|
-
lambda {
|
18
|
-
@processor.process(StringIO.new("z"*31))
|
19
|
-
}.should raise_error(DataTooShort)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "A consumer of a mock" do
|
4
|
-
it "should be able to send messages to the mock" do
|
5
|
-
mock = mock("poke me")
|
6
|
-
mock.should_receive(:poke)
|
7
|
-
mock.poke
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "a mock" do
|
12
|
-
it "should be able to mock the same message twice w/ different args" do
|
13
|
-
mock = mock("mock")
|
14
|
-
mock.should_receive(:msg).with(:arg1).and_return(:val1)
|
15
|
-
mock.should_receive(:msg).with(:arg2).and_return(:val2)
|
16
|
-
mock.msg(:arg1).should eql(:val1)
|
17
|
-
mock.msg(:arg2).should eql(:val2)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should be able to mock the same message twice w/ different args in reverse order" do
|
21
|
-
mock = mock("mock")
|
22
|
-
mock.should_receive(:msg).with(:arg1).and_return(:val1)
|
23
|
-
mock.should_receive(:msg).with(:arg2).and_return(:val2)
|
24
|
-
mock.msg(:arg2).should eql(:val2)
|
25
|
-
mock.msg(:arg1).should eql(:val1)
|
26
|
-
end
|
27
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class MultiThreadedExampleGroupRunner < Spec::Runner::ExampleGroupRunner
|
2
|
-
def initialize(options, arg)
|
3
|
-
super(options)
|
4
|
-
# configure these
|
5
|
-
@thread_count = 4
|
6
|
-
@thread_wait = 0
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
10
|
-
@threads = []
|
11
|
-
q = Queue.new
|
12
|
-
example_groups.each { |b| q << b}
|
13
|
-
success = true
|
14
|
-
@thread_count.times do
|
15
|
-
@threads << Thread.new(q) do |queue|
|
16
|
-
while not queue.empty?
|
17
|
-
example_group = queue.pop
|
18
|
-
success &= example_group.suite.run(nil)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
sleep @thread_wait
|
22
|
-
end
|
23
|
-
@threads.each {|t| t.join}
|
24
|
-
success
|
25
|
-
end
|
26
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/stack'
|
3
|
-
|
4
|
-
class StackExamples < Spec::ExampleGroup
|
5
|
-
describe(Stack)
|
6
|
-
before(:each) do
|
7
|
-
@stack = Stack.new
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class EmptyStackExamples < StackExamples
|
12
|
-
describe("when empty")
|
13
|
-
it "should be empty" do
|
14
|
-
@stack.should be_empty
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class AlmostFullStackExamples < StackExamples
|
19
|
-
describe("when almost full")
|
20
|
-
before(:each) do
|
21
|
-
(1..9).each {|n| @stack.push n}
|
22
|
-
end
|
23
|
-
it "should be full" do
|
24
|
-
@stack.should_not be_full
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class FullStackExamples < StackExamples
|
29
|
-
describe("when full")
|
30
|
-
before(:each) do
|
31
|
-
(1..10).each {|n| @stack.push n}
|
32
|
-
end
|
33
|
-
it "should be full" do
|
34
|
-
@stack.should be_full
|
35
|
-
end
|
36
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# This demonstrates the use of the options hash to support custom reporting.
|
2
|
-
# To see the result, run this command from the project root:
|
3
|
-
#
|
4
|
-
# bin/spec --require examples/passing/options_formatter.rb examples/passing/options_example.rb \
|
5
|
-
# --format OptionsFormatter
|
6
|
-
|
7
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
8
|
-
|
9
|
-
describe "this group will be reported", :report => true do
|
10
|
-
it "this example will be reported", :report => true do
|
11
|
-
# no-op
|
12
|
-
end
|
13
|
-
|
14
|
-
it "this example will not be reported", :report => false do
|
15
|
-
# no-op
|
16
|
-
end
|
17
|
-
|
18
|
-
it "this example will also not be reported", :foo => 'bar' do
|
19
|
-
# no-op
|
20
|
-
end
|
21
|
-
|
22
|
-
it "this example will also also not be reported" do
|
23
|
-
# no-op
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "this group will not be reported", :report => false do
|
28
|
-
it "though this example will", :report => true do
|
29
|
-
# no-op
|
30
|
-
end
|
31
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# This is an example of how you can use a custom formatter to do custom
|
2
|
-
# reporting. This formatter will only report example groups and examples that
|
3
|
-
# have :report => true (or anything truthy) in the declaration. See
|
4
|
-
# options_example.rb in this directory.
|
5
|
-
|
6
|
-
require 'spec/runner/formatter/base_text_formatter'
|
7
|
-
|
8
|
-
class OptionsFormatter < Spec::Runner::Formatter::BaseTextFormatter
|
9
|
-
def example_started(proxy)
|
10
|
-
if proxy.options[:report]
|
11
|
-
puts proxy.description
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def example_group_started(proxy)
|
16
|
-
if proxy.options[:report]
|
17
|
-
puts proxy.description
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
class MockableClass
|
4
|
-
def self.find id
|
5
|
-
return :original_return
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "A partial mock" do
|
10
|
-
|
11
|
-
it "should work at the class level" do
|
12
|
-
MockableClass.should_receive(:find).with(1).and_return {:stub_return}
|
13
|
-
MockableClass.find(1).should equal(:stub_return)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should revert to the original after each spec" do
|
17
|
-
MockableClass.find(1).should equal(:original_return)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "can be mocked w/ ordering" do
|
21
|
-
MockableClass.should_receive(:msg_1).ordered
|
22
|
-
MockableClass.should_receive(:msg_2).ordered
|
23
|
-
MockableClass.should_receive(:msg_3).ordered
|
24
|
-
MockableClass.msg_1
|
25
|
-
MockableClass.msg_2
|
26
|
-
MockableClass.msg_3
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "pending example (using pending method)" do
|
4
|
-
it %Q|should be reported as "PENDING: for some reason"| do
|
5
|
-
pending("for some reason")
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "pending example (with no block)" do
|
10
|
-
it %Q|should be reported as "PENDING: Not Yet Implemented"|
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "pending example (with block for pending)" do
|
14
|
-
it %Q|should have a failing block, passed to pending, reported as "PENDING: for some reason"| do
|
15
|
-
pending("for some reason") do
|
16
|
-
raise "some reason"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
class BddFramework
|
4
|
-
def intuitive?
|
5
|
-
true
|
6
|
-
end
|
7
|
-
|
8
|
-
def adopted_quickly?
|
9
|
-
true
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "BDD framework" do
|
14
|
-
|
15
|
-
before(:each) do
|
16
|
-
@bdd_framework = BddFramework.new
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should be adopted quickly" do
|
20
|
-
@bdd_framework.should be_adopted_quickly
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should be intuitive" do
|
24
|
-
@bdd_framework.should be_intuitive
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|