forked from Psli/weibo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #4035: Use railtie for loading app keys automatically and tested…
… with cucumber
- Loading branch information
Gary Or
committed
Aug 15, 2011
1 parent
574c75d
commit e23510e
Showing
13 changed files
with
269 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ rdoc | |
pkg | ||
|
||
## PROJECT::SPECIFIC | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,10 @@ require 'rubygems' | |
require 'bundler/setup' | ||
require 'rake' | ||
require 'rspec/core/rake_task' | ||
require 'cucumber/rake/task' | ||
|
||
desc 'Default: Run the specs' | ||
task :default => 'spec:unit' | ||
task :default => ['spec:unit', 'cucumber'] | ||
|
||
namespace :spec do | ||
desc 'Run unit specs' | ||
|
@@ -14,6 +15,11 @@ namespace :spec do | |
end | ||
task :spec => 'spec:unit' | ||
|
||
desc 'Cucumber' | ||
Cucumber::Rake::Task.new(:cucumber) do |t| | ||
t.fork = true | ||
end | ||
|
||
begin | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |gem| | ||
|
@@ -23,10 +29,16 @@ begin | |
gem.email = "[email protected]" | ||
gem.homepage = "http://github.com/ballantyne/weibo" | ||
gem.authors = ["Scott Ballantyne"] | ||
gem.add_development_dependency "thoughtbot-shoulda", ">= 0" | ||
gem.add_dependency "oauth", "~> 0.4.1" | ||
gem.add_dependency "hashie" | ||
gem.add_dependency "httparty", ">= 0.5.2" | ||
gem.add_dependency "railties" | ||
gem.add_development_dependency "rake" | ||
gem.add_development_dependency "rspec" | ||
gem.add_development_dependency "cucumber" | ||
gem.add_development_dependency "jeweler" | ||
gem.add_development_dependency "aruba" | ||
gem.add_development_dependency "rails", "3.0.9" | ||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings | ||
end | ||
Jeweler::GemcutterTasks.new | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Feature: Load Configurations | ||
In order to simplify the configurations | ||
As a Rails app | ||
I should load config/weibo.yml automatically | ||
|
||
@disable-bundler | ||
Scenario: generate a rails 3 application and load weibo configurations | ||
When I successfully run `bundle exec rails new testapp` | ||
And I cd to "testapp" | ||
And I add weibo from this project as a dependency | ||
When I successfully run `bundle install` | ||
And I write to "config/weibo.yml" with: | ||
""" | ||
development: | ||
api_key: dev_key | ||
api_secret: dev_secret | ||
production: | ||
api_key: prod_key | ||
api_secret: prod_secret | ||
test: | ||
api_key: test_key | ||
api_secret: test_secret | ||
""" | ||
When I successfully run `bundle exec rake -T` | ||
Then the output should contain "rake weibo" | ||
When I successfully run `bundle exec rake weibo RAILS_ENV=development` | ||
Then the output should contain "Weibo API Key: dev_key" | ||
And the output should contain "Weibo API Secret: dev_secret" | ||
When I successfully run `bundle exec rake weibo RAILS_ENV=production` | ||
Then the output should contain "Weibo API Key: prod_key" | ||
And the output should contain "Weibo API Secret: prod_secret" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
When /^I add weibo from this project as a dependency$/ do | ||
append_to_file('Gemfile', %{gem "weibo", :path => "#{PROJECT_ROOT}"}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'aruba/cucumber' | ||
|
||
PROJECT_ROOT = File.expand_path("../../..", __FILE__).freeze | ||
puts PROJECT_ROOT | ||
|
||
Before do | ||
@aruba_timeout_seconds = 3600 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Weibo | ||
class Railtie < Rails::Railtie | ||
config.after_initialize do | ||
weibo_oauth = YAML.load_file(File.join(Rails.root.to_s, 'config', 'weibo.yml'))[Rails.env || "development"] | ||
Weibo::Config.api_key = weibo_oauth["api_key"] | ||
Weibo::Config.api_secret = weibo_oauth["api_secret"] | ||
end | ||
rake_tasks do | ||
load "weibo/tasks/weibo.rake" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
desc 'Show Weibo Configurations' | ||
task :weibo => :environment do | ||
puts "Weibo API Key: #{Weibo::Config.api_key}" | ||
puts "Weibo API Secret: #{Weibo::Config.api_secret}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
require 'spec_helper' | ||
|
||
describe Weibo do | ||
end |
Oops, something went wrong.