Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clean up library dependencies and documentation

* Upgrade Ruby patch level to 247.
* Wrap documentation lines at 80 characters.
* End sentences with periods.
* Replace Bourne with RSpec Mocks >= 2.14, which now has stubbing and
  spying.
* Upgrade Rake.
* Use RSpec `expect` syntax.
* Configure RSpec to fail fast, saving time during TDD loops and
  CI runs.
* Configure RSpec to run tests in random order, potentially exposing
  inter-dependent tests.
  • Loading branch information...
commit c0a69a337b090819d2752b33bc498ac58a4aaf7a 1 parent 6cbad2c
@croaky croaky authored
View
2  .ruby-version
@@ -1 +1 @@
-2.0.0-p0
+2.0.0-p247
View
20 CONTRIBUTING.md
@@ -3,11 +3,11 @@ Contributing
> How can I contribute to this project?
-* Pull requests are always welcome
-* Address issues wherever possible
-* Prefix commit messages with [#XX] if addressing an existing issue number
-* Use the present tense in commit messages
-* Shorten commit messages to 50 characters with bulleted details
+* Pull requests are always welcome.
+* Address issues wherever possible.
+* Prefix commit messages with [#XX] if addressing an existing issue number.
+* Use the present tense in commit messages.
+* Shorten commit messages to 50 characters with bulleted details.
> In which format should my contributions be submitted?
@@ -28,8 +28,11 @@ See [example trails](trails/unix.json).
Book Resources (e.g. print and e-books)
---------------------------------------
-* Book resources only have to include a "publisher" link if the "uri" is an Amazon link.
-* If the book is available in the iBookstore, include the link under "ibooks" and replace the `https` prepended protocol with `itms-books` as in the above example.
+* Book resources only have to include a "publisher" link if the "uri" is an
+ Amazon link.
+* If the book is available in the iBookstore, include the link under "ibooks"
+ and replace the `https` prepended protocol with `itms-books` as in the above
+ example.
Learning Validations
--------------------
@@ -56,7 +59,8 @@ Validating JSON
* Run the tests, ID generator, and validator with `rake`
* For more detailed debugging, use [JSONlint.com](http://jsonlint.com).
-* Considering using [this regex](https://gist.github.com/4068038) for converting Markdown to JSON
+* Considering using [this regex](https://gist.github.com/4068038) for converting
+ Markdown to JSON.
Merging Pull Requests (for admins)
----------------------------------
View
4 Gemfile
@@ -2,12 +2,10 @@ source 'https://rubygems.org'
ruby '2.0.0'
-gem 'bourne'
gem 'colored'
gem 'httparty'
gem 'json'
gem 'json-schema'
-gem 'mocha', require: false
gem 'rake'
-gem 'rspec'
+gem 'rspec', '>= 2.14'
gem 'webmock'
View
27 Gemfile.lock
@@ -2,30 +2,25 @@ GEM
remote: https://rubygems.org/
specs:
addressable (2.3.3)
- bourne (1.3.2)
- mocha (= 0.13.2)
colored (1.2)
crack (0.3.2)
- diff-lcs (1.2.1)
+ diff-lcs (1.2.4)
httparty (0.10.2)
multi_json (~> 1.0)
multi_xml (>= 0.5.2)
json (1.7.7)
json-schema (1.1.1)
- metaclass (0.0.1)
- mocha (0.13.2)
- metaclass (~> 0.0.1)
multi_json (1.6.1)
multi_xml (0.5.3)
- rake (10.0.3)
- rspec (2.13.0)
- rspec-core (~> 2.13.0)
- rspec-expectations (~> 2.13.0)
- rspec-mocks (~> 2.13.0)
- rspec-core (2.13.0)
- rspec-expectations (2.13.0)
+ rake (10.1.0)
+ rspec (2.14.1)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
+ rspec-core (2.14.4)
+ rspec-expectations (2.14.0)
diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.13.0)
+ rspec-mocks (2.14.1)
webmock (1.11.0)
addressable (>= 2.2.7)
crack (>= 0.3.2)
@@ -34,12 +29,10 @@ PLATFORMS
ruby
DEPENDENCIES
- bourne
colored
httparty
json
json-schema
- mocha
rake
- rspec
+ rspec (>= 2.14)
webmock
View
6 README.md
@@ -3,9 +3,11 @@
NOTE:
=====
-As of 11/13/2012, this is now a JSON-only data resource.
+As of 11/13/2012, this is now a JSON-only data resource.
-To browse the trails, download [Learn for iPhone and iPad](http://www.appstore.com/thoughtbotlearn) in the App Store or visit [learn.thoughtbot.com](https://learn.thoughtbot.com).
+To browse the trails, download [Learn for iPhone and
+iPad](http://www.appstore.com/thoughtbotlearn) in the App Store or visit
+[learn.thoughtbot.com](https://learn.thoughtbot.com).
Trail map
=========
View
13 spec/json_validator_spec.rb
@@ -8,11 +8,10 @@
result = JSONValidator.new(file_name).run
- result.should be_true
- io.string.should eq '.'
+ expect(result).to be_true
+ expect(io.string).to eq '.'
end
-
it 'returns false and outputs an error if the JSON is not valid' do
$stdout = io = StringIO.new
dir = File.dirname(__FILE__)
@@ -20,8 +19,8 @@
result = JSONValidator.new(file_name).run
- result.should be_false
- io.string.should =~ /ERROR/
+ expect(result).to be_false
+ expect(io.string).to match(/ERROR/)
end
it 'returns false and outputs an error if the JSON is non compliant' do
@@ -31,7 +30,7 @@
result = JSONValidator.new(file_name).run
- result.should be_false
- io.string.should =~ /ERROR/
+ expect(result).to be_false
+ expect(io.string).to match %r{ERROR}
end
end
View
7 spec/spec_helper.rb
@@ -8,5 +8,10 @@
end
RSpec.configure do |config|
- config.mock_with :mocha
+ config.expect_with :rspec do |c|
+ c.syntax = :expect
+ end
+
+ config.fail_fast = true
+ config.order = 'random'
end
View
11 spec/trail_runner_spec.rb
@@ -1,7 +1,5 @@
require 'spec_helper'
-require 'mocha/api'
require 'rspec/mocks/standalone'
-require 'bourne'
describe TrailRunner, '#run' do
it 'outputs a starting message' do
@@ -9,18 +7,18 @@
TrailRunner.new.run('JSON validation') {}
- io.string.split("\n")[0].should =~ /Starting JSON validation/
+ expect(io.string.split("\n")[0]).to match %r{Starting JSON validation}
end
it 'yields each file name' do
runner = TrailRunner.new
files = %w(rails.json vim.json)
- runner.stubs(:json_files).returns(files)
+ runner.stub(:json_files) { files }
yielded_files = []
runner.run('Yield test') { |f| yielded_files << f }
- yielded_files.should eq files
+ expect(yielded_files).to eq files
end
it 'prints a closing puts' do
@@ -28,7 +26,6 @@
TrailRunner.new.run('Closing test') {}
- output = io.string[-1, 1]
- output.should == "\n"
+ expect(io.string[-1, 1]).to eq "\n"
end
end
View
41 spec/uri_validator_spec.rb
@@ -5,15 +5,16 @@
stub_request(:head, 'http://example.org')
stub_request(:head, 'http://example.com')
file_name = 'good_json_file.json'
- URIExtractor.stubs(:new).with(file_name).returns %w(
- http://example.org
- http://example.com
- )
+ URIExtractor.
+ stub(:new).
+ with(file_name) {
+ %w(http://example.org http://example.com)
+ }
$stdout = io = StringIO.new
URIValidator.new(file_name).run
- io.string.should eq '..'
+ expect(io.string).to eq '..'
end
it 'outputs an error for each invalid URI' do
@@ -24,42 +25,42 @@
stub_request(:head, 'http://dead.link.com').to_raise(Errno::ECONNREFUSED)
stub_request(:get, 'http://dead.link.com').to_raise(Errno::ECONNREFUSED)
file_name = 'path/to/bad_json_file.json'
- URIExtractor.stubs(:new).with(file_name).returns %w(
- http://bad.example.org
- http://thoughtbot.com/404
- http://dead.link.com
- )
+ URIExtractor.
+ stub(:new).
+ with(file_name) {
+ %w(http://bad.example.org http://thoughtbot.com/404 http://dead.link.com)
+ }
$stdout = io = StringIO.new
URIValidator.new(file_name).run
- io.string.should =~ %r{ERROR in bad_json_file\.json: http://bad\.example\.org}
- io.string.should =~ %r{ERROR in bad_json_file\.json: http://thoughtbot\.com/404}
+ expect(io.string).to match %r{ERROR in bad_json_file\.json: http://bad\.example\.org}
+ expect(io.string).to match %r{ERROR in bad_json_file\.json: http://thoughtbot\.com/404}
end
it 'retries with a GET request on a method not allowed error' do
stub_request(:head, 'http://example.com').to_return(status: 405)
stub_request(:get, 'http://example.com')
file_name = 'rails.json'
- URIExtractor.stubs(:new).with(file_name).returns %w(http://example.com)
- $stdout = io = StringIO.new
+ URIExtractor.stub(:new).with(file_name) { %w(http://example.com) }
+ $stdout = StringIO.new
URIValidator.new(file_name).run
- WebMock.should have_requested(:head, 'http://example.com')
- WebMock.should have_requested(:get, 'http://example.com')
+ expect(WebMock).to have_requested(:head, 'http://example.com')
+ expect(WebMock).to have_requested(:get, 'http://example.com')
end
it 'retries with a GET request on an exception' do
stub_request(:head, 'http://example.com').to_raise(SocketError)
stub_request(:get, 'http://example.com')
file_name = 'rails.json'
- URIExtractor.stubs(:new).with(file_name).returns %w(http://example.com)
- $stdout = io = StringIO.new
+ URIExtractor.stub(:new).with(file_name) { %w(http://example.com) }
+ $stdout = StringIO.new
URIValidator.new(file_name).run
- WebMock.should have_requested(:head, 'http://example.com')
- WebMock.should have_requested(:get, 'http://example.com')
+ expect(WebMock).to have_requested(:head, 'http://example.com')
+ expect(WebMock).to have_requested(:get, 'http://example.com')
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.