Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade syntax #1202

Merged
merged 3 commits into from Nov 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions spec/rspec/core/command_line_spec.rb
Expand Up @@ -10,18 +10,18 @@ module RSpec::Core
let(:config) { RSpec::configuration }
let(:world) { RSpec::world }

before { config.hooks.stub(:run) }
before { allow(config.hooks).to receive(:run) }

it "configures streams before command line options" do
stdout = StringIO.new
config.stub :load_spec_files
config.stub(:reporter => double.as_null_object)
allow(config).to receive :load_spec_files
allow(config).to receive_messages(:reporter => double.as_null_object)
config.output_stream = $stdout

# this is necessary to ensure that color works correctly on windows
config.should_receive(:error_stream=).ordered
config.should_receive(:output_stream=).ordered
config.should_receive(:force).at_least(:once).ordered
expect(config).to receive(:error_stream=).ordered
expect(config).to receive(:output_stream=).ordered
expect(config).to receive(:force).at_least(:once).ordered

command_line = build_command_line
command_line.run err, stdout
Expand Down Expand Up @@ -60,23 +60,23 @@ module RSpec::Core
end

context "running hooks" do
before { config.stub :load_spec_files }
before { allow(config).to receive :load_spec_files }

it "runs before suite hooks" do
config.hooks.should_receive(:run).with(:before, :suite)
expect(config.hooks).to receive(:run).with(:before, :suite)
command_line = build_command_line
command_line.run err, out
end

it "runs after suite hooks" do
config.hooks.should_receive(:run).with(:after, :suite)
expect(config.hooks).to receive(:run).with(:after, :suite)
command_line = build_command_line
command_line.run err, out
end

it "runs after suite hooks even after an error" do
config.hooks.should_receive(:run).with(:before, :suite).and_raise "this error"
config.hooks.should_receive(:run).with(:after , :suite)
expect(config.hooks).to receive(:run).with(:before, :suite).and_raise "this error"
expect(config.hooks).to receive(:run).with(:after , :suite)
expect do
command_line = build_command_line
command_line.run err, out
Expand All @@ -86,7 +86,7 @@ module RSpec::Core
end

describe "#run with custom output" do
before { config.stub :files_to_run => [] }
before { allow(config).to receive_messages :files_to_run => [] }

let(:output_file) { File.new("#{Dir.tmpdir}/command_line_spec_output.txt", 'w') }

Expand Down
32 changes: 16 additions & 16 deletions spec/rspec/core/configuration_options_spec.rb
Expand Up @@ -23,8 +23,8 @@
it "sends libs before requires" do
opts = config_options_object(*%w[--require a/path -I a/lib])
config = double("config").as_null_object
config.should_receive(:libs=).ordered
config.should_receive(:setup_load_path_and_require).ordered
expect(config).to receive(:libs=).ordered
expect(config).to receive(:setup_load_path_and_require).ordered
opts.configure(config)
end

Expand All @@ -39,24 +39,24 @@
it "sets up load path and requires before formatter" do
opts = config_options_object(*%w[--require a/path -f a/formatter])
config = double("config").as_null_object
config.should_receive(:setup_load_path_and_require).ordered
config.should_receive(:add_formatter).ordered
expect(config).to receive(:setup_load_path_and_require).ordered
expect(config).to receive(:add_formatter).ordered
opts.configure(config)
end

it "sends default_path before files_or_directories_to_run" do
opts = config_options_object(*%w[--default_path spec])
config = double("config").as_null_object
config.should_receive(:force).with(:default_path => 'spec').ordered
config.should_receive(:files_or_directories_to_run=).ordered
expect(config).to receive(:force).with(:default_path => 'spec').ordered
expect(config).to receive(:files_or_directories_to_run=).ordered
opts.configure(config)
end

it "sends pattern before files_or_directories_to_run" do
opts = config_options_object(*%w[--pattern **/*.spec])
config = double("config").as_null_object
config.should_receive(:force).with(:pattern => '**/*.spec').ordered
config.should_receive(:files_or_directories_to_run=).ordered
expect(config).to receive(:force).with(:pattern => '**/*.spec').ordered
expect(config).to receive(:files_or_directories_to_run=).ordered
opts.configure(config)
end

Expand All @@ -77,7 +77,7 @@
it "forces color_enabled" do
opts = config_options_object(*%w[--color])
config = RSpec::Core::Configuration.new
config.should_receive(:force).with(:color => true)
expect(config).to receive(:force).with(:color => true)
opts.configure(config)
end

Expand All @@ -93,7 +93,7 @@
it "forces #{config_key}" do
opts = config_options_object(cli_option, cli_value)
config = RSpec::Core::Configuration.new
config.should_receive(:force) do |pair|
expect(config).to receive(:force) do |pair|
expect(pair.keys.first).to eq(config_key)
expect(pair.values.first).to eq(config_value)
end
Expand All @@ -105,8 +105,8 @@
with_env_vars 'SPEC_OPTS' => "--require file_from_env" do
opts = config_options_object(*%w[--require file_from_opts])
config = RSpec::Core::Configuration.new
config.should_receive(:require).with("file_from_opts")
config.should_receive(:require).with("file_from_env")
expect(config).to receive(:require).with("file_from_opts")
expect(config).to receive(:require).with("file_from_env")
opts.configure(config)
end
end
Expand All @@ -115,7 +115,7 @@
with_env_vars 'SPEC_OPTS' => "-I dir_from_env" do
opts = config_options_object(*%w[-I dir_from_opts])
config = RSpec::Core::Configuration.new
config.should_receive(:libs=).with(["dir_from_opts", "dir_from_env"])
expect(config).to receive(:libs=).with(["dir_from_opts", "dir_from_env"])
opts.configure(config)
end
end
Expand Down Expand Up @@ -296,16 +296,16 @@
end

it "provides no files or directories if spec directory does not exist" do
FileTest.stub(:directory?).with("spec").and_return false
allow(FileTest).to receive(:directory?).with("spec").and_return false
expect(parse_options()).to include(:files_or_directories_to_run => [])
end
end

describe "default_path" do
it "gets set before files_or_directories_to_run" do
config = double("config").as_null_object
config.should_receive(:force).with(:default_path => 'foo').ordered
config.should_receive(:files_or_directories_to_run=).ordered
expect(config).to receive(:force).with(:default_path => 'foo').ordered
expect(config).to receive(:files_or_directories_to_run=).ordered
opts = config_options_object("--default_path", "foo")
opts.configure(config)
end
Expand Down