Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Add spec, fix more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
halfdan committed Jan 28, 2016
1 parent 7ffc1de commit 6e8aa65
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ source 'https://rubygems.org'
# Project requirements
gem 'rake'

# Test requirements
gem 'rspec', :group => 'test'
gem 'rack-test', :require => 'rack/test', :group => 'test'

# Component requirements
gem 'activerecord', '>= 3.1', :require => 'active_record'
gem 'sqlite3'
Expand Down
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GEM
addressable (2.3.8)
arel (6.0.3)
builder (3.2.2)
diff-lcs (1.2.5)
enumerable-lazy (0.0.1)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
Expand Down Expand Up @@ -88,9 +89,24 @@ GEM
rack (1.6.0)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
semantic_range (1.0.0)
sinatra (1.4.6)
rack (~> 1.4)
Expand All @@ -116,7 +132,12 @@ DEPENDENCIES
omniauth
omniauth-github
padrino (= 0.13.1)
rack-test
rake
rspec
semantic_range
sqlite3
unirest

BUNDLED WITH
1.11.2
1 change: 1 addition & 0 deletions app/views/badges/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
%img{src: "/b/#{badge.id}.svg"}
%td
= time_ago_in_words badge.updated_at
ago
%td
%a{href: url(:badges, :edit, id: badge.id)}
Edit
Expand Down
2 changes: 1 addition & 1 deletion app/views/badges/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
ago
%td
- if logged_in? && change.user != current_user
%button.btn.btn-xs.btn-primary +1
%a.btn.btn-xs.btn-primary{href: url()} +1
- if logged_in? && @badge.user == current_user
%button.btn.btn-success.btn-xs Apply
%button.btn.btn-danger.btn-xs Reject
Expand Down
9 changes: 6 additions & 3 deletions app/views/static/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
%p
Create a badge, embed it in your post, maintain it and let the community update the badge when its information is out of date.
%p
%a{class:"btn", href: '/auth/github'}
%span{class:"fa fa-github"}
Sign in with Github
- if logged_in?
%a{href: url(:badges, :index)} Show Badges
- else
%a{class:"btn", href: '/auth/github'}
%span{class:"fa fa-github"}
Sign in with Github
%h2#github Github Badges
%p The embadge API supports generating badges for your Ember projects on Github. The API for github badges is
Expand Down
1 change: 1 addition & 0 deletions models/badge_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class BadgeChange < ActiveRecord::Base
# Copies attributes over to badge
def accept!
badge.apply! self
badge.badge_changes.proposed.each(&:reject!)
self.status = :accepted
self.save
end
Expand Down
7 changes: 7 additions & 0 deletions spec/models/badge_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper'

describe Badge do
it "does things" do
expect(true).to be false
end
end
22 changes: 22 additions & 0 deletions spec/spec.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
begin
require 'rspec/core/rake_task'

spec_tasks = Dir['spec/*/'].each_with_object([]) do |d, result|
result << File.basename(d) unless Dir["#{d}*"].empty?
end

spec_tasks.each do |folder|
desc "Run the spec suite in #{folder}"
RSpec::Core::RakeTask.new("spec:#{folder}") do |t|
t.pattern = "./spec/#{folder}/**/*_spec.rb"
t.rspec_opts = "--color"
end
end

desc "Run complete application spec suite"
task 'spec' => spec_tasks.map { |f| "spec:#{f}" }
rescue LoadError
task :spec do
puts "RSpec is not part of this bundle, skip specs."
end
end
21 changes: 21 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))

RSpec.configure do |conf|
conf.include Rack::Test::Methods
end

# You can use this method to custom specify a Rack app
# you want rack-test to invoke:
#
# app DemoProject::App
# app DemoProject::App.tap { |a| }
# app(DemoProject::App) do
# set :foo, :bar
# end
#
def app(app = nil, &blk)
@app ||= block_given? ? app.instance_eval(&blk) : app
@app ||= Padrino.application
end

0 comments on commit 6e8aa65

Please sign in to comment.