memcached-manager 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.rspec +2 -0
  2. data/.travis.yml +19 -0
  3. data/CONTRIBUTING.md +28 -0
  4. data/Gemfile +26 -0
  5. data/Gemfile.lock +143 -0
  6. data/README.rdoc +15 -1
  7. data/Rakefile +60 -0
  8. data/VERSION +1 -0
  9. data/config.ru +2 -6
  10. data/features/api/create_memcached_key.feature +6 -0
  11. data/features/api/delete_memcached_key.feature +6 -0
  12. data/features/api/list_memcached_keys.feature +6 -0
  13. data/features/api/set_memcached_info.feature +5 -0
  14. data/features/api/show_memcached_key.feature +10 -0
  15. data/features/api/show_memcached_stats.feature +5 -0
  16. data/features/api/update_memcached_key.feature +7 -0
  17. data/features/step_definitions/api/create_memcached_key.rb +21 -0
  18. data/features/step_definitions/api/delete_memcached_key.rb +7 -0
  19. data/features/step_definitions/api/list_memcached_keys.rb +16 -0
  20. data/features/step_definitions/api/show_memcached_key.rb +18 -0
  21. data/features/step_definitions/api/show_memcached_stats.rb +3 -0
  22. data/features/step_definitions/api/update_memcached_key.rb +18 -0
  23. data/features/step_definitions/set_memcached_info.rb +25 -0
  24. data/features/step_definitions/webapp/create_memcached_key.rb +10 -0
  25. data/features/step_definitions/webapp/delete_memcached_key.rb +16 -0
  26. data/features/step_definitions/webapp/edit_memcached_key.rb +3 -0
  27. data/features/step_definitions/webapp/list_memcached_keys.rb +4 -0
  28. data/features/step_definitions/webapp/show_memcached_key.rb +4 -0
  29. data/features/step_definitions/webapp/show_memcached_stats.rb +5 -0
  30. data/features/support/env.rb +28 -0
  31. data/features/support/hooks.rb +3 -0
  32. data/features/webapp/create_memcached_key.feature +9 -0
  33. data/features/webapp/delete_memcached_key.feature +8 -0
  34. data/features/webapp/edit_memcached_key.feature +9 -0
  35. data/features/webapp/list_memcached_keys.feature +8 -0
  36. data/features/webapp/show_memcached_key.feature +7 -0
  37. data/features/webapp/show_memcached_stats.feature +6 -0
  38. data/lib/api.rb +85 -0
  39. data/lib/extensions/api_response.rb +15 -0
  40. data/lib/extensions/errors.rb +19 -0
  41. data/lib/extensions/memcached_connection.rb +15 -0
  42. data/lib/extensions/memcached_inspector.rb +49 -0
  43. data/lib/extensions/memcached_settings.rb +18 -0
  44. data/lib/extensions.rb +14 -0
  45. data/lib/memcached-manager.rb +4 -0
  46. data/lib/public/images/glyphicons-halflings-white.png +0 -0
  47. data/lib/public/images/glyphicons-halflings.png +0 -0
  48. data/lib/public/javascripts/angular/controllers.js +89 -0
  49. data/lib/public/javascripts/angular/routes.js +66 -0
  50. data/lib/public/javascripts/angular/services/notification.js +16 -0
  51. data/lib/public/javascripts/angular/services/resources.js +20 -0
  52. data/lib/public/javascripts/angular/services/response.js +10 -0
  53. data/lib/public/javascripts/angular-resource.min.js +10 -0
  54. data/lib/public/javascripts/angular-ui-states.min.js +7 -0
  55. data/lib/public/javascripts/angular.min.js +161 -0
  56. data/lib/public/javascripts/application.js +18 -0
  57. data/lib/public/javascripts/jquery-1.9.1.min.js +4 -0
  58. data/lib/public/javascripts/noty/jquery.noty.js +547 -0
  59. data/lib/public/javascripts/noty/layouts/top.js +34 -0
  60. data/lib/public/javascripts/noty/themes/default.js +156 -0
  61. data/lib/public/javascripts/noty_config.js +25 -0
  62. data/lib/public/stylesheets/app.css +50 -0
  63. data/lib/public/stylesheets/base.css +269 -0
  64. data/lib/public/stylesheets/icons.css +492 -0
  65. data/lib/public/stylesheets/layout.css +58 -0
  66. data/lib/public/stylesheets/skeleton.css +242 -0
  67. data/lib/public/templates/edit.html.erb +6 -0
  68. data/lib/public/templates/keys.html.erb +36 -0
  69. data/lib/public/templates/new.html.erb +6 -0
  70. data/lib/public/templates/show.html.erb +2 -0
  71. data/lib/public/templates/stats.html.erb +8 -0
  72. data/lib/routes.rb +4 -0
  73. data/lib/views/index.erb +13 -0
  74. data/lib/views/layout.erb +55 -0
  75. data/lib/webapp.rb +15 -0
  76. data/memcached-manager.gemspec +154 -0
  77. data/spec/javascripts/angular/controllers/list_keys_controller_spec.js +1 -0
  78. data/spec/javascripts/angular/services/notification_spec.js +2 -0
  79. data/spec/javascripts/angular/services/resource_spec.js +2 -0
  80. data/spec/javascripts/angular/services/response_spec.js +2 -0
  81. metadata +80 -6
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --backtrace
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ before_script:
2
+ - "export DISPLAY=:99.0"
3
+ - "sh -e /etc/init.d/xvfb start"
4
+
5
+ before_install:
6
+ - gem install bundler
7
+
8
+ script:
9
+ rake
10
+
11
+ rvm:
12
+ - 1.9.3
13
+ - 2.0.0
14
+
15
+ gemfile:
16
+ - Gemfile
17
+
18
+ services:
19
+ - memcache
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,28 @@
1
+ == Running development mode
2
+
3
+ bundle install
4
+ rackup
5
+
6
+ == Running the test suite
7
+
8
+ First, make sure you have phantomjs installed if you want to run cukes tagged as @javascript(those who are in the features/webapp directory.
9
+
10
+ Have `memcached` run on `localhost:11211` then run:
11
+
12
+ bundle exec rake
13
+
14
+ == Roadmap(stuff you can do)
15
+
16
+ * Develop frontend & artwork (in progress)
17
+ * Favicon
18
+ * Update API/frontend in order to use http statuses for errors, creation and so on.
19
+
20
+ == Making a pull request?
21
+
22
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
23
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
24
+ * Fork the project.
25
+ * Start a feature/bugfix branch.
26
+ * Commit and push until you are happy with your contribution.
27
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
28
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "sinatra"
4
+ gem "sinatra-contrib"
5
+ gem "dalli"
6
+ gem "vegas"
7
+ gem "thin"
8
+
9
+ group :development do
10
+ gem "jeweler", "~> 1.8.8"
11
+ end
12
+
13
+ group :test do
14
+ gem "poltergeist"
15
+ gem "rack-test", :require => "rack/test"
16
+ gem "rspec"
17
+ gem "mocha"
18
+ gem "cucumber"
19
+ gem "capybara", :require => false
20
+ gem "faraday"
21
+ end
22
+
23
+ group :development, :test do
24
+ gem 'jasmine', "= 1.3.2"
25
+ gem "cucumber"
26
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,143 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ backports (3.3.4)
6
+ builder (3.2.2)
7
+ capybara (2.1.0)
8
+ mime-types (>= 1.16)
9
+ nokogiri (>= 1.3.3)
10
+ rack (>= 1.0.0)
11
+ rack-test (>= 0.5.4)
12
+ xpath (~> 2.0)
13
+ childprocess (0.3.9)
14
+ ffi (~> 1.0, >= 1.0.11)
15
+ cliver (0.2.2)
16
+ cucumber (1.3.8)
17
+ builder (>= 2.1.2)
18
+ diff-lcs (>= 1.1.3)
19
+ gherkin (~> 2.12.1)
20
+ multi_json (>= 1.7.5, < 2.0)
21
+ multi_test (>= 0.0.2)
22
+ daemons (1.1.9)
23
+ dalli (2.6.4)
24
+ diff-lcs (1.2.4)
25
+ eventmachine (1.0.3)
26
+ faraday (0.8.8)
27
+ multipart-post (~> 1.2.0)
28
+ ffi (1.9.0)
29
+ gherkin (2.12.1)
30
+ multi_json (~> 1.3)
31
+ git (1.2.6)
32
+ github_api (0.10.1)
33
+ addressable
34
+ faraday (~> 0.8.1)
35
+ hashie (>= 1.2)
36
+ multi_json (~> 1.4)
37
+ nokogiri (~> 1.5.2)
38
+ oauth2
39
+ hashie (2.0.5)
40
+ highline (1.6.19)
41
+ httpauth (0.2.0)
42
+ jasmine (1.3.2)
43
+ jasmine-core (~> 1.3.1)
44
+ rack (~> 1.0)
45
+ rspec (>= 1.3.1)
46
+ selenium-webdriver (>= 0.1.3)
47
+ jasmine-core (1.3.1)
48
+ jeweler (1.8.8)
49
+ builder
50
+ bundler (~> 1.0)
51
+ git (>= 1.2.5)
52
+ github_api (= 0.10.1)
53
+ highline (>= 1.6.15)
54
+ nokogiri (= 1.5.10)
55
+ rake
56
+ rdoc
57
+ json (1.8.0)
58
+ jwt (0.1.8)
59
+ multi_json (>= 1.5)
60
+ metaclass (0.0.1)
61
+ mime-types (1.25)
62
+ mocha (0.14.0)
63
+ metaclass (~> 0.0.1)
64
+ multi_json (1.8.0)
65
+ multi_test (0.0.2)
66
+ multi_xml (0.5.5)
67
+ multipart-post (1.2.0)
68
+ nokogiri (1.5.10)
69
+ oauth2 (0.9.2)
70
+ faraday (~> 0.8)
71
+ httpauth (~> 0.2)
72
+ jwt (~> 0.1.4)
73
+ multi_json (~> 1.0)
74
+ multi_xml (~> 0.5)
75
+ rack (~> 1.2)
76
+ poltergeist (1.4.1)
77
+ capybara (~> 2.1.0)
78
+ cliver (~> 0.2.1)
79
+ multi_json (~> 1.0)
80
+ websocket-driver (>= 0.2.0)
81
+ rack (1.5.2)
82
+ rack-protection (1.5.0)
83
+ rack
84
+ rack-test (0.6.2)
85
+ rack (>= 1.0)
86
+ rake (10.1.0)
87
+ rdoc (4.0.1)
88
+ json (~> 1.4)
89
+ rspec (2.14.1)
90
+ rspec-core (~> 2.14.0)
91
+ rspec-expectations (~> 2.14.0)
92
+ rspec-mocks (~> 2.14.0)
93
+ rspec-core (2.14.5)
94
+ rspec-expectations (2.14.2)
95
+ diff-lcs (>= 1.1.3, < 2.0)
96
+ rspec-mocks (2.14.3)
97
+ rubyzip (0.9.9)
98
+ selenium-webdriver (2.35.1)
99
+ childprocess (>= 0.2.5)
100
+ multi_json (~> 1.0)
101
+ rubyzip (< 1.0.0)
102
+ websocket (~> 1.0.4)
103
+ sinatra (1.4.3)
104
+ rack (~> 1.4)
105
+ rack-protection (~> 1.4)
106
+ tilt (~> 1.3, >= 1.3.4)
107
+ sinatra-contrib (1.4.1)
108
+ backports (>= 2.0)
109
+ multi_json
110
+ rack-protection
111
+ rack-test
112
+ sinatra (~> 1.4.0)
113
+ tilt (~> 1.3)
114
+ thin (1.5.1)
115
+ daemons (>= 1.0.9)
116
+ eventmachine (>= 0.12.6)
117
+ rack (>= 1.0.0)
118
+ tilt (1.4.1)
119
+ vegas (0.1.11)
120
+ rack (>= 1.0.0)
121
+ websocket (1.0.7)
122
+ websocket-driver (0.3.0)
123
+ xpath (2.0.0)
124
+ nokogiri (~> 1.3)
125
+
126
+ PLATFORMS
127
+ ruby
128
+
129
+ DEPENDENCIES
130
+ capybara
131
+ cucumber
132
+ dalli
133
+ faraday
134
+ jasmine (= 1.3.2)
135
+ jeweler (~> 1.8.8)
136
+ mocha
137
+ poltergeist
138
+ rack-test
139
+ rspec
140
+ sinatra
141
+ sinatra-contrib
142
+ thin
143
+ vegas
data/README.rdoc CHANGED
@@ -24,7 +24,21 @@ or
24
24
 
25
25
  == Plugging memcached manager to an existing Rails app
26
26
 
27
- Todo.
27
+ Just mount it in **config/routes.rb**:
28
+
29
+ ```ruby
30
+ mount MemcachedManager::Routes, :at => '/mm'
31
+
32
+ ```
33
+ So it will be accessible in the /mm route of your application.
34
+
35
+
36
+ If you want to specify a different config than the defaults(localhost:11211) add an `.env` file with the following:
37
+
38
+ ```
39
+ memcached_host: foo.bar
40
+ memcached_port: 1337
41
+ ```
28
42
 
29
43
  == Requirements
30
44
 
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "memcached-manager"
18
+ gem.homepage = "http://github.com/thiagofm/memcached-manager"
19
+ gem.license = "MIT"
20
+ gem.summary = "A sinatra memcached-manager that allows you to view status, flush/view keys and so on. Also easily pluggable to a Rails app."
21
+ gem.description = "A sinatra memcached-manager that allows you to view status, flush/view keys and so on. Also easily pluggable to a Rails app."
22
+ gem.email = "thiagown@gmail.com"
23
+ gem.authors = ["Thiago Fernandes Massa"]
24
+ gem.test_files = Dir.glob('spec/**/*')
25
+ gem.executables = %w(memcached-manager)
26
+
27
+ # dependencies defined in Gemfile
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ # Tests
32
+ begin
33
+ require 'jasmine'
34
+ load 'jasmine/tasks/jasmine.rake'
35
+ rescue LoadError
36
+ task :jasmine do
37
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
38
+ end
39
+ end
40
+
41
+ require 'cucumber'
42
+ require 'cucumber/rake/task'
43
+
44
+ Cucumber::Rake::Task.new(:features) do |t|
45
+ t.cucumber_opts = "features --format pretty"
46
+ end
47
+
48
+ require 'rspec/core/rake_task'
49
+
50
+ desc "Run specs"
51
+ RSpec::Core::RakeTask.new do |t|
52
+ t.pattern = "./spec/**/*_spec.rb"
53
+ end
54
+
55
+ task :jasmineci do
56
+ system("export DISPLAY=:99.0 && bundle exec rake jasmine:ci")
57
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
58
+ end
59
+
60
+ task :default => [:jasmineci, :features, :spec]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
data/config.ru CHANGED
@@ -1,10 +1,6 @@
1
1
  # Sinatra modules
2
2
  require './lib/webapp'
3
3
  require './lib/api'
4
+ require './lib/routes'
4
5
 
5
- MemcachedManager::App = Rack::URLMap.new({
6
- "/api" => MemcachedManager::API.new,
7
- "/" => MemcachedManager::Webapp.new
8
- })
9
-
10
- run MemcachedManager
6
+ run MemcachedManager::Routes
@@ -0,0 +1,6 @@
1
+ @api
2
+ Feature: Create memcached pair
3
+ Scenario: Success
4
+ When I post some data to "/keys.json" in the API
5
+ Then I should receive a json response that it was saved successfully
6
+ And it should be saved in memcached
@@ -0,0 +1,6 @@
1
+ @api
2
+ Feature: Delete memcached key
3
+ Scenario: Success
4
+ Given there's the "username" memcached key avaiable
5
+ When I visit "/keys/username.json" in the API with the delete method
6
+ Then this key shouldn't exist.
@@ -0,0 +1,6 @@
1
+ @api
2
+ Feature: List memcached keys
3
+ Scenario: Success
4
+ Given there's some memcached keys avaiable
5
+ When I visit "/keys.json" in the API
6
+ Then I should receive a json response with those keys
@@ -0,0 +1,5 @@
1
+ @api
2
+ Feature: Set memcached info
3
+ Scenario: Success
4
+ When I post configs to "/config.json" in the API
5
+ Then the memcached config should be set
@@ -0,0 +1,10 @@
1
+ @api
2
+ Feature: Show memcached keys
3
+ Scenario: Success
4
+ Given there's the "username" memcached key avaiable
5
+ When I visit "/keys/username.json" in the API
6
+ Then I should receive a json response with this key
7
+
8
+ Scenario: Key doesn't exist
9
+ When I visit "/keys/username.json" in the API
10
+ Then I should receive a json telling me that the key doesn't exist
@@ -0,0 +1,5 @@
1
+ @api
2
+ Feature: Show memcached stats
3
+ Scenario: Success
4
+ When I visit "/stats.json" in the API
5
+ Then I should receive a json response with the memcached's current stats
@@ -0,0 +1,7 @@
1
+ @api
2
+ Feature: Update memcached pair
3
+ Scenario: Success
4
+ Given there's the "username" memcached key avaiable
5
+ When I put some data to "/keys.json" in the API
6
+ Then I should receive a json response that it was edited successfully
7
+ And it should be updated in memcached
@@ -0,0 +1,21 @@
1
+ When /^I post some data to "(.*?)" in the API$/ do |route|
2
+ @data = { key: 'all.i.want.to.do', value: 'is.bang.bang.bang' }
3
+ @response = API.post do |req|
4
+ req.url "api/#{route}"
5
+ req.params = @data
6
+ end
7
+ end
8
+
9
+ Then /^I should receive a json response that it was saved successfully$/ do
10
+ @response.status.should be 200
11
+ response_json = JSON.parse(@response.body)
12
+ response_json.class.should eql Hash
13
+ response_json.keys.should_not include 'errors'
14
+ response_json.values.should include 'all.i.want.to.do'
15
+ response_json.keys.should include 'expired'
16
+ end
17
+
18
+ Then /^it should be saved in memcached$/ do
19
+ key = Memcached.get(@data[:key])
20
+ key.should == @data[:value]
21
+ end
@@ -0,0 +1,7 @@
1
+ When /^I visit "(.*?)" in the API with the delete method$/ do |route|
2
+ API.delete("api/#{route}")
3
+ end
4
+
5
+ Then /^this key shouldn't exist\.$/ do
6
+ Memcached.get('username').should eql nil
7
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ Given /^there's some memcached keys avaiable$/ do
4
+ Memcached.set('foo', 'bar')
5
+ Memcached.set('ineed', 'togetalife')
6
+ end
7
+
8
+ When /^I visit "(.*?)" in the API$/ do |route|
9
+ @response = JSON.parse(API.get("api/#{route}").body)
10
+ end
11
+
12
+ Then /^I should receive a json response with those keys$/ do
13
+ @response.should_not equal nil
14
+ @response.last.values.should include 'foo'
15
+ @response.first.values.should include 'ineed'
16
+ end
@@ -0,0 +1,18 @@
1
+ # Scenario: Success
2
+ Given /^there's the "(.*?)" memcached key avaiable$/ do |key|
3
+ @key = key
4
+ Memcached.set(@key, 'John Doe')
5
+ end
6
+
7
+ Then /^I should receive a json response with this key$/ do
8
+ @response.class.should eql Hash
9
+ @response["key"].should include 'name'
10
+ @response["value"].should include 'John Doe'
11
+ end
12
+
13
+ # Scenario: Key doesn't exist
14
+ Then /^I should receive a json telling me that the key doesn't exist$/ do
15
+ @response.class.should eql Hash
16
+ @response.keys.should include 'errors'
17
+ @response["errors"].should include 'Key not found.'
18
+ end
@@ -0,0 +1,3 @@
1
+ Then /^I should receive a json response with the memcached's current stats$/ do
2
+ @response.keys.should include("#{MemcachedConfigs[:host]}:#{MemcachedConfigs[:port]}")
3
+ end
@@ -0,0 +1,18 @@
1
+ When /^I put some data to "(.*?)" in the API$/ do |route|
2
+ @data = { key: 'username', value: 'thiagofm' }
3
+ @response = API.put do |req|
4
+ req.url "api/#{route}"
5
+ req.params = @data
6
+ end
7
+ end
8
+
9
+ Then /^I should receive a json response that it was edited successfully$/ do
10
+ @response.status.should be 200
11
+ response_json = JSON.parse(@response.body)
12
+ response_json.class.should eql Hash
13
+ response_json.keys.should include 'key'
14
+ end
15
+
16
+ Then /^it should be updated in memcached$/ do
17
+ Memcached.get(@key).should eql 'thiagofm'
18
+ end
@@ -0,0 +1,25 @@
1
+ When /^I post configs to "(.*?)" in the API$/ do |route|
2
+ @data = { 'host' => 'i.am', 'port' => '1337' }
3
+ @route = route
4
+
5
+ API.post do |req|
6
+ req.url "api/#{@route}"
7
+ req.params = @data
8
+ end
9
+ end
10
+
11
+ Then /^the memcached config should be set$/ do
12
+ response = API.get("api/#{@route}")
13
+ response_json = JSON.parse(response.body)
14
+
15
+ response.status.should be 200
16
+ response_json['host'].should eql @data['host']
17
+ response_json['port'].should eql @data['port']
18
+
19
+ # Workaround so the next feature don't use the current memcached configs
20
+ @data = { 'host' => MemcachedConfigs[:host], 'port' => MemcachedConfigs[:port] }
21
+ API.post do |req|
22
+ req.url "api/#{@route}"
23
+ req.params = @data
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ When /^click on the X inside a div$/ do
2
+ within(".key-actions") do
3
+ find('.icon-remove').click
4
+ end
5
+ sleep 5
6
+ end
7
+
8
+ Then /^"(.*?)" key shouldn't exist in memcached$/ do |key|
9
+ Memcached.get(key).should be nil
10
+ end
@@ -0,0 +1,16 @@
1
+ When /^I visit "(.*?)"$/ do |route|
2
+ visit route
3
+ end
4
+
5
+ When /^fill in "(.*?)" with "(.*?)"$/ do |field, value|
6
+ fill_in(field, :with => value)
7
+ end
8
+
9
+ When /^click "(.*?)"$/ do |button|
10
+ click_button button
11
+ end
12
+
13
+ Then /^"(.*?)" key should have the "(.*?)" value in memcached$/ do |key, value|
14
+ sleep 1
15
+ Memcached.get(key).should == value
16
+ end
@@ -0,0 +1,3 @@
1
+ Given /^a key named "(.*?)" with the content "(.*?)" exists$/ do |key, value|
2
+ Memcached.set(key, value)
3
+ end
@@ -0,0 +1,4 @@
1
+ Then /^I should see "(.*?)" and "(.*?)" keys in the listing$/ do |key1, key2|
2
+ page.should have_content(key1)
3
+ page.should have_content(key2)
4
+ end
@@ -0,0 +1,4 @@
1
+ Then /^I should be able to see the "(.*?)" key with the "(.*?)" value$/ do |key, value|
2
+ page.should have_content(key)
3
+ page.should have_content(value)
4
+ end
@@ -0,0 +1,5 @@
1
+ Then /^I should see memcached stats$/ do
2
+ page.should have_content('Stats')
3
+ page.should have_content("#{MemcachedConfigs[:host]}")
4
+ page.should have_content("#{MemcachedConfigs[:port]}")
5
+ end
@@ -0,0 +1,28 @@
1
+ require 'cucumber'
2
+ require 'capybara/cucumber'
3
+ require 'faraday'
4
+ require 'dalli'
5
+ require 'rspec'
6
+ require 'rspec/expectations'
7
+ require 'capybara/poltergeist'
8
+ require 'sinatra'
9
+
10
+ Capybara.javascript_driver = :poltergeist
11
+
12
+ World(RSpec::Matchers)
13
+
14
+ # Files
15
+ Dir.glob("lib/**/*.rb").each do |file|
16
+ require_relative "../../#{file}"
17
+ end
18
+
19
+ Capybara.app = Rack::Builder.parse_file(File.expand_path('../../../config.ru', __FILE__)).first
20
+
21
+ API = Faraday.new do |conn| conn.adapter :rack, Rack::URLMap.new({
22
+ "/api" => MemcachedManager::API.new,
23
+ "/" => MemcachedManager::Webapp.new
24
+ })
25
+ end
26
+
27
+ MemcachedConfigs = { host: 'localhost', port: '11211' }
28
+ Memcached = Dalli::Client.new("#{MemcachedConfigs[:host]}:#{MemcachedConfigs[:port]}")
@@ -0,0 +1,3 @@
1
+ After do
2
+ Memcached.flush
3
+ end
@@ -0,0 +1,9 @@
1
+ @webapp
2
+ @javascript
3
+ Feature: Create memcached pair
4
+ Scenario: Success
5
+ When I visit "#/new"
6
+ And fill in "Key" with "foo"
7
+ And fill in "Value" with "bar"
8
+ And click "Create"
9
+ Then "foo" key should have the "bar" value in memcached
@@ -0,0 +1,8 @@
1
+ @webapp
2
+ @javascript
3
+ Feature: Delete memcached pair
4
+ Scenario: Success
5
+ Given a key named "foo" with the content "bar" exists
6
+ When I visit "#/"
7
+ And click on the X inside a div
8
+ Then "foo" key shouldn't exist in memcached
@@ -0,0 +1,9 @@
1
+ @webapp
2
+ @javascript
3
+ Feature: Edit memcached pair
4
+ Scenario: Success
5
+ Given a key named "foo" with the content "bar" exists
6
+ When I visit "#/edit/foo"
7
+ And fill in "Value" with "baz"
8
+ And click "Edit"
9
+ Then "foo" key should have the "baz" value in memcached
@@ -0,0 +1,8 @@
1
+ @webapp
2
+ @javascript
3
+ Feature: List memcached pair
4
+ Scenario: Success
5
+ Given a key named "foo" with the content "bar" exists
6
+ And a key named "fu" with the content "bar" exists
7
+ When I visit "#/"
8
+ Then I should see "foo" and "fu" keys in the listing
@@ -0,0 +1,7 @@
1
+ @webapp
2
+ @javascript
3
+ Feature: Show memcached key
4
+ Scenario: Success
5
+ Given a key named "foo" with the content "bar" exists
6
+ When I visit "#/key/foo"
7
+ Then I should be able to see the "foo" key with the "bar" value
@@ -0,0 +1,6 @@
1
+ @webapp
2
+ @javascript
3
+ Feature: Show memcached stats
4
+ Scenario: Success
5
+ When I visit "#/"
6
+ Then I should see memcached stats