Make all spec work, switch to thoughtbot way of integration testing

This commit is contained in:
2013-04-10 17:06:47 +02:00
parent 7b71e677c9
commit 20fa6ac805
12 changed files with 175 additions and 220 deletions
+3 -2
View File
@@ -1,6 +1,6 @@
source :rubygems
gem 'rails', '3.2.11'
gem 'rails', '3.2.13'
gem 'rack-cors', :require => 'rack/cors'
# Bundle edge Rails instead:
@@ -36,7 +36,7 @@ gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git'
gem 'devise', '2.0.4'
gem 'devise_simply_stored'
gem 'simple_form'
gem 'active_decorator'
gem 'active_decorator', path: '/Users/bterkuile/companytools/development/rails/components/active_decorator'
gem 'cmtool', github: 'bterkuile/cmtool'
gem 'kaminari'
@@ -65,6 +65,7 @@ group :test do
gem 'rspec-rails'
gem 'cucumber-rails'
gem 'poltergeist'
gem 'selenium-webdriver'
gem 'database_cleaner'
gem 'rb-fsevent', :require => false #if RUBY_PLATFORM =~ /darwin/i
gem 'ruby_gntp'
+83 -80
View File
@@ -34,56 +34,59 @@ GIT
couch_potato (>= 0.2.15)
rest-client (>= 1.4.2)
PATH
remote: /Users/bterkuile/companytools/development/rails/components/active_decorator
specs:
active_decorator (0.3.4)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.11)
actionpack (= 3.2.11)
mail (~> 2.4.4)
actionpack (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
active_decorator (0.3.4)
activemodel (3.2.11)
activesupport (= 3.2.11)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
activesupport (3.2.11)
i18n (~> 0.6)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
addressable (2.3.3)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bootstrap-sass (2.3.0.1)
bootstrap-sass (2.3.1.0)
sass (~> 3.2)
bourbon (3.1.1)
bourbon (3.1.2)
sass (>= 3.2.0)
thor
builder (3.0.4)
capybara (2.0.2)
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
xpath (~> 2.0)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
chunky_png (1.2.7)
chunky_png (1.2.8)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.1)
@@ -95,7 +98,7 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.5.0)
coffee-script-source (1.6.2)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
@@ -106,15 +109,16 @@ GEM
mime-types (~> 1.15)
multi_json (~> 1.0)
rest-client (~> 1.6.1)
cucumber (1.2.3)
cucumber (1.2.5)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.6)
gherkin (~> 2.11.7)
multi_json (~> 1.3)
cucumber-rails (1.3.0)
cucumber-rails (1.3.1)
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
cucumber (>= 1.2.0)
nokogiri (>= 1.5.0)
rails (~> 3.0)
daemons (1.1.9)
database_cleaner (0.9.1)
devise (2.0.4)
@@ -124,11 +128,11 @@ GEM
warden (~> 1.1.1)
devise_simply_stored (0.0.3)
devise
diff-lcs (1.2.1)
email_validator (1.3.0)
diff-lcs (1.2.2)
email_validator (1.4.0)
activemodel
erubis (2.7.0)
eventmachine (1.0.1)
eventmachine (1.0.3)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.2.0)
@@ -136,31 +140,32 @@ GEM
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
faye-websocket (0.4.6)
faye-websocket (0.4.7)
eventmachine (>= 0.12.0)
ffi (1.4.0)
ffi (1.6.0)
formatador (0.2.4)
fssm (0.2.10)
gherkin (2.11.6)
json (>= 1.7.6)
guard (1.6.2)
gherkin (2.11.8)
multi_json (~> 1.3)
guard (1.7.0)
formatador (>= 0.2.4)
listen (>= 0.6.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
terminal-table (>= 1.4.3)
thor (>= 0.14.6)
guard-rspec (2.4.1)
guard-rspec (2.5.2)
guard (>= 1.1)
rspec (~> 2.11)
haml (4.0.0)
haml (4.0.2)
tilt
haml-rails (0.4)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
hike (1.2.1)
hike (1.2.2)
http_parser.rb (0.5.3)
i18n (0.6.4)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.2.1)
railties (>= 3.0, < 5.0)
@@ -174,18 +179,18 @@ GEM
letter_opener (1.1.0)
launchy (~> 2.2.0)
listen (0.7.3)
lumberjack (1.0.2)
mail (2.4.4)
lumberjack (1.0.3)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.21)
mime-types (1.22)
mini_magick (3.5.0)
subexec (~> 0.2.1)
multi_json (1.6.1)
multi_json (1.7.2)
mustache (0.99.4)
nokogiri (1.5.6)
nokogiri (1.5.9)
orm_adapter (0.0.7)
paperclip (3.4.1)
activemodel (>= 3.0.0)
@@ -193,12 +198,10 @@ GEM
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
mime-types
poltergeist (1.0.2)
capybara (> 1.1)
childprocess (~> 0.3)
poltergeist (1.1.0)
capybara (~> 2.0, >= 2.0.1)
faye-websocket (~> 0.4, >= 0.4.4)
http_parser.rb (~> 0.5.3)
multi_json (~> 1.0)
polyglot (0.3.3)
pry (0.9.12)
coderay (~> 1.0.5)
@@ -215,22 +218,22 @@ GEM
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.11)
actionmailer (= 3.2.11)
actionpack (= 3.2.11)
activerecord (= 3.2.11)
activeresource (= 3.2.11)
activesupport (= 3.2.11)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.11)
railties (3.2.11)
actionpack (= 3.2.11)
activesupport (= 3.2.11)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rake (10.0.4)
rb-fsevent (0.9.3)
rdoc (3.12.2)
json (~> 1.4)
@@ -241,10 +244,10 @@ GEM
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
@@ -254,12 +257,12 @@ GEM
rspec-mocks (~> 2.13.0)
ruby_gntp (0.3.4)
rubyzip (0.9.9)
sass (3.2.6)
sass (3.2.7)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.31.0)
selenium-webdriver (2.32.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
@@ -267,49 +270,48 @@ GEM
simple_form (2.1.0)
actionpack (~> 3.0)
activemodel (~> 3.0)
slim (1.3.6)
temple (~> 0.5.5)
slim (1.3.7)
temple (~> 0.6.3)
tilt (~> 1.3.3)
slim-rails (1.1.0)
slim-rails (1.1.1)
actionpack (>= 3.0, < 4.1)
activesupport (>= 3.0, < 4.1)
railties (>= 3.0, < 4.1)
slim (~> 1.3)
slop (3.4.3)
slop (3.4.4)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.2.2)
temple (0.5.5)
terminal-table (1.4.5)
thin (1.5.0)
temple (0.6.3)
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.17.0)
tilt (1.3.4)
thor (0.18.1)
tilt (1.3.7)
tinymce-rails (3.5.8.1)
railties (>= 3.1.1)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.35)
uglifier (1.3.0)
tzinfo (0.3.37)
uglifier (2.0.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
warden (1.1.1)
rack (>= 1.0)
websocket (1.0.7)
xpath (1.0.0)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
active_decorator
active_decorator!
bootstrap-sass
bourbon
cmtool!
@@ -332,12 +334,13 @@ DEPENDENCIES
pry
quiet_assets
rack-cors
rails (= 3.2.11)
rails (= 3.2.13)
rb-fsevent
rqrcode
rspec-rails
ruby_gntp
sass-rails (~> 3.2.3)
selenium-webdriver
simple_form
simply_stored!
slim-rails
+36 -35
View File
@@ -126,13 +126,13 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1122"
inkscape:window-height="852"
inkscape:window-width="1435"
inkscape:window-height="860"
id="namedview43"
showgrid="false"
inkscape:zoom="6.34"
inkscape:cx="51.171527"
inkscape:cy="47.772468"
inkscape:cx="35.062165"
inkscape:cy="30.642055"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
@@ -143,12 +143,12 @@
<rect
style="fill:#303030;fill-opacity:1;stroke:none;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
style="fill:#5f3110;fill-opacity:1;stroke:none"
id="rect3809"
width="96.056786"
height="32.492115"
x="2.5236592"
y="47.791798"
x="2.0504732"
y="47.003155"
ry="0" /><text
font-size="9.4245"
id="text5"
@@ -164,6 +164,7 @@
<text
id="text7"
x="12.23935"
@@ -181,6 +182,7 @@
<text
font-size="9.4245"
id="text19"
@@ -196,6 +198,7 @@
<g
id="g3012"
inkscape:export-filename="/Users/bterkuile/Qwaiter/Android app/Pictures/icon-high-res.png"
@@ -346,41 +349,39 @@
transform="translate(-4208.3103,-4204.1921)"
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/icons/logo-medium.png"
inkscape:export-xdpi="112.82128"
inkscape:export-ydpi="112.82128" /></g><text
inkscape:export-ydpi="413.97891"
inkscape:export-xdpi="413.97891"
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/icons/logo-text.png"
y="68.982262"
x="21.494862"
style="font-size:17.67565727px;fill:#ffffff;fill-opacity:1;font-family:HelveticaRounded-Bold"
id="text3029"
font-size="9.4245"><tspan
id="tspan3031"
style="fill:#ffffff;fill-opacity:1;font-family:Arial Rounded MT Bold;-inkscape-font-specification:Arial Rounded MT Bold">Q</tspan></text>
inkscape:export-ydpi="112.82128" /></g>
<text
inkscape:export-ydpi="413.97891"
inkscape:export-xdpi="413.97891"
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/icons/logo-text.png"
style="font-size:20.05559921px;line-height:139.99999762%;fill:#ffffff;fill-opacity:1"
y="69.955124"
x="35.827068"
style="font-size:20.05559921px;line-height:139.99999762%;fill:#7bb459;fill-opacity:1"
y="69.109116"
x="23.631485"
id="text3033"
sodipodi:linespacing="140%"><tspan
style="font-size:15.75116634px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:139.99999762%;letter-spacing:-0.68085659px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;font-family:Arial Rounded MT Bold;-inkscape-font-specification:'Arial Rounded MT Bold,'"
style="font-size:15.75116634px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:139.99999762%;letter-spacing:-0.68085659px;writing-mode:lr-tb;text-anchor:start;fill:#7bb459;fill-opacity:1;font-family:Arial Rounded MT Bold;-inkscape-font-specification:'Arial Rounded MT Bold,'"
id="tspan3035"
font-size="9.4245"
y="69.955124"
x="35.827068"
dx="0">WAITE</tspan></text>
y="69.109116"
x="23.631485"
dx="0 0"><tspan
style="fill:#f8ad15;fill-opacity:1"
id="tspan3824">Q</tspan><tspan
style="fill:#ffffff;fill-opacity:1"
id="tspan3800">WAITE</tspan><tspan
style="fill:#f8ad15;fill-opacity:1"
id="tspan3826">R</tspan></tspan></text>
<text
inkscape:export-ydpi="413.97891"
inkscape:export-xdpi="413.97891"
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/icons/logo-text.png"
y="69.934372"
x="83.856453"
style="font-size:17.45138359px;fill:#ffffff;fill-opacity:1;font-family:HelveticaRounded-Bold"
id="text3037"
font-size="9.4245"><tspan
id="tspan3039"
style="fill:#ffffff;fill-opacity:1;font-family:Arial Rounded MT Bold;-inkscape-font-specification:Arial Rounded MT Bold">R</tspan></text>
xml:space="preserve"
style="font-size:36px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
x="35.962147"
y="74.290222"
id="text3028"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3030"
x="35.962147"
y="74.290222" /></text>
</svg>

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

+8
View File
@@ -26,6 +26,14 @@ module JSON
end
end
end
MultiJson.engine = :json_gem
require 'simply_stored'
module SimplyStored::Couch
def freeze
self
end
end
module Qwaiter
class Application < Rails::Application
+8 -5
View File
@@ -6,16 +6,19 @@
require 'cucumber/rails'
require 'capybara/poltergeist'
#Capybara.javascript_driver = :poltergeist
poltergeist = false
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
Capybara.register_driver :selenium do |app|
#Capybara::Selenium::Driver.new(app, :browser => :chrome)
Capybara::Selenium::Driver.new(app, :browser => :firefox)
if poltergeist
Capybara.javascript_driver = :poltergeist
else
Capybara.register_driver :selenium do |app|
#Capybara::Selenium::Driver.new(app, :browser => :chrome)
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
end
# By default, any exception happening in your Rails application will bubble up
-4
View File
@@ -1,4 +0,0 @@
require 'spec_helper'
# Put your acceptance spec helpers inside spec/acceptance/support
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
@@ -1,48 +0,0 @@
require 'acceptance/acceptance_helper'
feature 'Supplier main board spec.rb', %q{
In order to manage active lists and orders
As a confirmed supplier
I want to have control over lists and orders from the main activity panel
} do
background do
CouchPotato.couchrest_database.recreate!
create_confirmed_supplier 'supplier@qwaiter.com'
create_user 'user@qwaiter.com'
end
def create_active_list(options = {})
@table = create :table, supplier: @supplier
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
end
context "having javascript activated", js: true do
scenario 'the active list should be present and contained in row having its id' do
create_active_list
login_supplier_as 'supplier@qwaiter.com'
visit '/supplier'
page.should have_selector "#list-row-#{@list.id}"
end
scenario 'an order is added to the list before visiting the page' do
create_active_list
login_supplier_as 'supplier@qwaiter.com'
product = create :product, supplier: @supplier
sleep 0.1
@list.place_order @user, {product.id => 369}
visit '/supplier'
page.should have_selector ".of-list-#{@list.id}"
end
scenario 'an order is added to the list after visiting the page' do
create_active_list
login_supplier_as 'supplier@qwaiter.com'
product = create :product, supplier: @supplier
visit '/supplier'
@list.place_order @user, {product.id => 369}
sleep 0.1
page.should have_selector ".of-list-#{@list.id}"
end
end
end
-35
View File
@@ -1,35 +0,0 @@
module HelperMethods
# Put helper methods you need to be available in all acceptance specs here.
def create_user(email, password='secret')
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
end
def create_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
end
def create_confirmed_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
@supplier.confirm! unless @supplier.confirmed?
end
def login_user_as(email)
visit "/users/sign_in"
fill_in "user_email", with: email
fill_in "user_password", with: "secret"
submit_form
end
def login_supplier_as(email)
visit "/suppliers/sign_in"
fill_in "supplier_email", with: email
fill_in "supplier_password", with: "secret"
submit_form
end
def submit_form
find("[type=submit]").click
end
end
RSpec.configuration.include HelperMethods, :type => :acceptance
-9
View File
@@ -1,9 +0,0 @@
module NavigationHelpers
# Put helper methods related to the paths in your application here.
def homepage
"/"
end
end
RSpec.configuration.include NavigationHelpers, :type => :acceptance
@@ -1,5 +1,4 @@
require 'acceptance/acceptance_helper'
require 'spec_helper'
feature 'Supplier product categories spec', %q{
In order to manage product categories
As a confirmed supplier
+1
View File
@@ -32,6 +32,7 @@ RSpec.configure do |config|
config.include FactoryAttributesFor
config.include Devise::TestHelpers, :type => :controller
config.include EndWithMatcher
config.include Features::BasicHelpers, type: :feature
#config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = true
config.render_views = true
+35
View File
@@ -0,0 +1,35 @@
module Features
module BasicHelpers
# Put helper methods you need to be available in all acceptance specs here.
def create_user(email, password='secret')
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
end
def create_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
end
def create_confirmed_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
@supplier.confirm! unless @supplier.confirmed?
end
def login_user_as(email)
visit "/users/sign_in"
fill_in "user_email", with: email
fill_in "user_password", with: "secret"
submit_form
end
def login_supplier_as(email)
visit "/suppliers/sign_in"
fill_in "supplier_email", with: email
fill_in "supplier_password", with: "secret"
submit_form
end
def submit_form
find("[type=submit]").click
end
end
end