Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #22 from JPrevost/update_gems
Browse files Browse the repository at this point in the history
Update gems and switch to expect syntax
  • Loading branch information
JPrevost committed Jul 15, 2014
2 parents 4524d92 + 1a11c3b commit bc083a4
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 82 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
/log/*.log
/tmp
.DS_Store
/coverage
*.swp

# Ignore local env var loader
config/heroku_env.rb
config/heroku_env.rb
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gem 'coveralls', require: false

group :development do
gem 'sqlite3'
gem 'spring'
gem 'spring-commands-rspec'
end

group :production do
Expand Down
33 changes: 21 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GEM
byebug (3.1.2)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
capybara (2.2.1)
capybara (2.4.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
Expand All @@ -54,7 +54,7 @@ GEM
diff-lcs (1.2.5)
docile (1.1.5)
erubis (2.7.0)
execjs (2.0.2)
execjs (2.2.1)
hike (1.2.3)
i18n (0.6.11)
jquery-rails (3.1.1)
Expand Down Expand Up @@ -101,18 +101,22 @@ GEM
rest-client (1.7.1)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
rspec-core (3.0.2)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-support (~> 3.0.0)
rspec-rails (3.0.1)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
safe_yaml (1.0.3)
sass (3.2.19)
sass-rails (4.0.3)
Expand All @@ -125,6 +129,9 @@ GEM
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
spring (1.1.3)
spring-commands-rspec (1.0.2)
spring (>= 0.9.1)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -146,7 +153,7 @@ GEM
polyglot (>= 0.3.1)
tzinfo (1.2.1)
thread_safe (~> 0.1)
uglifier (2.5.0)
uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
vcr (2.9.2)
Expand All @@ -172,6 +179,8 @@ DEPENDENCIES
rails_12factor
rspec-rails
sass-rails (>= 3.2)
spring
spring-commands-rspec
sqlite3
uglifier
vcr
Expand Down
4 changes: 4 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
4 changes: 4 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
7 changes: 7 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
18 changes: 18 additions & 0 deletions bin/spring
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby

# This file loads spring without using Bundler, in order to be fast
# It gets overwritten when you run the `spring binstub` command

unless defined?(Spring)
require "rubygems"
require "bundler"

if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = ""
Gem.paths = ENV

gem "spring", match[1]
require "spring/binstub"
end
end
64 changes: 28 additions & 36 deletions spec/models/bustimes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,64 +1,56 @@
require 'spec_helper'

describe Bustime, :vcr do

it "should have access to the API key" do
expect do
ENV['CTA_API_KEY'].defined?
end.to be_true
end

describe "busroutes" do
describe 'busroutes' do
before { @busroutes = Bustime.new.busroutes }

it "should return an array (of hashes) of all busroutes" do
@busroutes.kind_of?(Array).should be_true
it 'returns an array (of hashes) of all busroutes' do
expect(@busroutes.is_a?(Array)).to be true
end

it "should contain 147 Outer Drive Express" do
@busroutes.select { |bus| bus["rt"] == "147" }.length().should equal 1
it 'contains 147 Outer Drive Express' do
expect(@busroutes.select { |bus| bus['rt'] == '147' }.length).to eq(1)
end

end

describe "busdirections" do
describe 'busdirections' do
before { @busdirections = Bustime.new.busdirections(147) }

it "should return an array of hashes with directions for a particular route" do
@busdirections.kind_of?(Array).should be_true
it 'returns an array of hashes with directions for a particular route' do
expect(@busdirections.is_a?(Array)).to be true
end

it "should return North Bound as one of the directions for the 147 route" do
@busdirections.select { |dir| dir["dir"] == "Northbound"}.length().should equal 1
it 'returns North Bound as one of the directions for the 147 route' do
expect(@busdirections.select { |dir| dir['dir'] == 'Northbound' }
.length).to eq(1)
end

end

describe "busstops" do
describe 'busstops' do
before { @busstops = Bustime.new.busstops(147, 'Northbound') }

before { @busstops = Bustime.new.busstops(147,'Northbound') }

it "should return an array of hashes of busstops for supplied route and direction" do
@busstops.kind_of?(Array).should be_true
it 'returns an array of hashes of busstops' do
expect(@busstops.is_a?(Array)).to be true
end

it "should contain Michigan and Huron for 147 North Bound" do
@busstops.select { |stpid| stpid["stpnm"] == "Michigan & Huron" }.length().should equal 1
it 'contains Michigan and Huron for 147 North Bound' do
expect(@busstops.select { |stpid| stpid['stpnm'] == 'Michigan & Huron' }
.length).to eq(1)
end

end

describe "buspredictions" do
before { @buspredictions = Bustime.new.buspredictions(147,'Northbound',1125) }

it "should return an array of hashes with predictions for supplied route, direction and stopid" do
@buspredictions.kind_of?(Array).should be_true
describe 'buspredictions' do
before do
@buspredictions = Bustime.new.buspredictions(147, 'Northbound', 1125)
end

it "should contain the stopname in the predictions" do
@buspredictions.select { |stpnm| stpnm["stpnm"] == "Michigan & Huron" }.length().should > 0
it 'returns an array of hashes with predictions' do
expect(@buspredictions.is_a?(Array)).to be true
end

it 'contains the stopname in the predictions' do
expect(@buspredictions.select { |s| s['stpnm'] == 'Michigan & Huron' }
.length).to be > 0
end
end

end
end
43 changes: 19 additions & 24 deletions spec/requests/bustime_pages_spec.rb
Original file line number Diff line number Diff line change
@@ -1,73 +1,67 @@
require 'spec_helper'

describe "BustimePages", :vcr do

subject { page }

before { visit root_path }

describe "Home page" do

it "should have a breadcrumb" do
page.should have_content "Choose a Route"
expect(page).to have_content("Choose a Route")
end

it "should display links to various routes" do
page.should have_link('147 Outer Drive Express', :href => busdirections_path(147,'Outer Drive Express'))
page.should have_link('66 Chicago', :href => busdirections_path(66,'Chicago'))
expect(page).to have_link('147 Outer Drive Express', :href => busdirections_path(147,'Outer Drive Express'))
expect(page).to have_link('66 Chicago', :href => busdirections_path(66,'Chicago'))
end

describe "clicking 147 bus" do

before { click_link('147 Outer Drive Express') }

it "should have a breadcrumb" do
page.should have_content "Route Choose a Direction"
expect(page).to have_content "Route Choose a Direction"
end

it "should have direction links" do
page.should have_link('Northbound', :href => busstops_path(147,'Outer Drive Express', 'Northbound'))
page.should have_link('Southbound', :href => busstops_path(147,'Outer Drive Express', 'Southbound'))
expect(page).to have_link('Northbound', :href => busstops_path(147,'Outer Drive Express', 'Northbound'))
expect(page).to have_link('Southbound', :href => busstops_path(147,'Outer Drive Express', 'Southbound'))
end

it "should display route information" do
page.should have_content "147 Outer Drive Express"
expect(page).to have_content "147 Outer Drive Express"
end

describe "clicking Northbound" do

before { click_link('Northbound') }

it "should have a breadcrumb" do
page.should have_content "Route Direction Choose a Stop"
expect(page).to have_content "Route Direction Choose a Stop"
end

it "should list bus stops" do
page.should have_link('Michigan & Huron', :href => buspredictions_path(147,'Outer Drive Express', 'Northbound', 1125, 'Michigan & Huron'))
page.should have_link('Congress & Michigan', :href => buspredictions_path(147,'Outer Drive Express', 'Northbound', 4725, 'Congress & Michigan'))
expect(page).to have_link('Michigan & Huron', :href => buspredictions_path(147,'Outer Drive Express', 'Northbound', 1125, 'Michigan & Huron'))
expect(page).to have_link('Congress & Michigan', :href => buspredictions_path(147,'Outer Drive Express', 'Northbound', 4725, 'Congress & Michigan'))
end


describe "Clicking Michigan & Huron" do
before { click_link('Michigan & Huron') }

it "should have a breadcrumb" do
page.should have_content "Route Direction Stop Upcoming Buses"
expect(page).to have_content "Route Direction Stop Upcoming Buses"
end

it "should display route and stop information" do
page.should have_content "147 Outer Drive Express, Northbound, Michigan & Huron"
expect(page).to have_content "147 Outer Drive Express, Northbound, Michigan & Huron"
end

it "should display bus predictions" do
page.should have_content "2 Min (to Howard Station)"
page.should have_content "28 Min (to Howard Station)"
expect(page).to have_content "2 Min (to Howard Station)"
expect(page).to have_content "28 Min (to Howard Station)"
end

it { should have_content('Refresh') }

it "should have more info links to bus detail" do
page.should have_link("More Info", :href => "#modal-4077")
expect(page).to have_link("More Info", :href => "#modal-4077")
end

describe 'recent stops' do
Expand All @@ -78,19 +72,20 @@
end

it 'only remembers 6 recent stops and removes the least recently used' do
pending
skip 'write this test'
end

it 'only remembers unique recent stops' do
pending
skip
end

it 'moves the most recent stop to the first position' do
pending
skip
end
end
end
end
end
end
end

8 changes: 4 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara'
require 'coveralls'
Coveralls.wear!

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

RSpec.configure do |config|
config.include Rails.application.routes.url_helpers
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
Expand Down
5 changes: 0 additions & 5 deletions spec/support/vcr_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@
c.configure_rspec_metadata!
end

RSpec.configure do |c|
# so we can use :vcr rather than :vcr => true;
# in RSpec 3 this will no longer be necessary.
c.treat_symbols_as_metadata_keys_with_true_values = true
end

0 comments on commit bc083a4

Please sign in to comment.