Green specs for ember 1.13

This commit is contained in:
2015-08-13 15:08:04 +02:00
parent 8ce95f72e9
commit 0415603a49
7 changed files with 21 additions and 10 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ group :assets do
#gem 'capistrano-local-precompile', require: false #gem 'capistrano-local-precompile', require: false
# See https://github.com/sstephenson/execjs#readme for more supported runtimes # See https://github.com/sstephenson/execjs#readme for more supported runtimes
#gem 'therubyracer', platforms: :ruby gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3' gem 'uglifier', '>= 1.0.3'
+7 -1
View File
@@ -187,7 +187,7 @@ GEM
ember-source (>= 1.8.0) ember-source (>= 1.8.0)
jquery-rails (>= 1.0.17) jquery-rails (>= 1.0.17)
railties (>= 3.1) railties (>= 3.1)
ember-source (1.13.7) ember-source (1.13.8)
ember-validations-rails (1.0.0) ember-validations-rails (1.0.0)
railties railties
erubis (2.7.0) erubis (2.7.0)
@@ -252,6 +252,7 @@ GEM
addressable (~> 2.3) addressable (~> 2.3)
letter_opener (1.4.1) letter_opener (1.4.1)
launchy (~> 2.2) launchy (~> 2.2)
libv8 (3.16.14.11)
loofah (2.0.2) loofah (2.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.3) mail (2.6.3)
@@ -336,6 +337,7 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (10.4.2) rake (10.4.2)
ref (2.0.0)
responders (2.1.0) responders (2.1.0)
railties (>= 4.2.0, < 5) railties (>= 4.2.0, < 5)
rest-client (1.8.0) rest-client (1.8.0)
@@ -419,6 +421,9 @@ GEM
temple (0.7.6) temple (0.7.6)
test_squad (0.0.1) test_squad (0.0.1)
rails rails
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
@@ -518,6 +523,7 @@ DEPENDENCIES
spring-commands-rspec spring-commands-rspec
sucker_punch sucker_punch
test_squad test_squad
therubyracer
turnip turnip
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
web-console (~> 2.0.0) web-console (~> 2.0.0)
@@ -27,6 +27,7 @@ Ember.Application.initializer
application.register('global:variables', Globals, {singleton: true}) application.register('global:variables', Globals, {singleton: true})
application.inject('controller', 'globals', 'global:variables') application.inject('controller', 'globals', 'global:variables')
application.inject('component', 'globals', 'global:variables') application.inject('component', 'globals', 'global:variables')
application.inject('route', 'globals', 'global:variables')
@App = Ember.Application.create @App = Ember.Application.create
LOG_TRANSITIONS: true LOG_TRANSITIONS: true
@@ -2,8 +2,10 @@ ControllerExtensions = Ember.Mixin.create
needs: ['application'] needs: ['application']
ajaxError: (callback)-> ajaxError: (callback)->
handler = (emberError)=> handler = (emberError)=>
emberError = emberError.errors[0] if emberError.errors and emberError.errors.length
console.log "Error: status #{emberError.status}" console.log "Error: status #{emberError.status}"
if emberError.status is 401 status = parseInt(emberError.status)
if status is 401
App.__container__.lookup('route:application').unauthorized() App.__container__.lookup('route:application').unauthorized()
else else
callback.call(@, emberError) callback.call(@, emberError)
@@ -16,6 +16,7 @@ Feature: Sign up as user using facebook
Given there is a confirmed and open supplier Given there is a confirmed and open supplier
And there is a facebook user And there is a facebook user
And the user has an active order And the user has an active order
And there is no user information stored in the local storage
#When I visit the user obtain token path #When I visit the user obtain token path
When the user is on the homepage When the user is on the homepage
Then the user is redirected to the sign in page Then the user is redirected to the sign in page
@@ -38,6 +39,7 @@ Feature: Sign up as user using facebook
Given there is a confirmed and open supplier Given there is a confirmed and open supplier
And there is a instagram user And there is a instagram user
And the user has an active order And the user has an active order
And there is no user information stored in the local storage
#When I visit the user obtain token path #When I visit the user obtain token path
When the user is on the homepage When the user is on the homepage
Then the user is redirected to the sign in page Then the user is redirected to the sign in page
@@ -30,8 +30,7 @@ step "the section table should not be marked as in need of help" do
end end
step 'the table should be marked as occupied and having an active order' do step 'the table should be marked as occupied and having an active order' do
classes = find(".section-table-#{@table.id}")['class'].split(/\s+/) assert_element_class ".section-table-#{@table.id}", %w[occupied active_order]
expect(classes & %w[occupied active_order]).to eq %w[occupied active_order]
end end
step "I click on section table as a supplier" do step "I click on section table as a supplier" do
+6 -5
View File
@@ -15,16 +15,17 @@ module SpecEmberHelpers
JSON.parse(h) JSON.parse(h)
end end
def assert_element_class(selector, class_name) def assert_element_class(selector, expected_class_names)
find selector # capybara wait for element find selector # capybara wait for element
time = 0 time = 0
classes = page.evaluate_script("$('#{selector}').attr('class')") expected_class_names = Array.wrap(expected_class_names).sort
while !classes.include?(class_name) and time < 10 found_classes = page.evaluate_script("$('#{selector}').attr('class')").to_s.split(/\s+/).sort
while (found_classes & expected_class_names) != expected_class_names and time < 10
sleep 0.1 sleep 0.1
classes = page.evaluate_script("$('#{selector}').attr('class')") found_classes = page.evaluate_script("$('#{selector}').attr('class')").to_s.split(/\s+/).sort
time += 1 time += 1
end end
classes.should include class_name (found_classes & expected_class_names).sort.should eq expected_class_names
end end
# expect_that_eventually selector: '.supplier-orders-placed-count-number', has_text: "10" # expect_that_eventually selector: '.supplier-orders-placed-count-number', has_text: "10"