Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

* upstream/master:
  updating readme for cucumber and adding rspec usage
  gem management: remove jeweler, just use bundler template
  adding gemfile lock to gitignore and a note about why
  updating for capybara "api" changes & move driver.browser into the driver adapters
  • Loading branch information...
2 parents 01be121 + b7d6d04 commit 947a4c3bfd276e86a32c4e4af8812a2d16c3d1cd @twalpole committed Apr 29, 2011
View
@@ -1,15 +1,6 @@
-# rcov generated
-coverage
-
-# rdoc generated
-rdoc
-
-# yard generated
-doc
-.yardoc
-
-# bundler
+pkg/*
+*.gem
.bundle
-# jeweler generated
-pkg
+# don't vc this, http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
+Gemfile.lock
View
12 Gemfile
@@ -1,12 +1,4 @@
source "http://rubygems.org"
-# Add dependencies required to use your gem here.
-# Example:
-# gem "activesupport", ">= 2.3.5"
-# Add dependencies to develop your gem here.
-# Include everything needed to run rake, tests, features, etc.
-group :development do
- gem "cucumber", ">= 0"
- gem "bundler", "~> 1.0.0"
- gem "jeweler", "~> 1.5.2"
-end
+# Specify your gem's dependencies in show_me_the_cookies.gemspec
+gemspec
View
112 README.md
@@ -10,79 +10,99 @@ Rails session cookies look something like '\_appname\_session', and can be found
Credits and Acknowledgements
==================================
-Initial release as a gist [here](https://gist.github.com/484787), early development sponsored by [Medify](www.medify.co.uk).
+Initial release as a gist [here](https://gist.github.com/484787), early development sponsored by [Medify](http://www.medify.co.uk).
Contributions have been made by:
* [Leandro Pedroni](https://github.com/ilpoldo) -- Rails 3 session cookie detection (no longer in the code but present in readme)
* [Matthew Nielsen](https://github.com/xunker) -- added culerity support & encouraged gem release
+gem install
+-----------
+gem install show\_me\_the\_cookies, or whatever fits your situation.
-Example Usage
-=============
+RSpec
+=====
+
+in step_helper or your support directory:
+
+ RSpec.configure do |config|
+ config.include ShowMeTheCookies, :type => :request
+ end
+
+Example usage
+--------------
+
+
+ it "remember-me is on by default" do
+ member = Member.make
+ visit dashboard_path
+ page.should have_content "Login"
+ within '#member_login' do
+ fill_in "Email", :with => member.email
+ fill_in "Password", :with => member.password
+ click_on "Sign in"
+ end
+
+ page.should have_content("Dashboard")
+ page.should have_no_content("Login")
+ # Given I close my browser (clearing the session)
+ delete_cookie Rails.application.config.session_options[:key]
+
+ # When I come back next time
+ visit dashboard_path
+ page.should have_content("Dashboard")
+ page.should have_no_content("Login")
+ end
+
+
+Cucumber
+========
+
+Install by loading the gem and adding the following to your stepdefs or support files
+
+ World(ShowMeTheCookies)
+ Before('@announce') do
+ @announce = true
+ end
-Feature
--------
+Example Usage
+-------------
@javascript @announce
Scenario: remembering users so they don't have to log in again for a while
- Given an activated member exists with forename: "Paul", surname: "Smith", email: "paul_smith_91@gmail.com", password: "bananabanana"
+ Given I am a site member
When I go to the dashboard
- Then I should see "Existing Member Login"
- When I fill in "Email" with "paul_smith_91@gmail.com" within "#member_login"
- And I fill in "Password" with "bananabanana" within "#member_login"
- And I check "Remember me"
- And I press "Sign in"
- Then I should be on the dashboard
- And I should see "Logged in as Paul Smith"
- And I should see "Sign out"
-
- Given I close my browser (clearing the Medify session)
- When I come back next time
- And I go to the dashboard
- Then I should see "Logged in as Paul Smith"
- And I should see "Sign out"
+ And I log in with the Remember Me option checked
+ Then I should see "Welcome back"
+
+ When I close my browser (clearing the session)
+ And I return to the dashboard url
+ Then I should see "Welcome back"
@rack_test @announce
Scenario: don't remember users across browser restarts if they don't want it
- Given an activated member exists with forename: "Paul", surname: "Smith", email: "paul_smith_91@gmail.com", password: "bananabanana"
+ Given I am a site member
When I go to the dashboard
- Then I should see "Existing Member Login"
- When I fill in "Email" with "paul_smith_91@gmail.com" within "#member_login"
- And I fill in "Password" with "bananabanana" within "#member_login"
- And I uncheck "Remember me"
- And I press "Sign in"
- Then I should be on the dashboard
- And I should see "Logged in as Paul Smith"
- And I should see "Sign out"
-
- Given I close my browser (clearing the Medify session)
- When I come back next time
- And I go to the dashboard
- Then I should see "Existing Member Login"
- And I should not see "Logged in as Paul Smith"
- And I should not see "Sign out"
+ And I log in without the Remember Me option checked
+ Then I should see "Welcome back"
+
+ When I close my browser (clearing the session)
+ And I return to the dashboard url
+ Then I should see the log-in screen
-gem install
------------
-gem install show\_me\_the\_cookies, or whatever fits your situation.
stepdef file
------------
-call it whatever you like, mine is called cookie_steps.rb
+for example cookie_steps.rb
Then /^show me the cookies!$/ do
show_me_the_cookies
end
Given /^I close my browser \(clearing the Medify session\)$/ do
- delete_cookie '_medify_session' # or in rails 3 use Rails.application.config.session_options[:key]
- end
-
- World(ShowMeTheCookies)
- Before('@announce') do
- @announce = true
+ delete_cookie '_appname_session' # or in rails 3 use Rails.application.config.session_options[:key]
end
Contributing
View
@@ -1,42 +1,2 @@
-require 'rubygems'
require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-require 'rake'
-
-require 'jeweler'
-Jeweler::Tasks.new do |gem|
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "show_me_the_cookies"
- gem.homepage = "http://github.com/nruth/show_me_the_cookies"
- gem.license = "MIT"
- gem.summary = %Q{Cookie manipulation for Capybara drivers}
- gem.description = %Q{Cookie manipulation for Capybara drivers -- viewing, deleting, ...}
- gem.email = "nick.rutherford@gmail.com"
- gem.authors = ["Nicholas Rutherford"]
- # Include your dependencies below. Runtime dependencies are required when using your gem,
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
- # gem.add_development_dependency 'rspec', '> 1.2.3'
-end
-Jeweler::RubygemsDotOrgTasks.new
-
-require 'cucumber/rake/task'
-Cucumber::Rake::Task.new(:features)
-
-task :default => :spec
-
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
-
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "show_me_the_cookies #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
+Bundler::GemHelper.install_tasks
@@ -1,9 +0,0 @@
-Feature: something something
- In order to something something
- A user something something
- something something something
-
- Scenario: something something
- Given inspiration
- When I create a sweet new gem
- Then everyone should see how awesome I am
View
@@ -1,13 +0,0 @@
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-
-$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
-require 'show_me_the_cookies'
-
-require 'rspec/expectations'
View
@@ -5,15 +5,16 @@ module ShowMeTheCookies
require 'show_me_the_cookies/selenium'
def current_driver_adapter
- case (current_driver = Capybara.current_session.driver)
- when Capybara::Driver::Selenium
- ShowMeTheCookies::Selenium.new(current_driver.browser)
- when Capybara::Driver::RackTest
- ShowMeTheCookies::RackTest.new(current_driver)
- when Capybara::Driver::Culerity
- ShowMeTheCookies::Culerity.new(current_driver.browser)
+ driver = Capybara.current_session.driver
+ case Capybara.current_driver
+ when :selenium
+ ShowMeTheCookies::Selenium.new driver
+ when :rack_test
+ ShowMeTheCookies::RackTest.new driver
+ when :culerity
+ ShowMeTheCookies::Culerity.new driver
else
- unsupported_driver_spam
+ raise "unsupported driver, use rack::test, selenium/webdriver or culerity"
end
end
@@ -37,8 +38,4 @@ def set_cookie(name, value, opts={})
private
@@session_cookie_name = nil
-
- def self.unsupported_browser_spam
- raise "unsupported driver, use rack::test, selenium/webdriver or culerity"
- end
end
@@ -1,6 +1,6 @@
class ShowMeTheCookies::Culerity
- def initialize(browser)
- @browser = browser
+ def initialize(driver)
+ @browser = driver.browser
end
def show_me_the_cookies
@@ -20,6 +20,6 @@ def set_cookie(name, value, opts={})
end
private
def cookie_jar
- @rack_test_driver.current_session.instance_variable_get(:@rack_mock_session).cookie_jar
+ @rack_test_driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar
end
end
@@ -1,6 +1,6 @@
class ShowMeTheCookies::Selenium
- def initialize(browser)
- @browser = browser
+ def initialize(driver)
+ @browser = driver.browser
self
end
@@ -0,0 +1,3 @@
+module ShowMeTheCookies
+ VERSION = "0.2.1"
+end
@@ -1,60 +1,20 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "show_me_the_cookies/version"
Gem::Specification.new do |s|
- s.name = %q{show_me_the_cookies}
- s.version = "0.2.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Nicholas Rutherford"]
- s.date = %q{2011-01-07}
+ s.name = "show_me_the_cookies"
+ s.version = ShowMeTheCookies::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Nicholas Rutherford"]
+ s.email = ["nick.rutherford@gmail.com"]
+ s.homepage = "https://github.com/nruth/show_me_the_cookies"
+ s.summary = %q{Cookie manipulation for Capybara drivers}
s.description = %q{Cookie manipulation for Capybara drivers -- viewing, deleting, ...}
- s.email = %q{nick.rutherford@gmail.com}
- s.extra_rdoc_files = [
- "LICENSE.txt",
- "README.md"
- ]
- s.files = [
- ".document",
- ".rspec",
- "Gemfile",
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "VERSION",
- "features/show_me_the_cookies.feature",
- "features/step_definitions/show_me_the_cookies_steps.rb",
- "features/support/env.rb",
- "lib/show_me_the_cookies.rb",
- "lib/show_me_the_cookies/culerity.rb",
- "lib/show_me_the_cookies/rack_test.rb",
- "lib/show_me_the_cookies/selenium.rb",
- "show_me_the_cookies.gemspec"
- ]
- s.homepage = %q{http://github.com/nruth/show_me_the_cookies}
s.licenses = ["MIT"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.4.2}
- s.summary = %q{Cookie manipulation for Capybara drivers}
-
- if s.respond_to? :specification_version then
- s.specification_version = 3
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<cucumber>, [">= 0"])
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
- else
- s.add_dependency(%q<cucumber>, [">= 0"])
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
- end
- else
- s.add_dependency(%q<cucumber>, [">= 0"])
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
- end
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
end
-

0 comments on commit 947a4c3

Please sign in to comment.