sinatra-sessionography 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE.markdown +113 -0
- data/README.markdown +78 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/sinatra/sessionography.rb +45 -0
- data/sinatra-sessionography.gemspec +61 -0
- data/spec/sessionography_spec.rb +36 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +32 -0
- metadata +112 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE.markdown
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
The Don't Be a Dick License
|
2
|
+
===========================
|
3
|
+
_version 0.2_
|
4
|
+
|
5
|
+
**Project:** [Sinatra::Sessionography](http://github.com/SFEley/sinatra-sessionography)
|
6
|
+
**Author:** Stephen Eley (<sfeley@gmail.com>)
|
7
|
+
|
8
|
+
This is a proposed draft of the **Don't Be a Dick** license for open source projects. The purpose of this license is to permit the broadest feasible scope for reuse and modification of creative work, restricted only by the requirement that one is not a dick about it.
|
9
|
+
|
10
|
+
1. Legal Parameters
|
11
|
+
-------------------
|
12
|
+
For legal purposes, the DBAD license is a superset of the [Apache License, Version 2.0][1] and incorporates all terms, conditions, privileges and limitations therein. The following text is a binding part of this license for this project:
|
13
|
+
|
14
|
+
> Copyright 2010 Stephen Eley
|
15
|
+
|
16
|
+
> Licensed under the Apache License, Version 2.0 (the "License");
|
17
|
+
you may not use this file except in compliance with the License.
|
18
|
+
You may obtain a copy of the License at
|
19
|
+
|
20
|
+
> <http://www.apache.org/licenses/LICENSE-2.0>
|
21
|
+
|
22
|
+
> Unless required by applicable law or agreed to in writing, software
|
23
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
24
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
25
|
+
See the License for the specific language governing permissions and
|
26
|
+
limitations under the License.
|
27
|
+
|
28
|
+
Nothing in the following text should be construed to inhibit, contradict, or override any part of the Apache License, Version 2.0.
|
29
|
+
|
30
|
+
2. Definitions
|
31
|
+
--------------
|
32
|
+
The following terms and definitions shall be in effect for the rest of this document.
|
33
|
+
|
34
|
+
> **NOTE:** Singular nouns and pronouns are used throughout this License for
|
35
|
+
grammatical convenience. However, any of the terms below _may_ refer to a
|
36
|
+
collective work or group of people. If this pegs your punctiliousness, you
|
37
|
+
are directed to mentally substitute "Person _or persons_," "Dick _or
|
38
|
+
dicks,_" etc., throughout this license. Just don't tell us about it.
|
39
|
+
|
40
|
+
### A. Project
|
41
|
+
|
42
|
+
A creative work of (software | writing | visual art | music) into which significant time and energy have been invested by people who _are not you,_ and which has been released into the world for the benefit of the general public (_including you._)
|
43
|
+
|
44
|
+
The **Project** may include, incorporate, derive from, or be inspired by other works. The Author, being a Reasonable Person, has made use of such source materials only as permitted by their own licenses or applicable law. The License you are reading applies only to those portions of the Project which are original and distinct to it. Source materials may be covered by their own licenses or conditions, and should not be assumed to have coverage under this License. (However, you are strongly encouraged not to be a dick about them either.)
|
45
|
+
|
46
|
+
### B. Author
|
47
|
+
|
48
|
+
A person who has invested significant time and energy into the Project licensed herein. Given the Author's release of the Project to the world under a liberal license, the Author is declared a Reasonable Person (at least within this context) and inherits all attributes, freedoms, and responsibilities thereof. No other assumptions are made about the Author, nor should you make any.
|
49
|
+
|
50
|
+
### C. Reasonable Person
|
51
|
+
|
52
|
+
A person who respects the time and energy that have been invested in the Project licensed herein, and acts accordingly. A Reasonable Person is broadly characterized as one who exercises his or her privilege to use, _not_ use, redistribute, modify, improve, worsen, review, report issues upon, participate in the community of, or ignore the work _without_ placing undue demands upon the Author. I.e., a Reasonable Person is a constituent of the majority of open source users and the population at large who are not Dicks.
|
53
|
+
|
54
|
+
### D. Dick
|
55
|
+
|
56
|
+
A person who _does not_ respect the time and energy that have been invested in the Project, and acts to punish such effort by giving others associated with the Project -- including, but not limited to, the Author -- a hard time. A Dick is nearly always selfish, but not necessarily with deliberate intent; some Dicks are merely thoughtless. The distinguishing characteristic of a Dick is that he or she places burdens upon Reasonable People, reducing their motivation to engage in open source activities. This damping effect is a significant detriment to the Project, to open source in general, to the production of new intellectual value in the world -- and, ultimately, to the Dick himself or herself.
|
57
|
+
|
58
|
+
> **NOTE:** Despite its original gender association, the word "Dick" is used herein in a _cultural_ context and not a _genital_ context. This License has chosen to adopt the term for its linguistic force and psychological impact, and sincerely regrets any inference of sexism. For purposes of the terms and conditions contained herein, it is understood that both men and women are equally capable of being Dicks.
|
59
|
+
|
60
|
+
> (But they shouldn't be.)
|
61
|
+
|
62
|
+
3. Permissions
|
63
|
+
--------------
|
64
|
+
|
65
|
+
The following privileges are granted explicitly and exclusively to Reasonable People. Although the Author acknowledges the practical unfeasibility of barring Dicks from enjoying the same privileges, they are nevertheless asked to refrain from any activity related to the Project _and/or_ to reconsider their behavior and stop being Dicks.
|
66
|
+
|
67
|
+
1. You are permitted to use the Project or any component of the Project.
|
68
|
+
|
69
|
+
2. You are permitted to redistribute the Project or any component of the Project, by itself or as part of a different work, provided that you give fair and reasonable credit back to the Author.
|
70
|
+
|
71
|
+
3. You are permitted to change the Project for your own needs or anyone else's. You may keep your changes to yourself or submit them back to the Author or the community, as you see fit, provided you are not a Dick about it.
|
72
|
+
|
73
|
+
4. You are permitted and encouraged to participate in any community related to the Project, or to create new communities.
|
74
|
+
|
75
|
+
5. You are permitted to report issues or problems with the Project, and to request that they be addressed, so long as the request is made in a reasonable fashion. (This privilege does _not_ oblige the Author to respond.)
|
76
|
+
|
77
|
+
6. You are permitted to make money from the Project. No recompense is owed to the Author unless by separate agreement, although sharing opportunities for mutual benefit is by no means discouraged.
|
78
|
+
|
79
|
+
7. You are permitted to discuss the Project in any medium, in any positive or negative spirit, so long as criticism is not libelous nor _ad hominem._ (I.e., don't lie, and keep it about the _work_ and not the _people._)
|
80
|
+
|
81
|
+
8. You are permitted to ignore the Project completely and make no use of it whatsoever. This right is irrevocable and absolute, and extended to Dicks and Reasonable People alike.
|
82
|
+
|
83
|
+
4. Limitations
|
84
|
+
--------------
|
85
|
+
|
86
|
+
The following restrictions are imposed explicitly and exclusively upon Dicks. These limitations are the inverse of the above privileges and are also tautological, as the prohibited actions are those _definitive_ of Dickhood.
|
87
|
+
|
88
|
+
1. You may not impede Reasonable People from exercising their privilege to use, redistribute, change, participate in, profit from, discuss, or ignore the Project.
|
89
|
+
|
90
|
+
2. You may not withhold the Author's credit for the Project, nor otherwise present the work of anyone else as your own.
|
91
|
+
|
92
|
+
3. You may not hold the Author responsible for any use or abuse of the Project by you or anyone else.
|
93
|
+
|
94
|
+
4. You may not troll, flame, nor dumb down any community associated with the Project.
|
95
|
+
|
96
|
+
5. Barring separate agreements, you may not _demand_ any time or attention on the part of the Author nor anyone else in the community. You may not hold the Author personally accountable for any issues you discover nor otherwise spread your own problems to other people.
|
97
|
+
|
98
|
+
6. You may not attempt to _compel_ time nor money from the Author nor any other community member by any means, including but not limited to legal action, intimidation, or annoyance.
|
99
|
+
|
100
|
+
7. You may not engage in _ad hominem_ (i.e. personal) attacks or criticism of the Author in the course of criticizing the Project.
|
101
|
+
|
102
|
+
8. You may not impede the absolute and irrevocable privilege of the Author and other members of the community to ignore you.
|
103
|
+
|
104
|
+
5. Use of This License
|
105
|
+
----------------------
|
106
|
+
The Don't Be a Dick License is released under the terms of the Don't Be a Dick License. Projects released under this License should remain under the License, and the terms of the License may not be modified by anyone other than the Project's original Author.
|
107
|
+
|
108
|
+
If you wish to make use of the License for your own open work, you may do so without asking permission, provided said work is truly your own, truly open, and you are truly not a Dick. You may modify the terms of the License to suit your own needs, but are strongly advised to annotate said changes. Modifications may not reduce the freedoms granted to Reasonable People as described in Section 3.
|
109
|
+
|
110
|
+
Reasonable People are _invited,_ but not compelled, to visit the Web site at <http://dbad-license.org> and browse or add their project to the repository of works released under the License.
|
111
|
+
|
112
|
+
|
113
|
+
[1]: http://apache.org/licenses/LICENSE-2.0
|
data/README.markdown
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
Sessionography
|
2
|
+
==============
|
3
|
+
|
4
|
+
This is a simple testing helper for Sinatra sessions. It was written because
|
5
|
+
having to use [this sort of approach][1] to test sessions made me sad.
|
6
|
+
Sessionography replaces Sinatra's `session` helper with a reference to a
|
7
|
+
simple hash in a module variable, enabling session calls that maintain state
|
8
|
+
across requests without the complexity and limitations of trying to use
|
9
|
+
`Rack::Session` with [Rack::Test][2].
|
10
|
+
|
11
|
+
It will not help you sing better. It does not make omelettes. And if you're
|
12
|
+
testing something that actually _cares_ about how sessions get set (e.g., if
|
13
|
+
you're working on Sinatra itself or a low-level Rack component) you won't want
|
14
|
+
to use this. But most of us just want to get on with testing our apps.
|
15
|
+
|
16
|
+
Setting up
|
17
|
+
----------
|
18
|
+
$ gem install sinatra-sessiongraphy
|
19
|
+
|
20
|
+
(Or `sudo gem install` if you're the last person on Earth who isn't using [RVM][3] yet.)
|
21
|
+
|
22
|
+
Then, in your **test\_helper.rb** file or your **spec\_helper.rb** file, just `require sinatra/sessionography`. If you're using the **Sinatra::Base** style you'll also need to explicitly include the helper:
|
23
|
+
|
24
|
+
# spec_helper.rb
|
25
|
+
require 'myapp'
|
26
|
+
require 'sinatra/sessionography'
|
27
|
+
|
28
|
+
MyApp.helpers Sinatra::Sessionography
|
29
|
+
|
30
|
+
|
31
|
+
Testing Tips
|
32
|
+
------------
|
33
|
+
Your app code can continue to call `session[:whatever]` as it already does. It'll simply bypass any `Rack::Session` middleware and set a hash in memory.
|
34
|
+
|
35
|
+
If you'd like to access that hash in your test cases, there are module methods available:
|
36
|
+
|
37
|
+
# This example is in RSpec, because that is how I roll.
|
38
|
+
describe HypotheticalApp do
|
39
|
+
before(:each) do
|
40
|
+
# You should initialize the session every time, with a .clear or
|
41
|
+
# an assignment. Here, we simulate pre-existing state.
|
42
|
+
Sinatra::Sessionography.session = {:foo => 'bar', :too => 'tar'}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should do something to the session" do
|
46
|
+
post "/something", {:hey => :ho}
|
47
|
+
Sinatra::Sessionography.session['hey'].should == 'ho'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should pay attention to the session" do
|
51
|
+
Sinatra::Sessionography.session[:user] = User.find_by_name('Tina Fey')
|
52
|
+
get "/something"
|
53
|
+
last_response.body.should =~ /Tina Fey/
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
The session will of course persist across Sinatra requests. That's the point of a session. However, it will _also_ persist between test cases, which is probably not what you want, so in your setup or teardown code you should always call `Sinatra::Sessionography.session.clear` or else set it to _nil_ or some other useful value.
|
59
|
+
|
60
|
+
Future Enhancements
|
61
|
+
-------------------
|
62
|
+
I knocked this off quickly because I needed it (for [Sinatra::Flash][4]) but it'd be fairly easy to give it a few other features useful for testing:
|
63
|
+
|
64
|
+
* Multiple sessions scoped by name, for simulating interactions between different users;
|
65
|
+
* Logging or remembering of changes to session state, so that test cases can trace more complex interactions with the session over time;
|
66
|
+
* Generalization to a Rack::Session::Test (or perhaps Rack::MockSession) component for testing Rack applications outside of just Sinatra.
|
67
|
+
|
68
|
+
I don't need any of those _today,_ so I'm not going to build them right away. But if you'd like to see them, feel free to leave an issue here and let me know. (Or just build it and contribute back, of course. The source, it is open like the sky.)
|
69
|
+
|
70
|
+
|
71
|
+
License
|
72
|
+
-------
|
73
|
+
This project is licensed under the [Don't Be a Dick License][5], version 0.2, and is copyright 2010 by Stephen Eley. See the [LICENSE.markdown][5] file for elaboration on not being a dick.
|
74
|
+
|
75
|
+
[1]:http://groups.google.com/group/sinatrarb/msg/338ece48db7963cf
|
76
|
+
[2]:http://github.com/brynary/rack-test
|
77
|
+
[3]:http://rvm.beginrescueend.com
|
78
|
+
[4]:http://github.com/SFEley/sinatra-flash
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "sinatra-sessionography"
|
8
|
+
gem.summary = %Q{A simple sessions stub for testing Sinatra}
|
9
|
+
gem.description = %Q{Sessionography has only one function: to replace Sinatra's session methods with a basic hash that persists across requests. Bypassing Rack::Session removes nearly all the complexity of unit and integration testing with session data.}
|
10
|
+
gem.email = "sfeley@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/SFEley/sinatra-sessionography"
|
12
|
+
gem.authors = ["Stephen Eley"]
|
13
|
+
gem.add_dependency "sinatra", ">= 1.0"
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
+
gem.add_development_dependency "yard", ">= 0"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
begin
|
40
|
+
require 'yard'
|
41
|
+
YARD::Rake::YardocTask.new
|
42
|
+
rescue LoadError
|
43
|
+
task :yardoc do
|
44
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
45
|
+
end
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
# Eases testing by overriding Sinatra's #session helper to access a module hash. Also
|
5
|
+
# provides a direct module method to that hash for test verification.
|
6
|
+
#
|
7
|
+
# If your application is using the {Sinatra::Base} style (as you probably should most of the time
|
8
|
+
# you'll also need to include this module as a helper when setting up your test suite:
|
9
|
+
#
|
10
|
+
# @example (Assuming your app is declared with `class MyApp < Sinatra::Base`)
|
11
|
+
# require 'myapp'
|
12
|
+
# require 'sinatra/sessionography'
|
13
|
+
# MyApp.helpers Sinatra::Sessionography
|
14
|
+
module Sessionography
|
15
|
+
|
16
|
+
# Use this in your test cases to get or set session variables outside of your application code.
|
17
|
+
#
|
18
|
+
# @return [Hash] A session hash.
|
19
|
+
def self.session
|
20
|
+
@session ||= {}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Set up the session with a copy of your own hash for testing. (Optional; it'll default to an
|
24
|
+
# empty hash or to the contents of 'rack.session' if you don't do this.)
|
25
|
+
#
|
26
|
+
# @param [Hash] val The hash to use as the session. Note that we clone the object; we don't maintain
|
27
|
+
# a live link to the same hash.
|
28
|
+
def self.session=(val)
|
29
|
+
@session = val.clone
|
30
|
+
end
|
31
|
+
|
32
|
+
# Replaces Sinatra's #session helper to completely bypass Rack::Session, thus mocking out
|
33
|
+
# sessions in tests.
|
34
|
+
#
|
35
|
+
# Let's be clear: this session is _global._ Not per-user. *Using this in production code
|
36
|
+
# would be bad.* (Important safety tip, thanks Egon.)
|
37
|
+
#
|
38
|
+
# @return [Hash] The same session hash accessible from {Sinatra::Sessionography.session}
|
39
|
+
def session
|
40
|
+
Sessionography.session
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
helpers Sessionography
|
45
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sinatra-sessionography}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Stephen Eley"]
|
12
|
+
s.date = %q{2010-04-26}
|
13
|
+
s.description = %q{Sessionography has only one function: to replace Sinatra's session methods with a basic hash that persists across requests. Bypassing Rack::Session removes nearly all the complexity of unit and integration testing with session data.}
|
14
|
+
s.email = %q{sfeley@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.markdown",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE.markdown",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/sinatra/sessionography.rb",
|
27
|
+
"sinatra-sessionography.gemspec",
|
28
|
+
"spec/sessionography_spec.rb",
|
29
|
+
"spec/spec.opts",
|
30
|
+
"spec/spec_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/SFEley/sinatra-sessionography}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.6}
|
36
|
+
s.summary = %q{A simple sessions stub for testing Sinatra}
|
37
|
+
s.test_files = [
|
38
|
+
"spec/sessionography_spec.rb",
|
39
|
+
"spec/spec_helper.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 1.0"])
|
48
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
49
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<sinatra>, [">= 1.0"])
|
52
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<sinatra>, [">= 1.0"])
|
57
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
58
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Sinatra::Sessionography do
|
4
|
+
before(:each) do
|
5
|
+
Sinatra::Sessionography.session.clear
|
6
|
+
end
|
7
|
+
|
8
|
+
it "shows an empty session when nothing is initialized" do
|
9
|
+
get "/session"
|
10
|
+
last_response.body.should == "{}"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "writes sessions" do
|
14
|
+
post "/session", {:dog => :woof}
|
15
|
+
Sinatra::Sessionography.session[:dog].should == :woof
|
16
|
+
end
|
17
|
+
|
18
|
+
it "reads sessions" do
|
19
|
+
Sinatra::Sessionography.session[:duck] = :quack
|
20
|
+
get "/session"
|
21
|
+
last_response.body.should == "{:duck=>:quack}"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can be set with an initializing hash" do
|
25
|
+
Sinatra::Sessionography.session = {:sheep => :baa}
|
26
|
+
get "/session"
|
27
|
+
last_response.body.should == "{:sheep=>:baa}"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "persists state across requests" do
|
31
|
+
post "/session", {:snail=>:slurp, :monkey=>:howl, :deer=>'Shoot me!'}
|
32
|
+
post "/session", {:cow=>:moo, :deer=>nil}
|
33
|
+
get "/session"
|
34
|
+
last_response.body.should == "{:snail=>:slurp, :monkey=>:howl, :deer=>nil, :cow=>:moo}"
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'sinatra'
|
4
|
+
require 'rack/test'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
|
8
|
+
set :environment, :test
|
9
|
+
require 'sinatra/sessionography'
|
10
|
+
|
11
|
+
# Simple getter for testing
|
12
|
+
get '/session' do
|
13
|
+
session.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
# Simple setter for testing
|
17
|
+
post '/session' do
|
18
|
+
params.each{|k,v| session[k.to_sym] = (v.is_a?(String) ? v.to_sym : v)}
|
19
|
+
session.inspect
|
20
|
+
end
|
21
|
+
|
22
|
+
# Hook to our application so Rack::Test works; see: http://www.sinatrarb.com/testing.html
|
23
|
+
module SinatraApp
|
24
|
+
def app
|
25
|
+
Sinatra::Application
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Runner.configure do |config|
|
30
|
+
include SinatraApp
|
31
|
+
include Rack::Test::Methods
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-sessionography
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Stephen Eley
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-26 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: sinatra
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
version: "1.0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 1
|
42
|
+
- 2
|
43
|
+
- 9
|
44
|
+
version: 1.2.9
|
45
|
+
type: :development
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: yard
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
description: "Sessionography has only one function: to replace Sinatra's session methods with a basic hash that persists across requests. Bypassing Rack::Session removes nearly all the complexity of unit and integration testing with session data."
|
60
|
+
email: sfeley@gmail.com
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- LICENSE.markdown
|
67
|
+
- README.markdown
|
68
|
+
files:
|
69
|
+
- .document
|
70
|
+
- .gitignore
|
71
|
+
- LICENSE.markdown
|
72
|
+
- README.markdown
|
73
|
+
- Rakefile
|
74
|
+
- VERSION
|
75
|
+
- lib/sinatra/sessionography.rb
|
76
|
+
- sinatra-sessionography.gemspec
|
77
|
+
- spec/sessionography_spec.rb
|
78
|
+
- spec/spec.opts
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/SFEley/sinatra-sessionography
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options:
|
86
|
+
- --charset=UTF-8
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.6
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: A simple sessions stub for testing Sinatra
|
110
|
+
test_files:
|
111
|
+
- spec/sessionography_spec.rb
|
112
|
+
- spec/spec_helper.rb
|