Permalink
Browse files

Tests added

  • Loading branch information...
1 parent d542b97 commit bfa4b2781e1922472ff6f9c1f0950e6996e34ec1 @dzaporozhets dzaporozhets committed Nov 6, 2012
Showing with 151 additions and 1 deletion.
  1. +19 −1 Gemfile
  2. +17 −0 Gemfile.lock
  3. +24 −0 Guardfile
  4. +3 −0 public/.directory
  5. +8 −0 spec/models/build_spec.rb
  6. +13 −0 spec/models/project_spec.rb
  7. +38 −0 spec/requests/projects_spec.rb
  8. +2 −0 spec/spec_helper.rb
  9. +27 −0 spec/support/login_helpers.rb
View
20 Gemfile
@@ -1,5 +1,13 @@
source 'https://rubygems.org'
+def darwin_only(require_as)
+ RUBY_PLATFORM.include?('darwin') && require_as
+end
+
+def linux_only(require_as)
+ RUBY_PLATFORM.include?('linux') && require_as
+end
+
gem 'rails', '3.2.8'
# DB
@@ -41,10 +49,20 @@ group :assets do
gem 'bootstrap-sass'
end
+
group :development do
gem 'annotate'
+end
+
+
+group :development, :test do
gem 'pry'
gem 'rspec-rails'
gem 'capybara'
- gem 'annotate'
+
+ gem 'shoulda-matchers'
+ gem 'guard-rspec'
+ gem 'rb-fsevent', require: darwin_only('rb-fsevent')
+ gem 'growl', require: darwin_only('growl')
+ gem 'rb-inotify', require: linux_only('rb-inotify')
end
View
@@ -65,6 +65,12 @@ GEM
ffi (1.1.5)
foreman (0.60.2)
thor (>= 0.13.6)
+ growl (1.0.3)
+ guard (1.3.2)
+ listen (>= 0.4.2)
+ thor (>= 0.14.6)
+ guard-rspec (1.2.1)
+ guard (>= 1.1)
haml (3.1.7)
haml-rails (0.3.5)
actionpack (>= 3.1, < 4.1)
@@ -81,6 +87,7 @@ GEM
libv8 (3.3.10.4)
libwebsocket (0.1.5)
addressable
+ listen (0.5.0)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -121,6 +128,9 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
+ rb-fsevent (0.9.1)
+ rb-inotify (0.8.8)
+ ffi (>= 0.5.0)
rdoc (3.12)
json (~> 1.4)
redis (3.0.2)
@@ -156,6 +166,8 @@ GEM
multi_json (~> 1.0)
rubyzip
settingslogic (2.0.8)
+ shoulda-matchers (1.3.0)
+ activesupport (>= 3.0.0)
sinatra (1.3.3)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
@@ -200,16 +212,21 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
foreman
+ growl
+ guard-rspec
haml-rails
jquery-rails
mysql2
pry
rails (= 3.2.8)
rake
+ rb-fsevent
+ rb-inotify
resque
rspec-rails
sass-rails (~> 3.2.3)
settingslogic
+ shoulda-matchers
stamp
therubyracer
thin
View
@@ -0,0 +1,24 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+ # Turnip features and steps
+ watch(%r{^spec/acceptance/(.+)\.feature$})
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
+end
+
View
@@ -0,0 +1,3 @@
+[Dolphin]
+PreviewsShown=true
+Timestamp=2012,11,5,14,44,35
@@ -0,0 +1,8 @@
+require 'spec_helper'
+
+describe Build do
+ subject { Build.new }
+
+ it { should belong_to(:project) }
+end
+
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe Project do
+ subject { Project.new }
+
+ it { should have_many(:builds) }
+
+ it { should validate_presence_of :name }
+ it { should validate_presence_of :path }
+ it { should validate_presence_of :scripts }
+ it { should validate_presence_of :timeout }
+ it { should validate_presence_of :token }
+end
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+describe "Projects" do
+ before do
+ login_as :user
+
+ opts = {
+ id: 1,
+ name: 'GitLab',
+ status: nil,
+ last_build: nil
+ }
+
+ @project = Project.new
+ @project.stub(opts)
+
+ end
+
+ describe "GET /projects" do
+ before do
+ Project.stub(all: [@project])
+ visit projects_path
+ end
+
+ it { page.should have_content @project.name }
+ it { page.should have_content 'Add Project' }
+ end
+
+ describe "GET /projects/:id" do
+ before do
+ Project.stub(find: @project)
+ visit project_path(@project)
+ end
+
+ it { page.should have_content @project.name }
+ end
+end
+
View
@@ -9,6 +9,8 @@
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
+ config.include LoginHelpers, type: :request
+
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
@@ -0,0 +1,27 @@
+module LoginHelpers
+ def login_as(role)
+ raise 'Only :user allowed' unless role == :user
+
+ @user = User.create(
+ email: 'test@test.com',
+ password: '123456',
+ password_confirmation: '123456'
+ )
+
+ login_with(@user)
+ end
+
+ # Internal: Login as the specified user
+ #
+ # user - User instance to login with
+ def login_with(user)
+ visit new_user_session_path
+ fill_in "user_email", with: user.email
+ fill_in "user_password", with: "123456"
+ click_button "Sign in"
+ end
+
+ def logout
+ click_link "Logout" rescue nil
+ end
+end

0 comments on commit bfa4b27

Please sign in to comment.