Browse files

Adding support for JS/mechanize selection. This required the URLs to …

…be rewritten
  • Loading branch information...
1 parent f9c5815 commit e8802e91fb57de91bd1dc4ccbe25eb10a3a6fa71 jb@kulor.com committed Jun 11, 2012
Showing with 32 additions and 31 deletions.
  1. +14 −21 app/routes/index.js
  2. +1 −1 features/admin.feature
  3. +2 −3 features/card.feature
  4. +2 −2 features/pack.feature
  5. +1 −1 features/step_definitions/card.rb
  6. +12 −3 features/support/env.rb
View
35 app/routes/index.js
@@ -40,39 +40,32 @@ exports.createCard = function(req, res){
var frontImageResource = req.session.images[req.body.frontImage];
var backImageResource = clone(req.session.images[req.body.backImage]);
backImageResource.imageBasketItem.type = 'back';
+
+ var businessCardImageBox = {
+ "height" : 59,
+ "angle" : 0,
+ "width" : 88,
+ "center" : {
+ "x" : 44,
+ "y" : 29.5
+ }
+ };
+
var frontImageData = [
{
"linkId" : "variable_image_front",
"type" : "imageData",
"resourceUri" : frontImageResource.imageBasketItem.resourceUri,
- "enhance" : false,
- "imageBox" : {
- "height" : 66,
- "angle" : 0,
- "width" : 88,
- "center" : {
- "x" : 44,
- "y" : 29.5
- }
- },
+ "imageBox" : businessCardImageBox
}
];
var backImageData = [
{
- "linkId" : "variable_image_details",
+ "linkId" : "variable_image_front",
"type" : "imageData",
"resourceUri" : backImageResource.imageBasketItem.resourceUri,
- "enhance" : false,
- "imageBox" : {
- "height" : 66,
- "angle" : 0,
- "width" : 88,
- "center" : {
- "x" : 44,
- "y" : 29.5
- }
- },
+ "imageBox" : businessCardImageBox
}
];
View
2 features/admin.feature
@@ -3,7 +3,7 @@ Feature: Admin panel
I want to be able to change the settings of my widget
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 submit the form
Then I should see a list of the images I have uploaded
View
5 features/card.feature
@@ -4,11 +4,10 @@ Feature: Creating a card
Scenario: Create card landing page
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"
- 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
Given I have a sample pack
When I visit "/card/create"
View
4 features/pack.feature
@@ -4,13 +4,13 @@ Feature: Creating a pack
This will allow me to add custom cards to a collection
Scenario: Creating a pack
- When I visit "pack/create"
+ When I visit "/pack/create"
Then I should get the title "Create a pack"
And I click "Create Pack"
Then I should get the title "Pack Details"
Scenario: Seeing a pack contents
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 see a button or link "Create Card"
View
2 features/step_definitions/card.rb
@@ -5,5 +5,5 @@
Then /^I should see the moo canvas with my cards preloaded$/ do
page.should have_css('#BCDesignImageUI.current', :text => 'Crop your images')
- sleep 10
+ sleep 5
end
View
15 features/support/env.rb
@@ -1,10 +1,19 @@
require 'capybara/mechanize/cucumber'
require 'capybara/cucumber'
require 'rspec/expectations'
-# require 'debugger'
Capybara.run_server = false
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.