Skip to content

Commit

Permalink
re-introducing cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Fletcher + Tom Uebel committed Dec 27, 2012
1 parent 3447cb8 commit 018ff1f
Show file tree
Hide file tree
Showing 15 changed files with 694 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gem 'grosser-ssl_requirement', :require => 'ssl_requirement'

group :test do
gem 'shoulda'
gem 'cucumber', '1.1.0'
gem 'webrat', '0.7.3'
gem 'rspec', '1.3.2'
gem 'rspec-rails', '1.3.4'
Expand All @@ -36,6 +37,8 @@ group :development do
gem 'guard-rspec'
gem 'spork', '0.8.5'
gem 'guard-spork'
gem 'cucumber-rails', '0.3.2'
gem 'guard-cucumber'
#gem 'reek'
gem 'ruby2ruby', '1.2.2'
gem 'heckle'
Expand Down
20 changes: 20 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,32 @@ GEM
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
columnize (0.3.6)
cucumber (1.1.0)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (~> 2.5.0)
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
diff-lcs (1.1.3)
factory_girl (1.3.3)
fakeweb (1.3.0)
fastercsv (1.5.4)
ffi (1.1.5)
fleximage (1.0.4)
aws-s3
rmagick
gherkin (2.5.4)
json (>= 1.4.6)
grosser-ssl_requirement (0.1.0)
actionpack
guard (1.3.3)
listen (>= 0.4.2)
thor (>= 0.14.6)
guard-cucumber (0.7.5)
cucumber (>= 0.10)
guard (>= 0.8.3)
guard-rspec (1.2.1)
guard (>= 1.1)
guard-spork (1.2.0)
Expand Down Expand Up @@ -131,6 +145,9 @@ GEM
steak (1.1.0)
rspec (>= 1.3)
sys-proctable (0.9.1)
term-ansicolor (1.0.7)
test-unit (1.2.3)
hoe (>= 1.5.1)
thor (0.16.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
Expand All @@ -148,11 +165,14 @@ DEPENDENCIES
SystemTimer (= 1.2.2)
capybara
comma!
cucumber (= 1.1.0)
cucumber-rails (= 0.3.2)
factory_girl (= 1.3.3)
fakeweb
fastercsv (= 1.5.4)
fleximage (= 1.0.4)
grosser-ssl_requirement
guard-cucumber
guard-rspec
guard-spork
heckle
Expand Down
9 changes: 8 additions & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
Expand Down Expand Up @@ -35,3 +36,9 @@ guard 'rspec', :version => 1, :cli => '--drb --color' do
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

guard 'cucumber', :cli => '--drb --format progress --no-profile' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
10 changes: 10 additions & 0 deletions features/bug_7551_new_dash_data_throws_error.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: (#7551) New dash data throws error when the include_subworkstreams parameter is supplied

Background:
Given I am logged in
And I am not an administrator

Scenario: New dash data throws error
Given I belong to a public workstream
When I go to dash data
Then I do not see an error screen
20 changes: 20 additions & 0 deletions features/extensions/capybara-webkit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Capybara::Driver::Webkit::Browser.class_eval do
@@pid = nil

def initialize(options = {})
@socket_class = options[:socket_class] || TCPSocket
ensure_server
connect
end

private

def ensure_server; start_server unless server_running?; end
def start_server
server_path = File.expand_path("#{gem_path}/bin/webkit_server", __FILE__)
@@pid = fork { exec(server_path) }
at_exit { Process.kill("INT", @@pid) }
end
def gem_path; @gem_path ||= Gem.loaded_specs["capybara-webkit"].full_gem_path; end
def server_running?; !@@pid.nil?; end
end
22 changes: 22 additions & 0 deletions features/extensions/webrat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Webrat.module_eval do
def self.session_class
if Webrat.configuration.mode == :selenium
Webrat::SeleniumSession
elsif Webrat.configuration.mode == :webkit
WebkitSession
else
Webrat::Session
end
end
end

Webrat::Scope.class_eval do
# Eliminates response caching so ajax can work
def dom # :nodoc:
if @selector
return scoped_dom
else
return page_dom
end
end
end
82 changes: 82 additions & 0 deletions features/public_work_streams_list.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Feature:(#6137) Browse Bettermeans only shows public workstreams

Background:
Given I am logged in
And I am not an administrator

Scenario: I can see any public workstreams
Given I belong to a public workstream
When I go to Browse Bettermeans
Then I see it
Given a public workstream that I do not belong to
When I go to Browse Bettermeans
Then I see it

Scenario: I cannot see private workstreams even when I am a member
Given a private workstream that I do not belong to
When I go to Browse Bettermeans
Then I do not see it
Given I belong to a private workstream
When I go to Browse Bettermeans
Then I do not see it

Scenario: I cannot see private workstreams that I do not belong to but Anonymous does
Given a private workstream that I do not belong to
But the anonymous user is a member
When I go to Browse Bettermeans
Then I do not see it

Scenario: Administrators cannot see any private workstreams
Given I am an administrator
And a private workstream that I do not belong to
When I go to Browse Bettermeans
Then I do not see it
Given I belong to a private workstream
When I go to Browse Bettermeans
Then I do not see it

Scenario: Anonymous users can see all public workstreams
Given I am not logged in
Given I belong to a public workstream
When I go to Browse Bettermeans
Then I see it
Given a public workstream that I do not belong to
When I go to Browse Bettermeans
Then I see it

Scenario: Anonymous users cannot see any private workstreams at all
Given I am not logged in
And a private workstream that I do not belong to
When I go to Browse Bettermeans
Then I do not see it
Given I belong to a private workstream
When I go to Browse Bettermeans
Then I do not see it

Scenario: It only shows root workstreams
Given a public workstream that is a child of another public workstream
When I go to Browse Bettermeans
Then I do not see it

Scenario: It only shows the top 10 workstreams
Given there are more than 10 workstreams available
When I go to Browse Bettermeans
Then I only see 10

@ajax
Scenario: I cannot see any private workstreams when I load more
Given there are 10 workstreams available
And a private workstream that I do not belong to
And I belong to a private workstream
When I go to Browse Bettermeans
And I load more
And I wait until loaded
Then I only see 10

@ajax
Scenario: I can see public workstreams when I load more
Given there are 11 workstreams available
When I go to Browse Bettermeans
And I load more
And I wait until loaded
Then I see 11
71 changes: 71 additions & 0 deletions features/step_definitions/global_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Given /^I am logged in$/ do
Given "I am logged in as \"brian_dennehy\""
end

Given /^I am logged in as "([^\"]*)"$/ do |username|
@user = ensure_account username,username

teardown { User.delete @user if @user }

Then "Login in as #{username} with password #{username}"

assert_not_contain "Invalid user or password"
end

Given /^I am not logged in$/ do
visit "http://localhost:3000/logout"
@user = User.anonymous
end

Given /^I am(\snot)? an administrator$/ do |not_an_adminstrator|
is_admin = not_an_adminstrator.nil? or not_an_adminstrator
@user.admin = is_admin
@user.save!
end

Given /^Login in as ([^\"]*) with password ([^\"]*)$/ do |username, password|
visit "http://localhost:3000/login"
fill_in "username", :with => username
fill_in "password", :with => password
click_button "login"
end

When /^I go to Browse Bettermeans$/ do
visit "http://localhost:3000/projects"
@view = BrowseBettermeansView.new webrat_session
end

When /^I go to dash data$/ do
the_project = projects.last
visit "http://localhost:3000/projects/#{the_project.id}/new_dashdata?include_subworkstreams=true"
end

When /^I wait until/ do
@view.wait_until_loaded
end

Then /^I do not see an error screen/ do
webrat_session.response_body.should_not contain "Action Controller: Exception caught"
end

def ensure_account(username, password)
result = User.find_by_login(username)

result = create_account(username, password) unless result

result
end

def create_account(username, password)
new_user = User.new
new_user.login = username
new_user.firstname = username
new_user.lastname = username
new_user.password = password
new_user.admin = false
new_user.mail = "#{username}@xxx.com"

new_user.save!

new_user
end
Loading

0 comments on commit 018ff1f

Please sign in to comment.