Skip to content

Commit

Permalink
Update to RSpec 3.1.0
Browse files Browse the repository at this point in the history
Performed the conversion with the transpec gem; ie. added it to the
Gemfile, then:

  bundle
  RUBYLIB=./lib:./vendor/walrat/lib bin/transpec -f

And then removed it from the bundle. And checked the spec suite was
still green:

  RUBYLIB=./lib:./vendor/walrat/lib bin/rspec

Here's the relevant output

  734 conversions
    from: obj.should
      to: expect(obj).to
  351 conversions
    from: == expected
      to: eq(expected)
  40 conversions
    from: lambda { }.should
      to: expect { }.to
  1 conversion
    from: =~ /pattern/
      to: match(/pattern/)
  1 conversion
    from: obj.should_not
      to: expect(obj).not_to

  1127 conversions, 0 incompletes, 0 warnings, 0 errors
  • Loading branch information
wincent committed Oct 21, 2014
1 parent 0dd34be commit 6aa9f89
Show file tree
Hide file tree
Showing 27 changed files with 893 additions and 788 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -5,7 +5,7 @@ source 'https://rubygems.org'

gem 'RedCloth', '3.0.4'
gem 'mkdtemp'
gem 'rspec', '1.3.0'
gem 'rspec', '3.1.0'
gem 'walrat', path: 'vendor/walrat'
gem 'wopen3'
gem 'yard'
16 changes: 14 additions & 2 deletions Gemfile.lock
Expand Up @@ -7,8 +7,20 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (3.0.4)
diff-lcs (1.2.5)
mkdtemp (1.2)
rspec (1.3.0)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
wopen3 (0.3)
yard (0.5.8)

Expand All @@ -18,7 +30,7 @@ PLATFORMS
DEPENDENCIES
RedCloth (= 3.0.4)
mkdtemp
rspec (= 1.3.0)
rspec (= 3.1.0)
walrat!
wopen3
yard
16 changes: 16 additions & 0 deletions bin/htmldiff
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'htmldiff' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('diff-lcs', 'htmldiff')
16 changes: 16 additions & 0 deletions bin/ldiff
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'ldiff' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('diff-lcs', 'ldiff')
16 changes: 16 additions & 0 deletions bin/rspec
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('rspec-core', 'rspec')
16 changes: 16 additions & 0 deletions bin/ruby-parse
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'ruby-parse' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('parser', 'ruby-parse')
16 changes: 16 additions & 0 deletions bin/ruby-rewrite
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'ruby-rewrite' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('parser', 'ruby-rewrite')
16 changes: 16 additions & 0 deletions bin/transpec
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'transpec' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('transpec', 'transpec')
18 changes: 9 additions & 9 deletions spec/acceptance/complete_application_spec.rb
Expand Up @@ -55,7 +55,7 @@
end

it 'succeeds' do
@result.should be_success
expect(@result).to be_success
end
end
end
Expand All @@ -77,7 +77,7 @@

it 'succeeds' do
puts @result.stderr unless @result.success? # for debugging
@result.should be_success
expect(@result).to be_success
end
end

Expand All @@ -91,11 +91,11 @@

it 'succeeds' do
puts @result.stderr unless @result.success? # for debugging
@result.should be_success
expect(@result).to be_success
end

it 'writes to the output file' do
@output_file.should exist
expect(@output_file).to exist
end

it 'produces matching output' do
Expand All @@ -105,7 +105,7 @@
@output_file.to_s, '\;'
actual_output = tidied_output.read
expected_output = t.sub(/\.tmpl\z/, '.app.html').read
actual_output.should == expected_output
expect(actual_output).to eq(expected_output)
end
end
end
Expand All @@ -128,7 +128,7 @@

it 'succeeds' do
puts @result.stderr unless @result.success? # for debugging
@result.should be_success
expect(@result).to be_success
end
end

Expand All @@ -143,11 +143,11 @@

it 'succeeds' do
puts @result.stderr unless @result.success? # for debugging
@result.should be_success
expect(@result).to be_success
end

it 'writes to the output file' do
@output_file.should exist
expect(@output_file).to exist
end

