rspec-core 2.6.4 → 2.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/{bin → exe}/autospec +0 -0
- data/{bin → exe}/rspec +0 -0
- data/features/Upgrade.md +11 -0
- data/features/command_line/exit_status.feature +20 -3
- data/features/command_line/format_option.feature +8 -0
- data/features/command_line/line_number_appended_to_path.feature +35 -1
- data/features/command_line/line_number_option.feature +16 -3
- data/features/command_line/pattern_option.feature +31 -0
- data/features/command_line/rake_task.feature +1 -1
- data/features/command_line/ruby.feature +22 -0
- data/features/configuration/default_path.feature +38 -0
- data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
- data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
- data/features/filtering/inclusion_filters.feature +4 -5
- data/features/formatters/text_formatter.feature +16 -13
- data/features/helper_methods/let.feature +4 -4
- data/features/hooks/around_hooks.feature +1 -1
- data/features/hooks/before_and_after_hooks.feature +3 -3
- data/features/hooks/filtering.feature +13 -6
- data/features/metadata/user_defined.feature +12 -10
- data/features/pending/pending_examples.feature +21 -8
- data/features/step_definitions/additional_cli_steps.rb +1 -1
- data/features/subject/attribute_of_subject.feature +2 -2
- data/features/support/env.rb +1 -2
- data/lib/rspec/core.rb +1 -23
- data/lib/rspec/core/configuration.rb +64 -16
- data/lib/rspec/core/configuration_options.rb +11 -4
- data/lib/rspec/core/example.rb +10 -7
- data/lib/rspec/core/example_group.rb +34 -18
- data/lib/rspec/core/formatters/base_text_formatter.rb +10 -2
- data/lib/rspec/core/formatters/html_formatter.rb +3 -1
- data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
- data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
- data/lib/rspec/core/hooks.rb +2 -2
- data/lib/rspec/core/let.rb +5 -5
- data/lib/rspec/core/metadata.rb +136 -94
- data/lib/rspec/core/option_parser.rb +10 -5
- data/lib/rspec/core/pending.rb +2 -1
- data/lib/rspec/core/rake_task.rb +26 -15
- data/lib/rspec/core/reporter.rb +2 -3
- data/lib/rspec/core/runner.rb +1 -1
- data/lib/rspec/core/shared_example_group.rb +4 -4
- data/lib/rspec/core/subject.rb +7 -7
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +4 -8
- data/spec/autotest/discover_spec.rb +2 -2
- data/spec/autotest/failed_results_re_spec.rb +29 -21
- data/spec/autotest/rspec_spec.rb +3 -3
- data/spec/rspec/core/command_line_spec.rb +1 -6
- data/spec/rspec/core/configuration_options_spec.rb +65 -13
- data/spec/rspec/core/configuration_spec.rb +148 -37
- data/spec/rspec/core/deprecations_spec.rb +2 -2
- data/spec/rspec/core/drb_command_line_spec.rb +6 -6
- data/spec/rspec/core/example_group_spec.rb +197 -61
- data/spec/rspec/core/example_spec.rb +33 -16
- data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +149 -1
- data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +85 -17
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
- data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
- data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +86 -18
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
- data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
- data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
- data/spec/rspec/core/let_spec.rb +19 -6
- data/spec/rspec/core/metadata_spec.rb +146 -61
- data/spec/rspec/core/pending_example_spec.rb +4 -4
- data/spec/rspec/core/rake_task_spec.rb +71 -50
- data/spec/rspec/core/reporter_spec.rb +2 -2
- data/spec/rspec/core/ruby_project_spec.rb +2 -2
- data/spec/rspec/core/runner_spec.rb +4 -1
- data/spec/rspec/core/shared_example_group_spec.rb +15 -119
- data/spec/rspec/core/subject_spec.rb +13 -13
- data/spec/rspec/core/world_spec.rb +31 -22
- data/spec/rspec/core_spec.rb +1 -29
- data/spec/spec_helper.rb +51 -49
- data/spec/support/shared_example_groups.rb +3 -3
- data/spec/support/spec_files.rb +8 -8
- metadata +79 -93
- data/.document +0 -5
- data/.gitignore +0 -12
- data/.rspec +0 -0
- data/.travis.yml +0 -9
- data/Changelog.md +0 -305
- data/Gemfile +0 -49
- data/Guardfile +0 -5
- data/License.txt +0 -23
- data/Rakefile +0 -93
- data/cucumber.yml +0 -2
- data/features/.nav +0 -57
- data/rspec-core.gemspec +0 -24
- data/script/FullBuildRakeFile +0 -63
- data/script/console +0 -8
- data/script/cucumber +0 -1
- data/script/full_build +0 -1
- data/script/spec +0 -1
- data/spec.txt +0 -1126
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
@@ -30,10 +30,10 @@ describe "an example" do
|
|
30
30
|
it "does not have an auto-generated description" do
|
31
31
|
group = RSpec::Core::ExampleGroup.describe('group') do
|
32
32
|
it "checks something" do
|
33
|
-
(3+4).should
|
33
|
+
(3+4).should eq(7)
|
34
34
|
end
|
35
35
|
pending do
|
36
|
-
"string".reverse.should
|
36
|
+
"string".reverse.should eq("gnirts")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
example = group.examples.last
|
@@ -45,7 +45,7 @@ describe "an example" do
|
|
45
45
|
it "does not show any message" do
|
46
46
|
group = RSpec::Core::ExampleGroup.describe('group') do
|
47
47
|
it "checks something" do
|
48
|
-
(3+4).should
|
48
|
+
(3+4).should eq(7)
|
49
49
|
end
|
50
50
|
specify do
|
51
51
|
pending
|
@@ -145,7 +145,7 @@ describe "an example" do
|
|
145
145
|
|
146
146
|
context "that passes" do
|
147
147
|
def run_example(*pending_args)
|
148
|
-
super(*pending_args) { 3.should
|
148
|
+
super(*pending_args) { 3.should eq(3) }
|
149
149
|
end
|
150
150
|
|
151
151
|
context "when given no options" do
|
@@ -1,18 +1,29 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require 'tempfile'
|
3
4
|
|
4
5
|
module RSpec::Core
|
5
6
|
describe RakeTask do
|
6
7
|
let(:task) { RakeTask.new }
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def ruby
|
10
|
+
FileUtils::RUBY
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def with_bundle_gemfile(val)
|
14
|
+
begin
|
15
|
+
orig = ENV['BUNDLE_GEMFILE']
|
16
|
+
ENV['BUNDLE_GEMFILE'] = val
|
17
|
+
yield
|
18
|
+
ensure
|
19
|
+
ENV['BUNDLE_GEMFILE'] = orig
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def without_bundler
|
24
|
+
with_bundle_gemfile nil do
|
25
|
+
yield
|
26
|
+
end
|
16
27
|
end
|
17
28
|
|
18
29
|
def with_rcov
|
@@ -24,52 +35,41 @@ module RSpec::Core
|
|
24
35
|
task.__send__(:spec_command)
|
25
36
|
end
|
26
37
|
|
27
|
-
context "default" do
|
38
|
+
context "default (BUNDLE_GEMFILE nil)" do
|
28
39
|
it "renders rspec" do
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
context "with bundler" do
|
34
|
-
context "with Gemfile" do
|
35
|
-
it "renders bundle exec rspec" do
|
36
|
-
File.stub(:exist?) { true }
|
37
|
-
task.skip_bundler = false
|
38
|
-
spec_command.should match(/bundle exec/)
|
40
|
+
with_bundle_gemfile nil do
|
41
|
+
spec_command.should =~ /^#{ruby} -S rspec/
|
39
42
|
end
|
40
43
|
end
|
44
|
+
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
task.skip_bundler = false
|
47
|
-
spec_command.should match(/bundle exec/)
|
46
|
+
context "default (BUNDLE_GEMFILE '')" do
|
47
|
+
it "renders rspec" do
|
48
|
+
with_bundle_gemfile '' do
|
49
|
+
spec_command.should =~ /^#{ruby} -S rspec/
|
48
50
|
end
|
49
51
|
end
|
52
|
+
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
task.skip_bundler = false
|
55
|
-
spec_command.should_not match(/bundle exec/)
|
56
|
-
end
|
54
|
+
context "with bundler (BUNDLE_GEMFILE non-blank)" do
|
55
|
+
it "renders bundle exec rspec" do
|
56
|
+
spec_command.should match(/bundle exec/)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
context "with rcov" do
|
61
61
|
it "renders rcov" do
|
62
|
-
|
63
|
-
|
62
|
+
without_bundler do
|
63
|
+
with_rcov do
|
64
|
+
spec_command.should =~ /^#{ruby} -S rcov/
|
65
|
+
end
|
64
66
|
end
|
65
67
|
end
|
66
|
-
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
with_bundler do
|
69
|
+
context "with bundler" do
|
70
|
+
it "renders bundle exec rcov" do
|
71
71
|
with_rcov do
|
72
|
-
spec_command.should =~
|
72
|
+
spec_command.should =~ /^bundle exec #{ruby} -S rcov/
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -77,8 +77,10 @@ module RSpec::Core
|
|
77
77
|
|
78
78
|
context "with ruby options" do
|
79
79
|
it "renders them before -S" do
|
80
|
-
|
81
|
-
|
80
|
+
without_bundler do
|
81
|
+
task.ruby_opts = "-w"
|
82
|
+
spec_command.should =~ /^#{ruby} -w -S rspec/
|
83
|
+
end
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
@@ -138,23 +140,42 @@ module RSpec::Core
|
|
138
140
|
end
|
139
141
|
|
140
142
|
context "with paths with quotes" do
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
@task = RakeTask.new do |t|
|
145
|
-
t.pattern = File.join(@tmp_dir, "*spec.rb")
|
143
|
+
it "escapes the quotes" do
|
144
|
+
task = RakeTask.new do |t|
|
145
|
+
t.pattern = File.join(Dir.tmpdir, "*spec.rb")
|
146
146
|
end
|
147
147
|
["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb"].each do |file_name|
|
148
|
-
FileUtils.touch(File.join(
|
148
|
+
FileUtils.touch(File.join(Dir.tmpdir, file_name))
|
149
149
|
end
|
150
|
+
task.__send__(:files_to_run).sort.should eq([
|
151
|
+
File.join(Dir.tmpdir, "first_spec.rb"),
|
152
|
+
File.join(Dir.tmpdir, "second_\\\"spec.rb"),
|
153
|
+
File.join(Dir.tmpdir, "third_\\\'spec.rb")
|
154
|
+
])
|
150
155
|
end
|
156
|
+
end
|
151
157
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
+
context "with paths including symlinked directories" do
|
159
|
+
it "finds the files" do
|
160
|
+
project_dir = File.join(Dir.tmpdir, "project")
|
161
|
+
FileUtils.rm_rf project_dir
|
162
|
+
|
163
|
+
foos_dir = File.join(project_dir, "spec/foos")
|
164
|
+
FileUtils.mkdir_p foos_dir
|
165
|
+
FileUtils.touch(File.join(foos_dir, "foo_spec.rb"))
|
166
|
+
|
167
|
+
bars_dir = File.join(Dir.tmpdir, "shared/spec/bars")
|
168
|
+
FileUtils.mkdir_p bars_dir
|
169
|
+
FileUtils.touch(File.join(bars_dir, "bar_spec.rb"))
|
170
|
+
|
171
|
+
FileUtils.ln_s bars_dir, File.join(project_dir, "spec/bars")
|
172
|
+
|
173
|
+
FileUtils.cd(project_dir) do
|
174
|
+
RakeTask.new.__send__(:files_to_run).sort.should eq([
|
175
|
+
"./spec/bars/bar_spec.rb",
|
176
|
+
"./spec/foos/foo_spec.rb"
|
177
|
+
])
|
178
|
+
end
|
158
179
|
end
|
159
180
|
end
|
160
181
|
end
|
@@ -44,14 +44,14 @@ module RSpec::Core
|
|
44
44
|
|
45
45
|
group.run(Reporter.new(formatter))
|
46
46
|
|
47
|
-
order.should
|
47
|
+
order.should eq([
|
48
48
|
"Started: root",
|
49
49
|
"Started: context 1",
|
50
50
|
"Finished: context 1",
|
51
51
|
"Started: context 2",
|
52
52
|
"Finished: context 2",
|
53
53
|
"Finished: root"
|
54
|
-
]
|
54
|
+
])
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -7,14 +7,14 @@ module RSpec
|
|
7
7
|
context "with ancestor containing spec directory" do
|
8
8
|
it "returns ancestor containing the spec directory" do
|
9
9
|
RubyProject.stub(:ascend_until).and_return('foodir')
|
10
|
-
RubyProject.determine_root.should
|
10
|
+
RubyProject.determine_root.should eq("foodir")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context "without ancestor containing spec directory" do
|
15
15
|
it "returns current working directory" do
|
16
16
|
RubyProject.stub(:find_first_parent_containing).and_return(nil)
|
17
|
-
RubyProject.determine_root.should
|
17
|
+
RubyProject.determine_root.should eq(".")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -7,6 +7,7 @@ module RSpec::Core
|
|
7
7
|
RSpec::Core::Runner.stub(:installed_at_exit?).and_return(false)
|
8
8
|
RSpec::Core::Runner.stub(:running_in_drb?).and_return(false)
|
9
9
|
RSpec::Core::Runner.stub(:at_exit_hook_disabled?).and_return(false)
|
10
|
+
RSpec::Core::Runner.stub(:run).and_return(-1)
|
10
11
|
RSpec::Core::Runner.should_receive(:at_exit)
|
11
12
|
RSpec::Core::Runner.autorun
|
12
13
|
end
|
@@ -25,6 +26,7 @@ module RSpec::Core
|
|
25
26
|
let(:out) { StringIO.new }
|
26
27
|
|
27
28
|
it "resets world and configuration" do
|
29
|
+
RSpec.configuration.stub(:files_to_run) { [] }
|
28
30
|
RSpec.configuration.should_receive(:reset)
|
29
31
|
RSpec.world.should_receive(:reset)
|
30
32
|
RSpec::Core::Runner.run([], err, out)
|
@@ -58,6 +60,7 @@ module RSpec::Core
|
|
58
60
|
end
|
59
61
|
|
60
62
|
it "outputs a message" do
|
63
|
+
RSpec.configuration.stub(:files_to_run) { [] }
|
61
64
|
err.should_receive(:puts).with(
|
62
65
|
"No DRb server is running. Running in local process instead ..."
|
63
66
|
)
|
@@ -65,7 +68,7 @@ module RSpec::Core
|
|
65
68
|
end
|
66
69
|
|
67
70
|
it "builds a CommandLine and runs the specs" do
|
68
|
-
process_proxy = double(RSpec::Core::CommandLine, :run =>
|
71
|
+
process_proxy = double(RSpec::Core::CommandLine, :run => 0)
|
69
72
|
process_proxy.should_receive(:run).with(err, out)
|
70
73
|
|
71
74
|
RSpec::Core::CommandLine.should_receive(:new).and_return(process_proxy)
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module RSpec::Core
|
4
|
-
|
5
4
|
describe SharedExampleGroup do
|
5
|
+
|
6
|
+
ExampleModule = Module.new
|
7
|
+
ExampleClass = Class.new
|
6
8
|
|
7
9
|
%w[share_examples_for shared_examples_for].each do |method_name|
|
8
10
|
describe method_name do
|
@@ -17,20 +19,15 @@ module RSpec::Core
|
|
17
19
|
group.send(method_name, 'shared group') {}
|
18
20
|
end.should raise_error(ArgumentError, "Shared example group 'shared group' already exists")
|
19
21
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
context "given a symbol" do
|
30
|
-
it "captures the given symbol and block in the World's collection of shared example groups" do
|
31
|
-
implementation = lambda {}
|
32
|
-
RSpec.world.shared_example_groups.should_receive(:[]=).with(:name, implementation)
|
33
|
-
send(method_name, :name, &implementation)
|
22
|
+
|
23
|
+
["name", :name, ExampleModule, ExampleClass].each do |object|
|
24
|
+
type = object.class.name.downcase
|
25
|
+
context "given a #{type}" do
|
26
|
+
it "captures the given #{type} and block in the World's collection of shared example groups" do
|
27
|
+
implementation = lambda {}
|
28
|
+
RSpec.world.shared_example_groups.should_receive(:[]=).with(object, implementation)
|
29
|
+
send(method_name, object, &implementation)
|
30
|
+
end
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
@@ -64,107 +61,6 @@ module RSpec::Core
|
|
64
61
|
end
|
65
62
|
end
|
66
63
|
|
67
|
-
describe "#it_should_behave_like" do
|
68
|
-
it "creates a nested group" do
|
69
|
-
shared_examples_for("thing") {}
|
70
|
-
group = ExampleGroup.describe('fake group')
|
71
|
-
group.it_should_behave_like("thing")
|
72
|
-
group.should have(1).children
|
73
|
-
end
|
74
|
-
|
75
|
-
it "adds shared examples to nested group" do
|
76
|
-
shared_examples_for("thing") do
|
77
|
-
it("does something")
|
78
|
-
end
|
79
|
-
group = ExampleGroup.describe('fake group')
|
80
|
-
shared_group = group.it_should_behave_like("thing")
|
81
|
-
shared_group.should have(1).examples
|
82
|
-
end
|
83
|
-
|
84
|
-
it "adds shared instance methods to nested group" do
|
85
|
-
shared_examples_for("thing") do
|
86
|
-
def foo; end
|
87
|
-
end
|
88
|
-
group = ExampleGroup.describe('fake group')
|
89
|
-
shared_group = group.it_should_behave_like("thing")
|
90
|
-
shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "adds shared class methods to nested group" do
|
94
|
-
shared_examples_for("thing") do
|
95
|
-
def self.foo; end
|
96
|
-
end
|
97
|
-
group = ExampleGroup.describe('fake group')
|
98
|
-
shared_group = group.it_should_behave_like("thing")
|
99
|
-
shared_group.methods.map{|m| m.to_s}.should include("foo")
|
100
|
-
end
|
101
|
-
|
102
|
-
context "given some parameters" do
|
103
|
-
it "passes the parameters to the shared example group" do
|
104
|
-
passed_params = {}
|
105
|
-
|
106
|
-
shared_examples_for("thing") do |param1, param2|
|
107
|
-
it("has access to the given parameters") do
|
108
|
-
passed_params[:param1] = param1
|
109
|
-
passed_params[:param2] = param2
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
group = ExampleGroup.describe("group") do
|
114
|
-
it_should_behave_like "thing", :value1, :value2
|
115
|
-
end
|
116
|
-
group.run
|
117
|
-
|
118
|
-
passed_params.should == { :param1 => :value1, :param2 => :value2 }
|
119
|
-
end
|
120
|
-
|
121
|
-
it "adds shared instance methods to nested group" do
|
122
|
-
shared_examples_for("thing") do |param1|
|
123
|
-
def foo; end
|
124
|
-
end
|
125
|
-
group = ExampleGroup.describe('fake group')
|
126
|
-
shared_group = group.it_should_behave_like("thing", :a)
|
127
|
-
shared_group.public_instance_methods.map{|m| m.to_s}.should include("foo")
|
128
|
-
end
|
129
|
-
|
130
|
-
it "evals the shared example group only once" do
|
131
|
-
eval_count = 0
|
132
|
-
shared_examples_for("thing") { |p| eval_count += 1 }
|
133
|
-
group = ExampleGroup.describe('fake group')
|
134
|
-
shared_group = group.it_should_behave_like("thing", :a)
|
135
|
-
eval_count.should == 1
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context "given a block" do
|
140
|
-
it "evaluates the block in nested group" do
|
141
|
-
scopes = []
|
142
|
-
shared_examples_for("thing") do
|
143
|
-
it("gets run in the nested group") do
|
144
|
-
scopes << self.class
|
145
|
-
end
|
146
|
-
end
|
147
|
-
group = ExampleGroup.describe("group") do
|
148
|
-
it_should_behave_like "thing" do
|
149
|
-
it("gets run in the same nested group") do
|
150
|
-
scopes << self.class
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
group.run
|
155
|
-
|
156
|
-
scopes[0].should be(scopes[1])
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
it "raises when named shared example_group can not be found" do
|
161
|
-
group = ExampleGroup.describe("example_group")
|
162
|
-
lambda do
|
163
|
-
group.it_should_behave_like("a group that does not exist")
|
164
|
-
end.should raise_error(/Could not find shared example group named/)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
64
|
describe "#share_as" do
|
169
65
|
it "is exposed to the global namespace" do
|
170
66
|
Kernel.should respond_to("share_as")
|
@@ -173,15 +69,15 @@ module RSpec::Core
|
|
173
69
|
it "adds examples to current example_group using include", :compat => 'rspec-1.2' do
|
174
70
|
share_as('Cornucopia') do
|
175
71
|
it "is plentiful" do
|
176
|
-
5.should
|
72
|
+
5.should eq(4)
|
177
73
|
end
|
178
74
|
end
|
179
75
|
group = ExampleGroup.describe('group') { include Cornucopia }
|
180
76
|
phantom_group = group.children.first
|
181
77
|
phantom_group.description.should eql("")
|
182
78
|
phantom_group.metadata[:shared_group_name].should eql('Cornucopia')
|
183
|
-
phantom_group.examples.length.should
|
184
|
-
phantom_group.examples.first.metadata[:description].should
|
79
|
+
phantom_group.examples.length.should eq(1)
|
80
|
+
phantom_group.examples.first.metadata[:description].should eq("is plentiful")
|
185
81
|
end
|
186
82
|
end
|
187
83
|
end
|
@@ -8,25 +8,25 @@ module RSpec::Core
|
|
8
8
|
describe "implicit subject" do
|
9
9
|
describe "with a class" do
|
10
10
|
it "returns an instance of the class" do
|
11
|
-
ExampleGroup.describe(Array).subject.call.should
|
11
|
+
ExampleGroup.describe(Array).subject.call.should eq([])
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "with a Module" do
|
16
16
|
it "returns the Module" do
|
17
|
-
ExampleGroup.describe(Enumerable).subject.call.should
|
17
|
+
ExampleGroup.describe(Enumerable).subject.call.should eq(Enumerable)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "with a string" do
|
22
22
|
it "return the string" do
|
23
|
-
ExampleGroup.describe("Foo").subject.call.should
|
23
|
+
ExampleGroup.describe("Foo").subject.call.should eq("Foo")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "with a number" do
|
28
28
|
it "returns the number" do
|
29
|
-
ExampleGroup.describe(15).subject.call.should
|
29
|
+
ExampleGroup.describe(15).subject.call.should eq(15)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -56,7 +56,7 @@ module RSpec::Core
|
|
56
56
|
it "replaces the implicit subject in that group" do
|
57
57
|
group = ExampleGroup.describe(Array)
|
58
58
|
group.subject { [1,2,3] }
|
59
|
-
group.subject.call.should
|
59
|
+
group.subject.call.should eq([1,2,3])
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -69,13 +69,13 @@ module RSpec::Core
|
|
69
69
|
|
70
70
|
it "is available in a nested group (subclass)" do
|
71
71
|
nested_group = group.describe("I'm nested!") { }
|
72
|
-
nested_group.subject.call.should
|
72
|
+
nested_group.subject.call.should eq([4,5,6])
|
73
73
|
end
|
74
74
|
|
75
75
|
it "is available in a doubly nested group (subclass)" do
|
76
76
|
nested_group = group.describe("Nesting level 1") { }
|
77
77
|
doubly_nested_group = nested_group.describe("Nesting level 2") { }
|
78
|
-
doubly_nested_group.subject.call.should
|
78
|
+
doubly_nested_group.subject.call.should eq([4,5,6])
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -149,9 +149,9 @@ module RSpec::Core
|
|
149
149
|
end
|
150
150
|
end.new
|
151
151
|
end
|
152
|
-
its([:a]) { should
|
153
|
-
its(['a']) { should
|
154
|
-
its([:b, 'c', 4]) { should
|
152
|
+
its([:a]) { should eq("Symbol: a") }
|
153
|
+
its(['a']) { should eq("String: a") }
|
154
|
+
its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Fixnum: 4") }
|
155
155
|
its(:name) { should = "George" }
|
156
156
|
context "when referring to an attribute without the proper array syntax" do
|
157
157
|
context "it raises an error" do
|
@@ -170,7 +170,7 @@ module RSpec::Core
|
|
170
170
|
context "it raises an error" do
|
171
171
|
its([:a]) do
|
172
172
|
expect do
|
173
|
-
should
|
173
|
+
should eq("Symbol: a")
|
174
174
|
end.to raise_error(NoMethodError)
|
175
175
|
end
|
176
176
|
end
|
@@ -181,12 +181,12 @@ module RSpec::Core
|
|
181
181
|
group = ExampleGroup.describe(Array) do
|
182
182
|
subject { [1, 'a'] }
|
183
183
|
|
184
|
-
its(:last) { should
|
184
|
+
its(:last) { should eq("a") }
|
185
185
|
|
186
186
|
describe '.first' do
|
187
187
|
def subject; super().first; end
|
188
188
|
|
189
|
-
its(:next) { should
|
189
|
+
its(:next) { should eq(2) }
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|