Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding support for JS/mechanize selection. This required the URLs to …
…be rewritten
  • Loading branch information
jb@kulor.com committed Jun 11, 2012
1 parent f9c5815 commit e8802e9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
35 changes: 14 additions & 21 deletions app/routes/index.js
Expand Up @@ -40,39 +40,32 @@ exports.createCard = function(req, res){
var frontImageResource = req.session.images[req.body.frontImage]; var frontImageResource = req.session.images[req.body.frontImage];
var backImageResource = clone(req.session.images[req.body.backImage]); var backImageResource = clone(req.session.images[req.body.backImage]);
backImageResource.imageBasketItem.type = 'back'; backImageResource.imageBasketItem.type = 'back';

var businessCardImageBox = {
"height" : 59,
"angle" : 0,
"width" : 88,
"center" : {
"x" : 44,
"y" : 29.5
}
};

var frontImageData = [ var frontImageData = [
{ {
"linkId" : "variable_image_front", "linkId" : "variable_image_front",
"type" : "imageData", "type" : "imageData",
"resourceUri" : frontImageResource.imageBasketItem.resourceUri, "resourceUri" : frontImageResource.imageBasketItem.resourceUri,
"enhance" : false, "imageBox" : businessCardImageBox
"imageBox" : {
"height" : 66,
"angle" : 0,
"width" : 88,
"center" : {
"x" : 44,
"y" : 29.5
}
},
} }
]; ];


var backImageData = [ var backImageData = [
{ {
"linkId" : "variable_image_details", "linkId" : "variable_image_front",
"type" : "imageData", "type" : "imageData",
"resourceUri" : backImageResource.imageBasketItem.resourceUri, "resourceUri" : backImageResource.imageBasketItem.resourceUri,
"enhance" : false, "imageBox" : businessCardImageBox
"imageBox" : {
"height" : 66,
"angle" : 0,
"width" : 88,
"center" : {
"x" : 44,
"y" : 29.5
}
},
} }
]; ];


Expand Down
2 changes: 1 addition & 1 deletion features/admin.feature
Expand Up @@ -3,7 +3,7 @@ Feature: Admin panel
I want to be able to change the settings of my widget I want to be able to change the settings of my widget


Scenario: Importing images Scenario: Importing images
When I visit "image/import" When I visit "/image/import"
And I import the image "http://uk.moo.com/images/logo/logo_no_stripe_green.png" And I import the image "http://uk.moo.com/images/logo/logo_no_stripe_green.png"
And I submit the form And I submit the form
Then I should see a list of the images I have uploaded Then I should see a list of the images I have uploaded
Expand Down
5 changes: 2 additions & 3 deletions features/card.feature
Expand Up @@ -4,11 +4,10 @@ Feature: Creating a card


Scenario: Create card landing page Scenario: Create card landing page
Given I have a sample pack Given I have a sample pack
When I visit "card/create" When I visit "/card/create"
Then I should get the title "Create a card" Then I should get the title "Create a card"
And there should be a sample image of a credit card # And there should be a sample image of a credit card


@javascript
Scenario: Submitting the card to the moo service Scenario: Submitting the card to the moo service
Given I have a sample pack Given I have a sample pack
When I visit "/card/create" When I visit "/card/create"
Expand Down
4 changes: 2 additions & 2 deletions features/pack.feature
Expand Up @@ -4,13 +4,13 @@ Feature: Creating a pack
This will allow me to add custom cards to a collection This will allow me to add custom cards to a collection


Scenario: Creating a pack Scenario: Creating a pack
When I visit "pack/create" When I visit "/pack/create"
Then I should get the title "Create a pack" Then I should get the title "Create a pack"
And I click "Create Pack" And I click "Create Pack"
Then I should get the title "Pack Details" Then I should get the title "Pack Details"


Scenario: Seeing a pack contents Scenario: Seeing a pack contents
Given I have a sample pack Given I have a sample pack
When I visit "pack/{{sample_pack_id}}" When I visit "/pack/{{sample_pack_id}}"
And I should have a limit of "50" cards I could create And I should have a limit of "50" cards I could create
And I should see a button or link "Create Card" And I should see a button or link "Create Card"
2 changes: 1 addition & 1 deletion features/step_definitions/card.rb
Expand Up @@ -5,5 +5,5 @@


Then /^I should see the moo canvas with my cards preloaded$/ do Then /^I should see the moo canvas with my cards preloaded$/ do
page.should have_css('#BCDesignImageUI.current', :text => 'Crop your images') page.should have_css('#BCDesignImageUI.current', :text => 'Crop your images')
sleep 10 sleep 5
end end
15 changes: 12 additions & 3 deletions features/support/env.rb
@@ -1,10 +1,19 @@
require 'capybara/mechanize/cucumber' require 'capybara/mechanize/cucumber'
require 'capybara/cucumber' require 'capybara/cucumber'
require 'rspec/expectations' require 'rspec/expectations'
# require 'debugger'


Capybara.run_server = false Capybara.run_server = false
Capybara.app_host = 'http://localhost:3000' Capybara.app_host = 'http://localhost:3000'
Capybara.default_selector = :css Capybara.default_selector = :css


Capybara.default_driver = :mechanize Capybara.default_driver = :mechanize
Capybara.default_driver = :selenium if ENV['DRIVER'] == 'js'

Before do |scenario|
# As the Moo app will throw alert messages when switching pages
# or exiting, this can interfere with the Cucumber session (the next scenario may fail)
begin
page.driver.browser.switch_to.alert.accept
rescue
end
end

0 comments on commit e8802e9

Please sign in to comment.