Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch to the new expect syntax.
I used some vim macros to do most of the work here:
http://nathanmlong.com/2012/11/convert-to-the-new-rspec-syntax-with-vim-macros/

I also had to re-gen the html/textmate formatter output since
those include the failing line, which changed from `should`
to `expect`.

While I was at it, I deleted the files for 1.9.2-jruby because
the current jruby version supports 1.9.3, but not 1.9.2.

I wasn't able to re-gen the rbx files because my local
rbx installation is messed up and RVM is failing on me
when trying to re-install rbx :(.
  • Loading branch information
myronmarston committed Jan 1, 2013
1 parent 3b1fd5f commit d7a3f4e
Show file tree
Hide file tree
Showing 56 changed files with 1,059 additions and 1,905 deletions.
8 changes: 4 additions & 4 deletions spec/autotest/failed_results_re_spec.rb
Expand Up @@ -16,14 +16,14 @@ def run_example
shared_examples "autotest failed_results_re" do
it "matches a failure" do
output = run_example { fail }
output.should match(Autotest::Rspec2.new.failed_results_re)
output.should include(__FILE__.sub(File.expand_path('.'),'.'))
expect(output).to match(Autotest::Rspec2.new.failed_results_re)
expect(output).to include(__FILE__.sub(File.expand_path('.'),'.'))
end

it "does not match when there are no failures" do
output = run_example { } # pass
output.should_not match(Autotest::Rspec2.new.failed_results_re)
output.should_not include(__FILE__.sub(File.expand_path('.'),'.'))
expect(output).not_to match(Autotest::Rspec2.new.failed_results_re)
expect(output).not_to include(__FILE__.sub(File.expand_path('.'),'.'))
end
end

Expand Down
41 changes: 20 additions & 21 deletions spec/autotest/rspec_spec.rb
Expand Up @@ -11,8 +11,7 @@

it "uses autotest's prefix" do
rspec_autotest.prefix = "this is the prefix "
rspec_autotest.
make_test_cmd({'a' => 'b'}).should match(/this is the prefix/)
expect(rspec_autotest.make_test_cmd({'a' => 'b'})).to match(/this is the prefix/)
end

describe "commands" do
Expand All @@ -30,41 +29,41 @@

it "uses double quotes for windows compatibility" do
command = rspec_autotest.make_test_cmd(@files_to_test)
command.should include('"')
command.should_not include("'")
expect(command).to include('"')
expect(command).not_to include("'")
end

it "makes the appropriate test command" do
actual_command = rspec_autotest.make_test_cmd(@files_to_test)
expected_command = /#{ruby_cmd}.*"#{spec_cmd}" (.*)/

actual_command.should match(expected_command)
expect(actual_command).to match(expected_command)

actual_command =~ expected_command
$1.should =~ /#{File.expand_path('file_one')}/
$1.should =~ /#{File.expand_path('file_two')}/
expect($1).to match /#{File.expand_path('file_one')}/
expect($1).to match /#{File.expand_path('file_two')}/
end

it "returns a blank command for no files" do
rspec_autotest.make_test_cmd({}).should eq('')
expect(rspec_autotest.make_test_cmd({})).to eq('')
end

it "quotes the paths of files to test" do
cmd = rspec_autotest.make_test_cmd(@files_to_test)
@files_to_test.keys.each do |file_to_test|
cmd.should match(/"#{File.expand_path(file_to_test)}"/)
expect(cmd).to match(/"#{File.expand_path(file_to_test)}"/)
end
end

it "quotes the path of the ruby executable" do
cmd = rspec_autotest.make_test_cmd(@files_to_test)
cmd.should match(%r("/path/to/ruby"))
expect(cmd).to match(%r("/path/to/ruby"))
end

it "gives '--tty' to #{Autotest::Rspec2::RSPEC_EXECUTABLE}, not '--autotest'" do
cmd = rspec_autotest.make_test_cmd(@files_to_test)
cmd.should match(' --tty ')
cmd.should_not match(' --autotest ')
expect(cmd).to match(' --tty ')
expect(cmd).not_to match(' --autotest ')
end
end

Expand All @@ -76,19 +75,19 @@
end

it "finds the spec file for a given lib file" do
rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
expect(rspec_autotest).to map_specs([@spec_file]).to(@lib_file)
end

it "finds the spec file if given a spec file" do
rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
expect(rspec_autotest).to map_specs([@spec_file]).to(@spec_file)
end

it "ignores files in spec dir that aren't specs" do
rspec_autotest.should map_specs([]).to("spec/spec_helper.rb")
expect(rspec_autotest).to map_specs([]).to("spec/spec_helper.rb")
end

it "ignores untracked files (in @file)" do
rspec_autotest.should map_specs([]).to("lib/untracked_file")
expect(rspec_autotest).to map_specs([]).to("lib/untracked_file")
end
end

Expand All @@ -97,12 +96,12 @@
let(:spec_file) { "spec/autotest/some_spec.rb" }

it "returns no failures if no failures were given in the output" do
rspec_autotest.consolidate_failures([[]]).should eq({})
expect(rspec_autotest.consolidate_failures([[]])).to eq({})
end

it "returns a hash with the spec filename => spec name for each failure or error" do
failures = [ [ "false should be false", spec_file ] ]
rspec_autotest.consolidate_failures(failures).should eq({
expect(rspec_autotest.consolidate_failures(failures)).to eq({
spec_file => ["false should be false"]
})
end
Expand All @@ -113,11 +112,11 @@
end

it "excludes the subject file" do
rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
expect(rspec_autotest.consolidate_failures(failures).keys).not_to include(subject_file)
end

it "includes the spec file" do
rspec_autotest.consolidate_failures(failures).keys.should include(spec_file)
expect(rspec_autotest.consolidate_failures(failures).keys).to include(spec_file)
end
end
end
Expand All @@ -128,7 +127,7 @@
['filename.rb', './filename.rb', File.expand_path('filename.rb')].each do |file|
@files_to_test[file] = []
end
rspec_autotest.normalize(@files_to_test).should have(1).file
expect(rspec_autotest.normalize(@files_to_test)).to have(1).file
end
end
end
42 changes: 21 additions & 21 deletions spec/command_line/order_spec.rb
Expand Up @@ -87,46 +87,46 @@
RSpec.configuration.seed = srand && srand # reset seed in same process
run_command 'tmp/aruba/spec/order_spec.rb --order rand -f doc'

stdout.string.should match(/Randomized with seed \d+/)
expect(stdout.string).to match(/Randomized with seed \d+/)

top_level_groups {|first_run, second_run| first_run.should_not eq(second_run)}
nested_groups {|first_run, second_run| first_run.should_not eq(second_run)}
examples('group 1') {|first_run, second_run| first_run.should_not eq(second_run)}
examples('group 1-1') {|first_run, second_run| first_run.should_not eq(second_run)}
top_level_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
nested_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
examples('group 1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
examples('group 1-1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
end
end

describe '--order rand:SEED' do
it 'runs the examples and groups in the same order each time' do
2.times { run_command 'tmp/aruba/spec/order_spec.rb --order rand:123 -f doc' }

stdout.string.should match(/Randomized with seed 123/)
expect(stdout.string).to match(/Randomized with seed 123/)

top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
nested_groups {|first_run, second_run| first_run.should eq(second_run)}
examples('group 1') {|first_run, second_run| first_run.should eq(second_run)}
examples('group 1-1') {|first_run, second_run| first_run.should eq(second_run)}
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
end
end

describe '--seed SEED' do
it "forces '--order rand' and runs the examples and groups in the same order each time" do
2.times { run_command 'tmp/aruba/spec/order_spec.rb --seed 123 -f doc' }

stdout.string.should match(/Randomized with seed \d+/)
expect(stdout.string).to match(/Randomized with seed \d+/)

top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
nested_groups {|first_run, second_run| first_run.should eq(second_run)}
examples('group 1') {|first_run, second_run| first_run.should eq(second_run)}
examples('group 1-1') {|first_run, second_run| first_run.should eq(second_run)}
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
end

it "runs examples in the same order, regardless of the order in which files are given" do
run_command 'tmp/aruba/spec/simple_spec.rb tmp/aruba/spec/simple_spec2.rb --seed 1337 -f doc'
run_command 'tmp/aruba/spec/simple_spec2.rb tmp/aruba/spec/simple_spec.rb --seed 1337 -f doc'

top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
nested_groups {|first_run, second_run| first_run.should eq(second_run)}
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
end
end

Expand All @@ -136,9 +136,9 @@

run_command 'tmp/aruba/spec/order_spec.rb --order default -f doc'

stdout.string.should_not match(/Randomized/)
expect(stdout.string).not_to match(/Randomized/)

stdout.string.should match(
expect(stdout.string).to match(
/group 1.*group 1 example 1.*group 1 example 2.*group 1-1.*group 1-2.*group 2.*/m
)
end
Expand Down Expand Up @@ -169,10 +169,10 @@
it 'orders the groups and examples by the provided strategy' do
run_command 'tmp/aruba/spec/custom_order_spec.rb -f doc'

top_level_groups { |groups| groups.flatten.should eq(['group A', 'group B']) }
top_level_groups { |groups| expect(groups.flatten).to eq(['group A', 'group B']) }
examples('group B') do |examples|
letters = examples.flatten.map { |e| e[/(.)\z/, 1] }
letters.should eq(['A', 'B', 'C', 'D'])
expect(letters).to eq(['A', 'B', 'C', 'D'])
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/rspec/core/command_line_spec.rb
Expand Up @@ -27,13 +27,13 @@ module RSpec::Core
it "assigns ConfigurationOptions built from Array of options to @options" do
config_options = ConfigurationOptions.new(%w[--color])
command_line = CommandLine.new(%w[--color])
command_line.instance_eval { @options.options }.should eq(config_options.parse_options)
expect(command_line.instance_eval { @options.options }).to eq(config_options.parse_options)
end

it "assigns submitted ConfigurationOptions to @options" do
config_options = ConfigurationOptions.new(%w[--color])
command_line = CommandLine.new(config_options)
command_line.instance_eval { @options }.should be(config_options)
expect(command_line.instance_eval { @options }).to be(config_options)
end

describe "#run" do
Expand All @@ -42,17 +42,17 @@ module RSpec::Core

it "returns 0 if spec passes" do
command_line = build_command_line passing_spec_filename
command_line.run(err, out).should eq 0
expect(command_line.run(err, out)).to eq 0
end

it "returns 1 if spec fails" do
command_line = build_command_line failing_spec_filename
command_line.run(err, out).should eq 1
expect(command_line.run(err, out)).to eq 1
end

it "returns 2 if spec fails and --failure-exit-code is 2" do
command_line = build_command_line failing_spec_filename, "--failure-exit-code", "2"
command_line.run(err, out).should eq 2
expect(command_line.run(err, out)).to eq 2
end
end

Expand Down Expand Up @@ -91,7 +91,7 @@ module RSpec::Core
config.output_stream = output_file
command_line = build_command_line
command_line.run err, out
command_line.instance_eval { @configuration.output_stream }.should eq output_file
expect(command_line.instance_eval { @configuration.output_stream }).to eq output_file
end
end

Expand Down

0 comments on commit d7a3f4e

Please sign in to comment.