Permalink
Browse files

RSpecを使ってテストを書きなおした

  • Loading branch information...
1 parent 14e4965 commit 911b48035715f2c8bd70202897a7a376f95a1037 Tatsuro Ueda committed Feb 7, 2013
Showing with 829 additions and 190 deletions.
  1. +1 −0 .idea/.name
  2. +5 −0 .idea/encodings.xml
  3. +5 −0 .idea/misc.xml
  4. +9 −0 .idea/modules.xml
  5. +22 −0 .idea/p120908-new-movies-server.iml
  6. +5 −0 .idea/scopes/scope_settings.xml
  7. +7 −0 .idea/vcs.xml
  8. +407 −0 .idea/workspace.xml
  9. +3 −1 Gemfile
  10. +14 −0 Gemfile.lock
  11. +19 −10 app.rb
  12. +183 −179 feed.rb
  13. +22 −0 spec/app_spec.rb
  14. +53 −0 spec/feed_spec.rb
  15. +40 −0 spec/feed_spec_helper.rb
  16. +11 −0 spec/spec_helper.rb
  17. +23 −0 spec/url_spec.rb
View
@@ -0,0 +1 @@
+p120908-new-movies-server
View
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+
View
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby" project-jdk-type="RUBY_SDK" />
+</project>
+
View
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/p120908-new-movies-server.iml" filepath="$PROJECT_DIR$/.idea/p120908-new-movies-server.iml" />
+ </modules>
+ </component>
+</project>
+
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="RUBY_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.0.22, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="dalli (v2.1.0, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.3, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="newrelic_rpm (v3.4.2.1, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rack (v1.4.1, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rack-protection (v1.2.0, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.2, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.12.0, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.12.2, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.12.1, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.12.2, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="sinatra (v1.3.2, ruby) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="tilt (v1.3.3, ruby) [gem]" level="application" />
+ </component>
+</module>
+
@@ -0,0 +1,5 @@
+<component name="DependencyValidationManager">
+ <state>
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+ </state>
+</component>
View
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project>
+
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,4 +1,6 @@
source 'https://rubygems.org'
gem 'sinatra', '1.3.2'
gem 'newrelic_rpm'
-gem 'dalli'
+gem 'dalli'
+gem 'rspec'
+gem 'rack-test'
View
@@ -2,10 +2,21 @@ GEM
remote: https://rubygems.org/
specs:
dalli (2.1.0)
+ diff-lcs (1.1.3)
newrelic_rpm (3.4.2.1)
rack (1.4.1)
rack-protection (1.2.0)
rack
+ rack-test (0.6.2)
+ rack (>= 1.0)
+ rspec (2.12.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.12.2)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
@@ -14,8 +25,11 @@ GEM
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
dalli
newrelic_rpm
+ rack-test
+ rspec
sinatra (= 1.3.2)
View
29 app.rb
@@ -9,10 +9,15 @@
require 'newrelic_rpm'
end
-set :cache, Dalli::Client.new(ENV['MEMCACHE_SERVERS'],
- :username => ENV['MEMCACHE_USERNAME'],
- :password => ENV['MEMCACHE_PASSWORD'],
- :expires_in => 60 * 30)
+configure :production do
+ set :cache, Dalli::Client.new(
+ ENV['MEMCACHE_SERVERS'],
+ :username => ENV['MEMCACHE_USERNAME'],
+ :password => ENV['MEMCACHE_PASSWORD'],
+ :expires_in => 60 * 30
+ )
+end
+
# data = settings.cache.get(tag)
# settings.cache.set(tag,data)
@@ -80,12 +85,14 @@ def feed_vimeo(tag)
@key = 'tag1=' + params['tag1']
end
- # if cache exists
- if output = settings.cache.get(@key)
- output
+ configure :production do
+ # if cache exists
+ if output = settings.cache.get(@key)
+ output
+ else
+ end
# if cache does not exists
- else
# Thread One
t1 = Thread.new(params['tag1']) do |param_tag1|
@feed_nico = feed_nico(param_tag1)
@@ -120,8 +127,10 @@ def feed_vimeo(tag)
end
after '/new_movie' do
- puts 'saved'
- settings.cache.set(@key, @output)
+ puts 'saved' if DEBUG_APP
+ configure :production do
+ settings.cache.set(@key, @output)
+ end
end
get '/test.html' do
Oops, something went wrong.

1 comment on commit 911b480

Collaborator

utwang commented on 911b480 Feb 7, 2013

#9

Please sign in to comment.