Skip to content

Commit

Permalink
Using poltergeist for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsantamaria committed Mar 13, 2017
1 parent 2344a8d commit b215e14
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
**/*.swp
Gemfile.lock
gemfiles/*.gemfile.lock
.byebug_history

test_apps/rails_3_2/.bundle
test_apps/rails_3_2/Gemfile.lock
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ We are using dummy applications to handle some of our test cases with different

Append RAILS_ENV=test to both commands to prepare each database for testing

In order to fully test our gem, we needed to use [Selenium](http://docs.seleniumhq.org/download/). Getting this setup is beyond the scope of this Readme.
In order to fully test our gem, we needed to use the [Poltergeist gem](https://github.com/teampoltergeist/poltergeist) and [PhantomJS](http://phantomjs.org/). Getting this setup is beyond the scope of this Readme.

Once you have everything setup, you should be able `appraisal rake` from the root directory have everything run. If you've installed Selenium properly, you should see an automated instance of your browser _(eg. Firefox)_ pop up and run through some of the integration tests.
Once you have everything setup, you should be able to execute `appraisal rake` from the root directory have everything run.

That's all!

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_3_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "http://rubygems.org"

gem "rails", "3.2.13"
gem "paperclip", "3.4.0"
gem "shared_rails", :path => "../test_apps/shared_rails"
gem 'shared_rails', :path => "../test_apps/shared_rails"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "http://rubygems.org"

gem "rails", "4.0.2"
gem "paperclip", "4.1.0"
gem "shared_rails", :path => "../test_apps/shared_rails"
gem 'shared_rails', :path => "../test_apps/shared_rails"

gemspec :path => "../"
4 changes: 3 additions & 1 deletion papercrop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Gem::Specification.new do |s|
s.add_development_dependency "sass"
s.add_development_dependency "sqlite3"
s.add_development_dependency "database_cleaner"
s.add_development_dependency "selenium-webdriver"
s.add_development_dependency "poltergeist"
s.add_development_dependency 'appraisal'
s.add_development_dependency 'test-unit'
s.add_development_dependency 'byebug'
end
8 changes: 4 additions & 4 deletions spec/integration/papercrop_js_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
click_link "New Landscape"

fill_in "Name", :with => "Mountains"
find("#landscape_picture").native.send_keys(File.expand_path("../../../#{mountains_img_path}", __FILE__))
attach_file "Picture", mountains_img_path
click_button "Create Landscape"

sleep 2
sleep 1
page.execute_script("jcrop_api.setSelect([300, 200, 700, 500])")
page.execute_script('if ($("#picture_crop_y").val() == "199"){$("#picture_crop_y").val("200")}')
page.execute_script('if ($("#picture_crop_w").val() == "399"){$("#picture_crop_w").val("400")}')
Expand All @@ -29,15 +29,15 @@
click_link "New Landscape"

fill_in "Name", :with => "Mountains"
find("#landscape_picture").native.send_keys(File.expand_path(File.expand_path("../../../#{mountains_img_path}", __FILE__), __FILE__))
attach_file "Picture", mountains_img_path
click_button "Create Landscape"

click_button "Crop image"
click_link "Back"

click_link "Crop"

sleep 2
sleep 1
page.execute_script("jcrop_api.setSelect([300, 200, 700, 500])")
page.execute_script('if ($("#picture_crop_y").val() == "199"){$("#picture_crop_y").val("200")}')
page.execute_script('if ($("#picture_crop_w").val() == "399"){$("#picture_crop_w").val("400")}')
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
require File.expand_path("../../test_apps/#{ENV["TEST_APP"]}/config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/poltergeist'
require 'database_cleaner'
require 'byebug'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Expand Down Expand Up @@ -40,6 +42,7 @@
config.order = "random"

config.include Capybara::DSL
Capybara.javascript_driver = :poltergeist

config.before(:suite) do
DatabaseCleaner.strategy = :truncation
Expand Down
2 changes: 1 addition & 1 deletion test_apps/shared_rails/shared_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.version = "0.0.0"
s.authors = ["name"]
s.email = ["email"]
s.homepage = "none"
s.homepage = "https://github.com/rsantamaria/papercrop"
s.summary = "Shared content between rails test apps"
s.description = "Shared content between rails test apps"

Expand Down

0 comments on commit b215e14

Please sign in to comment.