it 'produces matching output' do
Expand All @@ -157,7 +157,7 @@
@output_file.to_s, '\;'
actual_output = tidied_output.read
expected_output = t.sub(/\.tmpl\z/, '.web.html').read
actual_output.should == expected_output
expect(actual_output).to eq(expected_output)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/multi_file_spec.rb
Expand Up @@ -43,7 +43,7 @@
base = base.basename(base.extname).to_s
actual_output = IO.read(output_dir + dir + base)
expected_output = IO.read(path.to_s.sub(/\.tmpl\z/i, ".expected"))
actual_output.should == expected_output
expect(actual_output).to eq(expected_output)
end
end
end
6 changes: 3 additions & 3 deletions spec/acceptance/single_file_spec.rb
Expand Up @@ -48,14 +48,14 @@

it "matches expected output when evaluating dynamically (source file: #{path})" do
actual_output = template.fill
actual_output.should == expected_output
expect(actual_output).to eq(expected_output)
end

it "matches expected output when running compiled file in subshell (source file: #{path})" do
target_path = manually_compiled_templates.join(path.basename(path.extname).to_s + '.rb')
File.open(target_path, 'w+') { |file| file.puts compiled }
actual_output = `ruby -I#{Walrus::SpecHelper::LIBDIR} #{target_path}`
actual_output.should == expected_output
expect(actual_output).to eq(expected_output)
end

