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.
- data/.rspec +2 -0
- data/.travis.yml +19 -0
- data/CONTRIBUTING.md +28 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +143 -0
- data/README.rdoc +15 -1
- data/Rakefile +60 -0
- data/VERSION +1 -0
- data/config.ru +2 -6
- data/features/api/create_memcached_key.feature +6 -0
- data/features/api/delete_memcached_key.feature +6 -0
- data/features/api/list_memcached_keys.feature +6 -0
- data/features/api/set_memcached_info.feature +5 -0
- data/features/api/show_memcached_key.feature +10 -0
- data/features/api/show_memcached_stats.feature +5 -0
- data/features/api/update_memcached_key.feature +7 -0
- data/features/step_definitions/api/create_memcached_key.rb +21 -0
- data/features/step_definitions/api/delete_memcached_key.rb +7 -0
- data/features/step_definitions/api/list_memcached_keys.rb +16 -0
- data/features/step_definitions/api/show_memcached_key.rb +18 -0
- data/features/step_definitions/api/show_memcached_stats.rb +3 -0
- data/features/step_definitions/api/update_memcached_key.rb +18 -0
- data/features/step_definitions/set_memcached_info.rb +25 -0
- data/features/step_definitions/webapp/create_memcached_key.rb +10 -0
- data/features/step_definitions/webapp/delete_memcached_key.rb +16 -0
- data/features/step_definitions/webapp/edit_memcached_key.rb +3 -0
- data/features/step_definitions/webapp/list_memcached_keys.rb +4 -0
- data/features/step_definitions/webapp/show_memcached_key.rb +4 -0
- data/features/step_definitions/webapp/show_memcached_stats.rb +5 -0
- data/features/support/env.rb +28 -0
- data/features/support/hooks.rb +3 -0
- data/features/webapp/create_memcached_key.feature +9 -0
- data/features/webapp/delete_memcached_key.feature +8 -0
- data/features/webapp/edit_memcached_key.feature +9 -0
- data/features/webapp/list_memcached_keys.feature +8 -0
- data/features/webapp/show_memcached_key.feature +7 -0
- data/features/webapp/show_memcached_stats.feature +6 -0
- data/lib/api.rb +85 -0
- data/lib/extensions/api_response.rb +15 -0
- data/lib/extensions/errors.rb +19 -0
- data/lib/extensions/memcached_connection.rb +15 -0
- data/lib/extensions/memcached_inspector.rb +49 -0
- data/lib/extensions/memcached_settings.rb +18 -0
- data/lib/extensions.rb +14 -0
- data/lib/memcached-manager.rb +4 -0
- data/lib/public/images/glyphicons-halflings-white.png +0 -0
- data/lib/public/images/glyphicons-halflings.png +0 -0
- data/lib/public/javascripts/angular/controllers.js +89 -0
- data/lib/public/javascripts/angular/routes.js +66 -0
- data/lib/public/javascripts/angular/services/notification.js +16 -0
- data/lib/public/javascripts/angular/services/resources.js +20 -0
- data/lib/public/javascripts/angular/services/response.js +10 -0
- data/lib/public/javascripts/angular-resource.min.js +10 -0
- data/lib/public/javascripts/angular-ui-states.min.js +7 -0
- data/lib/public/javascripts/angular.min.js +161 -0
- data/lib/public/javascripts/application.js +18 -0
- data/lib/public/javascripts/jquery-1.9.1.min.js +4 -0
- data/lib/public/javascripts/noty/jquery.noty.js +547 -0
- data/lib/public/javascripts/noty/layouts/top.js +34 -0
- data/lib/public/javascripts/noty/themes/default.js +156 -0
- data/lib/public/javascripts/noty_config.js +25 -0
- data/lib/public/stylesheets/app.css +50 -0
- data/lib/public/stylesheets/base.css +269 -0
- data/lib/public/stylesheets/icons.css +492 -0
- data/lib/public/stylesheets/layout.css +58 -0
- data/lib/public/stylesheets/skeleton.css +242 -0
- data/lib/public/templates/edit.html.erb +6 -0
- data/lib/public/templates/keys.html.erb +36 -0
- data/lib/public/templates/new.html.erb +6 -0
- data/lib/public/templates/show.html.erb +2 -0
- data/lib/public/templates/stats.html.erb +8 -0
- data/lib/routes.rb +4 -0
- data/lib/views/index.erb +13 -0
- data/lib/views/layout.erb +55 -0
- data/lib/webapp.rb +15 -0
- data/memcached-manager.gemspec +154 -0
- data/spec/javascripts/angular/controllers/list_keys_controller_spec.js +1 -0
- data/spec/javascripts/angular/services/notification_spec.js +2 -0
- data/spec/javascripts/angular/services/resource_spec.js +2 -0
- data/spec/javascripts/angular/services/response_spec.js +2 -0
- metadata +80 -6
data/.rspec
ADDED
data/.travis.yml
ADDED
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
|
-
|
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::
|
6
|
-
"/api" => MemcachedManager::API.new,
|
7
|
-
"/" => MemcachedManager::Webapp.new
|
8
|
-
})
|
9
|
-
|
10
|
-
run MemcachedManager
|
6
|
+
run MemcachedManager::Routes
|
@@ -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,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,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,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,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,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,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
|