Browse files

Getting stuff ready in order to remove Cucumber as a dependency.

  • Loading branch information...
1 parent 3e7e6b4 commit c097249b2191377b3b7023d8e982034827408201 @ifesdjeen ifesdjeen committed May 29, 2011
View
7 Gemfile
@@ -21,16 +21,14 @@ gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
gem 'rake', '~> 0.9.0'
group :test do
- gem 'capybara'
- gem 'cucumber-rails'
gem 'database_cleaner'
gem 'factory_girl', '~> 2.0.0.beta2'
gem 'factory_girl_rails', :git => 'https://github.com/thoughtbot/factory_girl_rails.git'
- gem 'fakeweb'
gem 'mocha'
gem 'test_declarative'
gem 'web-socket-ruby'
gem 'fakeredis'
+ gem 'webmock'
platforms :ruby_18 do
gem 'minitest'
gem 'minitest_tu_shim'
@@ -41,4 +39,7 @@ group :test do
platforms :mri_19 do
gem 'ruby-debug19'
end
+ gem 'steak', '~> 1.1.0'
+ gem 'rspec-rails', '~> 2.6.1'
+ gem 'capybara', '~> 0.4.1.2'
end
View
51 Gemfile.lock
@@ -55,13 +55,16 @@ GEM
bcrypt-ruby (2.1.4)
bcrypt-ruby (2.1.4-java)
builder (2.1.2)
- capybara (1.0.0.beta1)
+ capybara (0.4.1.2)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27)
- xpath (~> 0.1.4)
+ xpath (~> 0.1.3)
+ celerity (0.8.9)
childprocess (0.1.9)
ffi (~> 1.0.6)
chunky_png (1.2.0)
@@ -71,17 +74,7 @@ GEM
fssm (>= 0.2.7)
sass (~> 3.1)
crack (0.1.8)
- cucumber (0.10.3)
- builder (>= 2.1.2)
- diff-lcs (>= 1.1.2)
- gherkin (>= 2.3.8)
- json (>= 1.4.6)
- term-ansicolor (>= 1.0.5)
- cucumber-rails (0.5.0)
- capybara (>= 1.0.0.beta1)
- cucumber (>= 0.10.2)
- nokogiri (>= 1.4.4)
- rack-test (>= 0.5.7)
+ culerity (0.2.15)
database_cleaner (0.6.7)
devise (1.3.4)
bcrypt-ruby (~> 2.1.2)
@@ -102,18 +95,12 @@ GEM
eventmachine (0.12.10-java)
factory_girl (2.0.0.beta2)
fakeredis (0.1.2)
- fakeweb (1.3.0)
faraday (0.5.7)
addressable (~> 2.2.4)
multipart-post (~> 1.1.0)
rack (< 2, >= 1.1.0)
ffi (1.0.9)
- ffi (1.0.9-java)
fssm (0.2.7)
- gherkin (2.3.9)
- json (>= 1.4.6)
- gherkin (2.3.9-java)
- json (>= 1.4.6)
hoptoad_notifier (2.4.10)
activesupport
builder
@@ -192,6 +179,19 @@ GEM
vegas (~> 0.1.2)
resque-meta (1.0.3)
resque (~> 1.8)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.3)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
@@ -220,7 +220,8 @@ GEM
sinatra (1.2.6)
rack (~> 1.1)
tilt (< 2.0, >= 1.2.2)
- term-ansicolor (1.0.5)
+ steak (1.1.0)
+ rspec (>= 1.3)
test_declarative (0.0.5)
thor (0.14.6)
tilt (1.3.2)
@@ -238,6 +239,9 @@ GEM
rack (>= 1.0)
weakling (0.0.4-java)
web-socket-ruby (0.1.0)
+ webmock (1.6.4)
+ addressable (~> 2.2, > 2.2.5)
+ crack (>= 0.1.7)
xpath (0.1.4)
nokogiri (~> 1.3)
yajl-ruby (0.8.2)
@@ -250,17 +254,15 @@ PLATFORMS
DEPENDENCIES
SystemTimer (~> 1.2.3)
- capybara
+ capybara (~> 0.4.1.2)
compass (~> 0.11.0)
- cucumber-rails
database_cleaner
devise (~> 1.3.3)
em-http-request (~> 0.3.0)
em-websocket (~> 0.3.0)
factory_girl (~> 2.0.0.beta2)
factory_girl_rails!
fakeredis
- fakeweb
hoptoad_notifier (~> 2.4.9)
jammit (~> 0.6.0)
minitest
@@ -275,10 +277,13 @@ DEPENDENCIES
refraction (~> 0.2.0)
resque (~> 1.17.0)
resque-meta (~> 1.0.3)
+ rspec-rails (~> 2.6.1)
ruby-debug
ruby-debug19
+ steak (~> 1.1.0)
test_declarative
travis-ci-em-pusher (~> 0.1.1)
unobtrusive_flash (~> 0.0.2)
web-socket-ruby
+ webmock
yajl-ruby (~> 0.8.2)
View
3 app/controllers/repositories_controller.rb
@@ -12,8 +12,9 @@ def show
end
format.png do
status = Repository.human_status_by(params.slice(:owner_name, :name))
+
response.headers["Expires"] = CGI.rfc1123_date(Time.now)
- send_file(Rails.public_path + "/images/status/#{status}.png", :type => 'image/png', :disposition => 'inline')
+ send_file("#{Rails.public_path}/images/status/#{status}.png", :type => 'image/png', :disposition => 'inline')
end
end
end
View
14 docs/capybara.textile
@@ -0,0 +1,14 @@
+h1. Chrome
+
+Since Firefox comes with Websockets "disabled:"https://developer.mozilla.org/en/WebSockets", even though there's a way to enable it through:
+ a. go to about:config
+ b. set network.websocket.enabled to true
+ c. set network.websocket.override-security-block to true.
+ d. restart Firefox
+
+But it's still easier to support Chrome by default.
+In order to get it to work:
+ a. download Chrome itself from "http://www.google.com/landing/chrome/beta/":"http://www.google.com/landing/chrome/beta/" (yes, it's Beta, but Selenium Webdriver only supports that version for now)
+ b. download Chrome Driver from "http://code.google.com/p/selenium/downloads/list":"http://code.google.com/p/selenium/downloads/list"
+ c. unzip your stuff anywhere and add that dir to your PATH
+
View
5 spec/acceptance/acceptance_helper.rb
@@ -0,0 +1,5 @@
+require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
+require "steak"
+
+# Put your acceptance spec helpers inside /spec/acceptance/support
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
View
14 spec/acceptance/status_button_spec.rb
@@ -0,0 +1,14 @@
+require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
+
+feature "Status Button", %q{
+ In order to show the latest build status for my project
+ As a user
+ I want to be able to embed live status buttons on my website
+} do
+
+ scenario 'Show an "unknown" button when the repository does not exist' do
+ Repository.delete_all(:owner_name => "svenfuchs", :name => "travis")
+ visit "/svenfuchs/travis.png"
+ controller.should_receive(:send_file).with("/images/status/unknown.png").once
+ end
+end
View
5 spec/acceptance/support/helpers.rb
@@ -0,0 +1,5 @@
+module HelperMethods
+ # Put helper methods you need to be available in all tests here.
+end
+
+RSpec.configuration.include HelperMethods, :type => :acceptance
View
9 spec/acceptance/support/paths.rb
@@ -0,0 +1,9 @@
+module NavigationHelpers
+ # Put helper methods related to the paths in your application here.
+
+ def homepage
+ "/"
+ end
+end
+
+RSpec.configuration.include NavigationHelpers, :type => :acceptance
View
50 spec/controllers/repositories_controller_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+describe RepositoriesController do
+ describe "GET 'show'" do
+ before(:each) do
+ controller.stub!(:render)
+ end
+
+ let(:repository) { Factory.create(:repository, :owner_name => "sven", :name => "fuchs") }
+
+ it 'should show an "unknown" button when the repository does not exist' do
+ controller.should_receive(:send_file).with("#{Rails.public_path}/images/status/unknown.png", {:type=>"image/png", :disposition=>"inline"}).once
+
+ post :show, :format => "png", :owner_name => "sven", :name => "fuchs"
+ end
+
+ it 'should how an "unknown" button when it only has a build thats not finished' do
+ Factory(:running_build)
+
+ controller.should_receive(:send_file).with("#{Rails.public_path}/images/status/unknown.png", {:type=>"image/png", :disposition=>"inline"}).once
+
+ post :show, :format => "png", :owner_name => "sven", :name => "fuchs"
+ end
+
+ it 'should show an "unstable" button when the repository has broken build' do
+ Factory(:broken_build, :repository => repository)
+
+ controller.should_receive(:send_file).with("#{Rails.public_path}/images/status/unstable.png", {:type=>"image/png", :disposition=>"inline"}).once
+
+ post :show, :format => "png", :owner_name => "sven", :name => "fuchs"
+ end
+
+ it 'should show a "stable" button when the repository\'s last build passed' do
+ Factory(:successfull_build, :repository => repository)
+
+ controller.should_receive(:send_file).with("#{Rails.public_path}/images/status/stable.png", {:type=>"image/png", :disposition=>"inline"}).once
+
+ post :show, :format => "png", :owner_name => "sven", :name => "fuchs"
+ end
+
+ it 'should show a "stable" button when the previous build passed and there\'s one still running' do
+ Factory(:successfull_build, :repository => repository)
+ Factory(:running_build, :repository => repository)
+
+ controller.should_receive(:send_file).with("#{Rails.public_path}/images/status/stable.png", {:type=>"image/png", :disposition=>"inline"}).once
+
+ post :show, :format => "png", :owner_name => "sven", :name => "fuchs"
+ end
+ end
+end
View
27 spec/spec_helper.rb
@@ -0,0 +1,27 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+
+# 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}
+
+RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+end
View
15 test/factories.rb
@@ -20,6 +20,21 @@
committer_email 'svenfuchs@artweb-design.de'
end
+ factory :running_build, :parent => :build do
+ started_at { Time.now }
+ end
+
+ factory :successfull_build, :parent => :build do
+ status 0
+ finished_at { Time.now }
+ end
+
+ factory :broken_build, :parent => :build do
+ status 1
+ started_at { Time.now }
+ finished_at { Time.now }
+ end
+
factory :user do
name 'Sven Fuchs'
login 'svenfuchs'

0 comments on commit c097249

Please sign in to comment.