it "matches expected output when using 'walrus' commandline tool (source file: #{path})" do
Expand All @@ -64,7 +64,7 @@
dir = dir.to_s.sub(/\A\//, '') if dir.absolute? # and always will be absolute
base = base.basename(base.extname).to_s
actual_output = IO.read(walrus_compiled_templates + dir + base)
actual_output.should == expected_output
expect(actual_output).to eq(expected_output)
end
end
end
24 changes: 12 additions & 12 deletions spec/additions/string_spec.rb
Expand Up @@ -6,29 +6,29 @@

describe 'converting to source strings' do
it 'standard strings should be unchanged' do
''.to_source_string.should == ''
'hello world'.to_source_string.should == 'hello world'
"hello\nworld".to_source_string.should == "hello\nworld"
expect(''.to_source_string).to eq('')
expect('hello world'.to_source_string).to eq('hello world')
expect("hello\nworld".to_source_string).to eq("hello\nworld")
end

it 'single quotes should be escaped' do
"'foo'".to_source_string.should == "\\'foo\\'"
expect("'foo'".to_source_string).to eq("\\'foo\\'")
end

it 'backslashes should be escaped' do
'hello\\nworld'.to_source_string.should == "hello\\\\nworld"
expect('hello\\nworld'.to_source_string).to eq("hello\\\\nworld")
end

it 'should work with Unicode characters' do
'€ información…'.to_source_string.should == '€ información…'
expect('€ información…'.to_source_string).to eq('€ información…')
end

it 'should be able to round trip' do
eval("'" + ''.to_source_string + "'").should == ''
eval("'" + 'hello world'.to_source_string + "'").should == 'hello world'
eval("'" + "hello\nworld".to_source_string + "'").should == "hello\nworld"
eval("'" + "'foo'".to_source_string + "'").should == '\'foo\''
eval("'" + 'hello\\nworld'.to_source_string + "'").should == 'hello\\nworld'
eval("'" + '€ información…'.to_source_string + "'").should == '€ información…'
expect(eval("'" + ''.to_source_string + "'")).to eq('')
expect(eval("'" + 'hello world'.to_source_string + "'")).to eq('hello world')
expect(eval("'" + "hello\nworld".to_source_string + "'")).to eq("hello\nworld")
expect(eval("'" + "'foo'".to_source_string + "'")).to eq('\'foo\'')
expect(eval("'" + 'hello\\nworld'.to_source_string + "'")).to eq('hello\\nworld')
expect(eval("'" + '€ información…'.to_source_string + "'")).to eq('€ información…')
end
end
6 changes: 3 additions & 3 deletions spec/bin/walrus_spec.rb
Expand Up @@ -44,16 +44,16 @@ def walrus *args
# fixed in commit a9e4646
Dir.mkdtemp do
result = walrus 'compile', 'non-existent-template'
result.stderr.should =~ /failed to read input template/
result.status.should == Walrus::Exit::READ_ERROR
expect(result.stderr).to match(/failed to read input template/)
expect(result.status).to eq(Walrus::Exit::READ_ERROR)
end
end

specify 'directory arguments should not trigger infinite recursion' do
# fixed in commit 6d23968
dir = Dir.mkdtemp
result = walrus 'compile', dir
result.should be_success
expect(result).to be_success
end
end
end
8 changes: 4 additions & 4 deletions spec/compiler_spec.rb
Expand Up @@ -13,23 +13,23 @@
# the line
Object.class_eval @parser.compile "## hello world\nhere's some raw text",
:class_name => :CompilerSpecAlpha
Walrus::Grammar::CompilerSpecAlpha.new.fill.should == "here's some raw text"
expect(Walrus::Grammar::CompilerSpecAlpha.new.fill).to eq("here's some raw text")
end

it 'compiles raw text followed by a comment' do
# on the same line (note that trailing newline is not eaten)
Object.class_eval @parser.compile "here's some raw text## hello world\n",
:class_name => :CompilerSpecBeta
Walrus::Grammar::CompilerSpecBeta.new.fill.should == "here's some raw text\n"
expect(Walrus::Grammar::CompilerSpecBeta.new.fill).to eq("here's some raw text\n")

# on two separate lines (note that second trailing newline gets eaten)
Object.class_eval @parser.compile "here's some raw text\n## hello world\n",
:class_name => :CompilerSpecDelta
Walrus::Grammar::CompilerSpecDelta.new.fill.should == "here's some raw text\n"
expect(Walrus::Grammar::CompilerSpecDelta.new.fill).to eq("here's some raw text\n")

# same but with no trailing newline
Object.class_eval @parser.compile "here's some raw text\n## hello world",
:class_name => :CompilerSpecGamma
Walrus::Grammar::CompilerSpecGamma.new.fill.should == "here's some raw text\n"
expect(Walrus::Grammar::CompilerSpecGamma.new.fill).to eq("here's some raw text\n")
end
end
4 changes: 2 additions & 2 deletions spec/grammar/comment_spec.rb
Expand Up @@ -6,7 +6,7 @@
describe Walrus::Grammar::Comment do
context 'compiled' do
it 'produces no meaningful output' do
eval(Walrus::Grammar::Comment.new(' hello world').compile).should == nil
expect(eval(Walrus::Grammar::Comment.new(' hello world').compile)).to eq(nil)
end
end

Expand All @@ -17,7 +17,7 @@

it 'produces no output' do
Object.class_eval @parser.compile('## hello world', :class_name => :CommentSpec)
Walrus::Grammar::CommentSpec.new.fill.should == ''
expect(Walrus::Grammar::CommentSpec.new.fill).to eq('')
end
end
end
8 changes: 4 additions & 4 deletions spec/grammar/echo_directive_spec.rb
Expand Up @@ -22,7 +22,7 @@ def accumulate string
string.source_text = "'hello world'"
@accumulator = Accumulator.new
@accumulator.instance_eval(Walrus::Grammar::EchoDirective.new(Walrus::Grammar::SingleQuotedStringLiteral.new(string)).compile)
@accumulator.content.should == 'hello world'
expect(@accumulator.content).to eq('hello world')
end

# regression test for inputs that previously raised
Expand All @@ -45,21 +45,21 @@ def accumulate string
it 'should be able to round trip' do
# simple example
Object.class_eval @parser.compile("#echo 'foo'", :class_name => :EchoDirectiveSpecAlpha)
Walrus::Grammar::EchoDirectiveSpecAlpha.new.fill.should == 'foo'
expect(Walrus::Grammar::EchoDirectiveSpecAlpha.new.fill).to eq('foo')
end

it 'evaluates multiple expressions, but only accumulates the last' do
Object.class_eval @parser.compile("#echo @foo = 1 + 2; @foo = @foo + 3; @foo",
:class_name => :EchoDirectiveSpecBeta)
Walrus::Grammar::EchoDirectiveSpecBeta.new.fill.should == '6'
expect(Walrus::Grammar::EchoDirectiveSpecBeta.new.fill).to eq('6')
end

it 'evaluates multiple expressions in the same context' do
# this means that local variables can be set in one expression in the
# list and accessed by others in the list
Object.class_eval @parser.compile("#echo foo = 1 + 2; foo = foo + 3; foo",
:class_name => :EchoDirectiveSpecDelta)
Walrus::Grammar::EchoDirectiveSpecDelta.new.fill.should == '6'
expect(Walrus::Grammar::EchoDirectiveSpecDelta.new.fill).to eq('6')
end
end
end

0 comments on commit 6aa9f89

Please sign in to comment.