Skip to content

Commit

Permalink
added YARD documentation generation task (rake doc); switched webrat …
Browse files Browse the repository at this point in the history
…with capybara; added example capybara test; updated gitignore
  • Loading branch information
gnarmis committed Mar 13, 2012
1 parent eeefe47 commit 772cc45
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
*.lock
*.log
coverage
.yardoc
doc
4 changes: 3 additions & 1 deletion Gemfile
Expand Up @@ -12,7 +12,9 @@ end
group :test do
gem 'rspec'
gem 'rack-test', :require => "rack/test"
gem 'webrat'
gem 'capybara', :require => "capybara/rspec"
gem 'simplecov', :require => false
gem 'redcarpet'
gem 'yard'
end

9 changes: 9 additions & 0 deletions Rakefile
Expand Up @@ -5,6 +5,7 @@ task :default => :help
desc "Run specs"
task :spec do
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ["-f progress", "-r ./spec/spec_helper.rb"]
t.pattern = './spec/**/*_spec.rb'
end
end
Expand All @@ -16,6 +17,13 @@ task :coverage do
sh "rspec -r spec_helper"
end

desc "Produce documentation using YARD"
task :doc do
sh "rm -rf doc/*"
ENV['DOC'] = "true"
sh "yard doc"
end

desc "Run IRB console with app environment"
task :console do
puts "Loading development console..."
Expand All @@ -35,4 +43,5 @@ task :help do
puts "rake pry - Run a Pry console with the enviroment loaded"
puts "rake spec - Run specs"
puts "rake coverage - Run specs and calculate coverage"
puts "rake doc - Produce documentation using YARD"
end
6 changes: 5 additions & 1 deletion lib/foo/foo.rb
Expand Up @@ -10,6 +10,10 @@ class Foo < Sinatra::Base
logger.info "loading index page in foo"
"Hello from foo"
end

get '/button' do
erb :button
end

# I did this to be able to wrap my app in Rack::Auth::Digest for example
## Example:
Expand All @@ -27,4 +31,4 @@ def self.new(*)
end

end
end
end
1 change: 1 addition & 0 deletions lib/foo/views/button.erb
@@ -0,0 +1 @@
<a href="/button" id="button">button</a>
7 changes: 7 additions & 0 deletions lib/foo/views/layout.erb
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head></head>
<body>
<%= yield %>
</body>
</html>
2 changes: 2 additions & 0 deletions spec/foo_api_spec.rb
Expand Up @@ -4,7 +4,9 @@

def app
@app ||= Project::FooAPI
Capybara.app = Project::FooAPI
end


describe "GET '/api/hello'" do
it "should be successful" do
Expand Down
12 changes: 11 additions & 1 deletion spec/foo_spec.rb
@@ -1,15 +1,25 @@
require 'spec_helper'



describe Project::Foo do

def app
@app ||= Project::Foo
Capybara.app = Project::Foo
end

describe "GET '/'" do
it "should be successful" do
get '/'
last_response.should be_ok
last_response.status == 200
end
end

describe "GET '/button", :type => :request do
it "clicks a button" do
visit '/button'
click_link 'button'
end
end
end
7 changes: 2 additions & 5 deletions spec/spec_helper.rb
Expand Up @@ -5,12 +5,9 @@
end
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")

Webrat.configure do |conf|
conf.mode = :rack
end

RSpec.configure do |conf|
conf.include Rack::Test::Methods
conf.include Webrat::Methods
conf.include Webrat::Matchers
conf.include Capybara::DSL
Capybara.javascript_driver = :webkit
end

0 comments on commit 772cc45

Please sign in to comment.