dragonfly 0.9.15 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dragonfly might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.gitignore +1 -8
- data/.travis.yml +11 -0
- data/Gemfile +1 -0
- data/History.md +52 -2
- data/LICENSE +1 -1
- data/README.md +38 -95
- data/dev/grid.jpg +0 -0
- data/dev/irbrc.rb +27 -0
- data/dev/rails_template.rb +38 -0
- data/dev/test.ru +56 -0
- data/dev/test_rails +19 -0
- data/dragonfly.gemspec +3 -21
- data/lib/dragonfly.rb +45 -44
- data/lib/dragonfly/app.rb +175 -96
- data/lib/dragonfly/configurable.rb +71 -170
- data/lib/dragonfly/content.rb +211 -0
- data/lib/dragonfly/core_ext/object.rb +1 -6
- data/lib/dragonfly/file_data_store.rb +197 -0
- data/lib/dragonfly/image_magick/analysers/image_properties.rb +23 -0
- data/lib/dragonfly/image_magick/generators/convert.rb +19 -0
- data/lib/dragonfly/image_magick/generators/plain.rb +26 -0
- data/lib/dragonfly/image_magick/generators/plasma.rb +25 -0
- data/lib/dragonfly/image_magick/generators/text.rb +127 -0
- data/lib/dragonfly/image_magick/plugin.rb +83 -0
- data/lib/dragonfly/image_magick/processors/convert.rb +29 -0
- data/lib/dragonfly/image_magick/processors/encode.rb +18 -0
- data/lib/dragonfly/image_magick/processors/thumb.rb +76 -0
- data/lib/dragonfly/job.rb +118 -134
- data/lib/dragonfly/job_endpoint.rb +2 -0
- data/lib/dragonfly/memory_data_store.rb +34 -0
- data/lib/dragonfly/middleware.rb +5 -3
- data/lib/dragonfly/{active_model_extensions.rb → model.rb} +5 -3
- data/lib/dragonfly/{active_model_extensions → model}/attachment.rb +40 -35
- data/lib/dragonfly/{active_model_extensions → model}/attachment_class_methods.rb +36 -40
- data/lib/dragonfly/model/class_methods.rb +109 -0
- data/lib/dragonfly/{active_model_extensions → model}/instance_methods.rb +2 -2
- data/lib/dragonfly/{active_model_extensions → model}/validations.rb +17 -12
- data/lib/dragonfly/railtie.rb +8 -6
- data/lib/dragonfly/register.rb +27 -0
- data/lib/dragonfly/response.rb +47 -52
- data/lib/dragonfly/routed_endpoint.rb +4 -0
- data/lib/dragonfly/serializer.rb +15 -5
- data/lib/dragonfly/server.rb +56 -29
- data/lib/dragonfly/shell.rb +12 -23
- data/lib/dragonfly/spec/data_store_examples.rb +64 -0
- data/lib/dragonfly/temp_object.rb +32 -47
- data/lib/dragonfly/url_attributes.rb +19 -22
- data/lib/dragonfly/url_mapper.rb +3 -0
- data/lib/dragonfly/utils.rb +12 -0
- data/lib/dragonfly/version.rb +1 -1
- data/lib/dragonfly/whitelist.rb +19 -0
- data/lib/rails/generators/dragonfly/USAGE +8 -0
- data/lib/rails/generators/dragonfly/dragonfly_generator.rb +24 -0
- data/lib/rails/generators/dragonfly/templates/initializer.rb.erb +27 -0
- data/samples/gif.gif +0 -0
- data/spec/dragonfly/app_spec.rb +270 -64
- data/spec/dragonfly/configurable_spec.rb +142 -418
- data/spec/dragonfly/content_spec.rb +353 -0
- data/spec/dragonfly/cookie_monster_spec.rb +2 -1
- data/spec/dragonfly/file_data_store_spec.rb +301 -0
- data/spec/dragonfly/image_magick/analysers/image_properties_spec.rb +20 -0
- data/spec/dragonfly/image_magick/generators/convert_spec.rb +19 -0
- data/spec/dragonfly/image_magick/generators/plain_spec.rb +50 -0
- data/spec/dragonfly/image_magick/generators/plasma_spec.rb +32 -0
- data/spec/dragonfly/image_magick/generators/text_spec.rb +77 -0
- data/spec/dragonfly/image_magick/plugin_spec.rb +131 -0
- data/spec/dragonfly/image_magick/processors/convert_spec.rb +56 -0
- data/spec/dragonfly/image_magick/processors/thumb_spec.rb +173 -0
- data/spec/dragonfly/job_endpoint_spec.rb +30 -73
- data/spec/dragonfly/job_spec.rb +280 -608
- data/spec/dragonfly/memory_data_store_spec.rb +20 -0
- data/spec/dragonfly/middleware_spec.rb +47 -27
- data/spec/dragonfly/{active_model_extensions → model}/model_spec.rb +331 -555
- data/spec/dragonfly/model/validations_spec.rb +196 -0
- data/spec/dragonfly/register_spec.rb +35 -0
- data/spec/dragonfly/routed_endpoint_spec.rb +6 -6
- data/spec/dragonfly/serializer_spec.rb +13 -15
- data/spec/dragonfly/server_spec.rb +122 -46
- data/spec/dragonfly/shell_spec.rb +43 -24
- data/spec/dragonfly/temp_object_spec.rb +69 -94
- data/spec/dragonfly/url_attributes_spec.rb +49 -0
- data/spec/dragonfly/utils_spec.rb +32 -0
- data/spec/dragonfly/whitelist_spec.rb +30 -0
- data/spec/dragonfly_spec.rb +43 -0
- data/spec/fixtures/deprecated_stored_content/eggs.bonus +1 -0
- data/spec/fixtures/deprecated_stored_content/eggs.bonus.meta +1 -0
- data/spec/functional/configuration_spec.rb +19 -0
- data/spec/functional/model_urls_spec.rb +43 -41
- data/spec/functional/remote_on_the_fly_spec.rb +14 -16
- data/spec/functional/shell_commands_spec.rb +24 -14
- data/spec/functional/to_response_spec.rb +10 -10
- data/spec/functional/urls_spec.rb +5 -3
- data/spec/spec_helper.rb +23 -28
- data/spec/support/argument_matchers.rb +7 -8
- data/spec/support/image_matchers.rb +14 -36
- data/spec/support/model_helpers.rb +97 -0
- data/spec/support/simple_matchers.rb +12 -0
- metadata +92 -393
- data/.yardopts +0 -29
- data/Rakefile +0 -36
- data/config.ru +0 -14
- data/docs.watchr +0 -1
- data/extra_docs/Analysers.md +0 -68
- data/extra_docs/Caching.md +0 -23
- data/extra_docs/Configuration.md +0 -149
- data/extra_docs/Couch.md +0 -49
- data/extra_docs/DataStorage.md +0 -226
- data/extra_docs/Encoding.md +0 -67
- data/extra_docs/ExampleUseCases.md +0 -116
- data/extra_docs/GeneralUsage.md +0 -105
- data/extra_docs/Generators.md +0 -68
- data/extra_docs/Heroku.md +0 -50
- data/extra_docs/ImageMagick.md +0 -136
- data/extra_docs/Index.md +0 -33
- data/extra_docs/MimeTypes.md +0 -40
- data/extra_docs/Models.md +0 -441
- data/extra_docs/Mongo.md +0 -42
- data/extra_docs/Processing.md +0 -77
- data/extra_docs/Rack.md +0 -52
- data/extra_docs/Rails2.md +0 -57
- data/extra_docs/Rails3.md +0 -56
- data/extra_docs/ServingRemotely.md +0 -104
- data/extra_docs/Sinatra.md +0 -25
- data/extra_docs/URLs.md +0 -203
- data/features/images.feature +0 -47
- data/features/no_processing.feature +0 -14
- data/features/rails.feature +0 -8
- data/features/steps/common_steps.rb +0 -8
- data/features/steps/dragonfly_steps.rb +0 -66
- data/features/steps/rails_steps.rb +0 -40
- data/features/support/env.rb +0 -13
- data/features/support/setup.rb +0 -41
- data/fixtures/rails/files/app/models/album.rb +0 -6
- data/fixtures/rails/files/app/views/albums/new.html.erb +0 -7
- data/fixtures/rails/files/app/views/albums/show.html.erb +0 -6
- data/fixtures/rails/files/config/initializers/dragonfly.rb +0 -4
- data/fixtures/rails/files/features/manage_album_images.feature +0 -38
- data/fixtures/rails/files/features/step_definitions/helper_steps.rb +0 -7
- data/fixtures/rails/files/features/step_definitions/image_steps.rb +0 -25
- data/fixtures/rails/files/features/step_definitions/web_steps.rb +0 -189
- data/fixtures/rails/files/features/support/paths.rb +0 -17
- data/fixtures/rails/files/features/text_images.feature +0 -7
- data/fixtures/rails/template.rb +0 -20
- data/irbrc.rb +0 -19
- data/lib/dragonfly/active_model_extensions/class_methods.rb +0 -98
- data/lib/dragonfly/analyser.rb +0 -58
- data/lib/dragonfly/analysis/file_command_analyser.rb +0 -33
- data/lib/dragonfly/analysis/image_magick_analyser.rb +0 -6
- data/lib/dragonfly/config/heroku.rb +0 -26
- data/lib/dragonfly/config/image_magick.rb +0 -6
- data/lib/dragonfly/config/rails.rb +0 -20
- data/lib/dragonfly/data_storage.rb +0 -11
- data/lib/dragonfly/data_storage/couch_data_store.rb +0 -83
- data/lib/dragonfly/data_storage/file_data_store.rb +0 -144
- data/lib/dragonfly/data_storage/mongo_data_store.rb +0 -96
- data/lib/dragonfly/data_storage/s3data_store.rb +0 -168
- data/lib/dragonfly/encoder.rb +0 -13
- data/lib/dragonfly/encoding/image_magick_encoder.rb +0 -6
- data/lib/dragonfly/function_manager.rb +0 -67
- data/lib/dragonfly/generation/image_magick_generator.rb +0 -6
- data/lib/dragonfly/generator.rb +0 -9
- data/lib/dragonfly/image_magick/analyser.rb +0 -53
- data/lib/dragonfly/image_magick/config.rb +0 -44
- data/lib/dragonfly/image_magick/encoder.rb +0 -57
- data/lib/dragonfly/image_magick/generator.rb +0 -147
- data/lib/dragonfly/image_magick/processor.rb +0 -114
- data/lib/dragonfly/image_magick/utils.rb +0 -46
- data/lib/dragonfly/image_magick_utils.rb +0 -4
- data/lib/dragonfly/job_builder.rb +0 -39
- data/lib/dragonfly/job_definitions.rb +0 -30
- data/lib/dragonfly/loggable.rb +0 -28
- data/lib/dragonfly/processing/image_magick_processor.rb +0 -6
- data/lib/dragonfly/processor.rb +0 -9
- data/lib/dragonfly/rails/images.rb +0 -32
- data/lib/dragonfly/simple_cache.rb +0 -23
- data/spec/dragonfly/active_model_extensions/spec_helper.rb +0 -95
- data/spec/dragonfly/analyser_spec.rb +0 -123
- data/spec/dragonfly/analysis/file_command_analyser_spec.rb +0 -49
- data/spec/dragonfly/data_storage/couch_data_store_spec.rb +0 -84
- data/spec/dragonfly/data_storage/file_data_store_spec.rb +0 -308
- data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +0 -81
- data/spec/dragonfly/data_storage/s3_data_store_spec.rb +0 -277
- data/spec/dragonfly/data_storage/shared_data_store_examples.rb +0 -77
- data/spec/dragonfly/function_manager_spec.rb +0 -154
- data/spec/dragonfly/image_magick/analyser_spec.rb +0 -73
- data/spec/dragonfly/image_magick/encoder_spec.rb +0 -46
- data/spec/dragonfly/image_magick/generator_spec.rb +0 -178
- data/spec/dragonfly/image_magick/processor_spec.rb +0 -293
- data/spec/dragonfly/job_builder_spec.rb +0 -37
- data/spec/dragonfly/job_definitions_spec.rb +0 -57
- data/spec/dragonfly/loggable_spec.rb +0 -80
- data/spec/dragonfly/simple_cache_spec.rb +0 -27
- data/spec/dragonfly/url_attributes.rb +0 -47
- data/spec/functional/deprecations_spec.rb +0 -51
- data/spec/functional/image_magick_app_spec.rb +0 -27
- data/spec/test_imagemagick.ru +0 -49
- data/yard/handlers/configurable_attr_handler.rb +0 -38
- data/yard/setup.rb +0 -15
- data/yard/templates/default/fulldoc/html/css/common.css +0 -109
- data/yard/templates/default/layout/html/layout.erb +0 -93
- data/yard/templates/default/module/html/configuration_summary.erb +0 -31
- data/yard/templates/default/module/setup.rb +0 -17
data/features/images.feature
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
Feature: champion uses dragonfly to process images
|
2
|
-
In order to be a champion
|
3
|
-
A user uses dragonfly
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given we are using the app for images
|
7
|
-
Given a stored image "beach.png" with dimensions 200x100
|
8
|
-
|
9
|
-
Scenario: Go to url for original
|
10
|
-
When I go to the url for "beach.png", with format 'png'
|
11
|
-
Then the response should be OK
|
12
|
-
And the response should have mime-type 'image/png'
|
13
|
-
And the image should have width '200'
|
14
|
-
And the image should have height '100'
|
15
|
-
And the image should have format 'png'
|
16
|
-
|
17
|
-
Scenario: Go to url for changed format version
|
18
|
-
When I go to the url for "beach.png", with format 'gif'
|
19
|
-
Then the response should be OK
|
20
|
-
And the response should have mime-type 'image/gif'
|
21
|
-
And the image should have width '200'
|
22
|
-
And the image should have height '100'
|
23
|
-
And the image should have format 'gif'
|
24
|
-
|
25
|
-
Scenario: Go to url for soft resized version
|
26
|
-
When I go to the url for "beach.png", with format 'png' and resize geometry '100x150'
|
27
|
-
Then the response should be OK
|
28
|
-
And the response should have mime-type 'image/png'
|
29
|
-
And the image should have width '100'
|
30
|
-
And the image should have height '50'
|
31
|
-
And the image should have format 'png'
|
32
|
-
|
33
|
-
Scenario: Go to url for hard resized version
|
34
|
-
When I go to the url for "beach.png", with format 'png' and resize geometry '100x150!'
|
35
|
-
Then the response should be OK
|
36
|
-
And the response should have mime-type 'image/png'
|
37
|
-
And the image should have width '100'
|
38
|
-
And the image should have height '150'
|
39
|
-
And the image should have format 'png'
|
40
|
-
|
41
|
-
Scenario: use a parameters shortcut
|
42
|
-
When I go to the url for "beach.png", with shortcut '100x150!'
|
43
|
-
Then the response should be OK
|
44
|
-
And the response should have mime-type 'image/png'
|
45
|
-
And the image should have width '100'
|
46
|
-
And the image should have height '150'
|
47
|
-
And the image should have format 'png'
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Feature: winner uses dragonfly to serve different kinds of files
|
2
|
-
In order to be a winner
|
3
|
-
As a potential loser
|
4
|
-
I want to be a winner
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given we are using the app for files
|
8
|
-
|
9
|
-
Scenario: Go to url for original, without extension
|
10
|
-
Given a stored file "sample.docx"
|
11
|
-
When I go to the url for "sample.docx"
|
12
|
-
Then the response should be OK
|
13
|
-
And the response should have mime-type 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
14
|
-
And the response should have the same content as the file "sample.docx"
|
data/features/rails.feature
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
Feature: champion uses dragonfly in his Rails application
|
2
|
-
In order to be a champion
|
3
|
-
A user uses dragonfly in his Rails application
|
4
|
-
|
5
|
-
Scenario: Set up dragonfly using initializer
|
6
|
-
Given a Rails application set up for using dragonfly
|
7
|
-
Then the manage_album_images cucumber features in my Rails app should pass
|
8
|
-
And the text_images cucumber features in my Rails app should pass
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
|
-
Given /^we are using the app for (\w+)$/ do |app_name|
|
4
|
-
$app = Dragonfly[app_name.to_sym]
|
5
|
-
end
|
6
|
-
|
7
|
-
Given /^a stored file "(.+?)"$/ do |name|
|
8
|
-
file = File.new(File.dirname(__FILE__) + "/../../samples/#{name}")
|
9
|
-
uid = $app.store(file)
|
10
|
-
TEMP_FILES[name] = uid
|
11
|
-
end
|
12
|
-
|
13
|
-
Given /^a stored image "(.+?)" with dimensions (\d+)x(\d+)$/ do |name, width, height|
|
14
|
-
tempfile = Tempfile.new(name)
|
15
|
-
`convert -resize #{width}x#{height}! #{SAMPLE_IMAGE_PATH} #{tempfile.path}`
|
16
|
-
uid = $app.store(tempfile)
|
17
|
-
TEMP_FILES[name] = uid
|
18
|
-
end
|
19
|
-
|
20
|
-
When /^I go to the url for "(.+?)"$/ do |name|
|
21
|
-
uid = TEMP_FILES[name]
|
22
|
-
make_request $app.fetch(uid)
|
23
|
-
end
|
24
|
-
|
25
|
-
When /^I go to the url for "(.+?)", with format '([^']+?)'$/ do |name, format|
|
26
|
-
uid = TEMP_FILES[name]
|
27
|
-
make_request $app.fetch(uid).encode(format)
|
28
|
-
end
|
29
|
-
|
30
|
-
When /^I go to the url for "(.+?)", with format '(.+?)' and resize geometry '(.+?)'$/ do |name, format, geometry|
|
31
|
-
uid = TEMP_FILES[name]
|
32
|
-
make_request $app.fetch(uid).process(:resize, geometry).encode(format)
|
33
|
-
end
|
34
|
-
|
35
|
-
When /^I go to the url for "(.+?)", with shortcut '([^']+?)'$/ do |name, geometry|
|
36
|
-
uid = TEMP_FILES[name]
|
37
|
-
make_request $app.fetch(uid).thumb(geometry)
|
38
|
-
end
|
39
|
-
|
40
|
-
Then "the response should be OK" do
|
41
|
-
@response.status.should == 200
|
42
|
-
end
|
43
|
-
|
44
|
-
Then /the response should have mime-type '(.+?)'/ do |mime_type|
|
45
|
-
@response.headers['Content-Type'].should == mime_type
|
46
|
-
end
|
47
|
-
|
48
|
-
Then /^the image should have width '(.+?)'$/ do |width|
|
49
|
-
@response.body.should have_width(width.to_i)
|
50
|
-
end
|
51
|
-
|
52
|
-
Then /^the image should have height '(.+?)'$/ do |height|
|
53
|
-
@response.body.should have_height(height.to_i)
|
54
|
-
end
|
55
|
-
|
56
|
-
Then /^the image should have format '(.+?)'$/ do |format|
|
57
|
-
@response.body.should have_format(format)
|
58
|
-
end
|
59
|
-
|
60
|
-
Then /^the response should have the same content as the file "([^\"]*)"$/ do |name|
|
61
|
-
if RUBY_VERSION =~ /^1\.8/
|
62
|
-
@response.body.should == $app.fetch(TEMP_FILES[name]).data
|
63
|
-
else
|
64
|
-
@response.body.force_encoding('BINARY').should == $app.fetch(TEMP_FILES[name]).data.force_encoding('BINARY')
|
65
|
-
end
|
66
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
RAILS_APP_NAME = 'tmp_app'
|
4
|
-
FIXTURES_PATH = ROOT_PATH + "/fixtures"
|
5
|
-
|
6
|
-
def fixture_path
|
7
|
-
"#{FIXTURES_PATH}/rails"
|
8
|
-
end
|
9
|
-
|
10
|
-
def app_path
|
11
|
-
"#{fixture_path}/#{RAILS_APP_NAME}"
|
12
|
-
end
|
13
|
-
|
14
|
-
##############################################################################
|
15
|
-
|
16
|
-
Given "a Rails application set up for using dragonfly" do
|
17
|
-
ok = nil
|
18
|
-
FileUtils.cd fixture_path do
|
19
|
-
FileUtils.rm_rf RAILS_APP_NAME
|
20
|
-
ok = `bundle exec rails new #{RAILS_APP_NAME} -m template.rb`
|
21
|
-
end
|
22
|
-
raise "Problem setting up Rails app" unless ok
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^the (.+) cucumber features in my Rails app should pass$/ do |filename|
|
26
|
-
puts "\n*** RUNNING FEATURES IN THE RAILS APP... ***\n"
|
27
|
-
path = File.join(fixture_path, RAILS_APP_NAME)
|
28
|
-
FileUtils.cd path do
|
29
|
-
env = ENV['RAILS_ENV']
|
30
|
-
ENV['RAILS_ENV'] = 'cucumber'
|
31
|
-
`rake db:migrate`
|
32
|
-
ENV['RAILS_ENV'] = env
|
33
|
-
end
|
34
|
-
features_passed = nil
|
35
|
-
FileUtils.cd path do
|
36
|
-
features_passed = system "cucumber features/#{filename}.feature"
|
37
|
-
end
|
38
|
-
puts "\n*** FINISHED RUNNING FEATURES IN THE RAILS APP ***\n"
|
39
|
-
raise "Features failed" unless features_passed
|
40
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
begin
|
3
|
-
Bundler.setup(:default, :cucumber)
|
4
|
-
rescue Bundler::BundlerError => e
|
5
|
-
$stderr.puts e.message
|
6
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
-
exit e.status_code
|
8
|
-
end
|
9
|
-
|
10
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
-
require 'dragonfly'
|
12
|
-
|
13
|
-
require 'rspec/expectations'
|
data/features/support/setup.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
ROOT_PATH = File.expand_path(File.dirname(__FILE__) + "/../..")
|
2
|
-
|
3
|
-
require ROOT_PATH + '/spec/support/image_matchers.rb'
|
4
|
-
|
5
|
-
# A hash of <name for reference> => <dragonfly uid> pairs
|
6
|
-
TEMP_FILES = {}
|
7
|
-
|
8
|
-
root_path = ROOT_PATH + '/tmp/dragonfly_cukes'
|
9
|
-
logger = Logger.new(ROOT_PATH + '/tmp/dragonfly_cukes.log')
|
10
|
-
|
11
|
-
Dragonfly[:images].configure_with(:imagemagick).configure do |c|
|
12
|
-
c.datastore.root_path = root_path
|
13
|
-
c.log = logger
|
14
|
-
end
|
15
|
-
|
16
|
-
Dragonfly[:files].configure do |c|
|
17
|
-
c.datastore.root_path = root_path
|
18
|
-
c.log = logger
|
19
|
-
c.analyser.register(Dragonfly::Analysis::FileCommandAnalyser)
|
20
|
-
end
|
21
|
-
|
22
|
-
SAMPLE_IMAGE_PATH = ROOT_PATH + '/samples/beach.png'
|
23
|
-
|
24
|
-
Before do
|
25
|
-
# Remove temporary images
|
26
|
-
TEMP_FILES.each do |name, uid|
|
27
|
-
$app.datastore.destroy(uid)
|
28
|
-
TEMP_FILES.delete(name)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module MyHelpers
|
33
|
-
|
34
|
-
def make_request(job)
|
35
|
-
request = Rack::MockRequest.new($app)
|
36
|
-
@response = request.get(job.url)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
World(MyHelpers)
|
@@ -1,38 +0,0 @@
|
|
1
|
-
Feature: champion adds cover images to his albums
|
2
|
-
In order to be a champion
|
3
|
-
A user adds an image to his album
|
4
|
-
|
5
|
-
Scenario: Add and view image
|
6
|
-
When I go to the new album page
|
7
|
-
And I attach the file "../../../samples/beach.png" to "album[cover_image]"
|
8
|
-
And I press "Create"
|
9
|
-
Then I should see "successfully created"
|
10
|
-
And I should see "Look at this cover image!"
|
11
|
-
When I look at the generated image
|
12
|
-
Then I should see a PNG image of size 200x100
|
13
|
-
|
14
|
-
Scenario: validation fails
|
15
|
-
When I go to the new album page
|
16
|
-
And I attach the file "../../../samples/sample.docx" to "album[cover_image]"
|
17
|
-
And I press "Create"
|
18
|
-
Then I should see "Cover image format is incorrect. It needs to be one of 'jpg', 'png', 'gif', but was 'docx'"
|
19
|
-
|
20
|
-
Scenario: other validation fails
|
21
|
-
When I go to the new album page
|
22
|
-
And I fill in "album[name]" with "too long"
|
23
|
-
And I attach the file "../../../samples/beach.png" to "album[cover_image]"
|
24
|
-
And I press "Create"
|
25
|
-
Then I should see "Name is too long"
|
26
|
-
When I fill in "album[name]" with "short"
|
27
|
-
And I press "Create"
|
28
|
-
Then I should see "successfully created"
|
29
|
-
And I should see "short"
|
30
|
-
And I should see "Look at this cover image!"
|
31
|
-
When I look at the generated image
|
32
|
-
Then I should see a PNG image of size 200x100
|
33
|
-
|
34
|
-
Scenario: view remote image
|
35
|
-
Given an album "good" with attached file "beach.png"
|
36
|
-
When I go to the page for album "good"
|
37
|
-
And I look at the original image
|
38
|
-
Then I should see a PNG image of size 280x355
|
@@ -1,25 +0,0 @@
|
|
1
|
-
Given /^an album "(.+)" with attached file "(.+)"$/ do |name, filename|
|
2
|
-
Album.create! :name => name, :cover_image => Rails.root.join('../../../samples', filename)
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I look at the generated image$/ do
|
6
|
-
page.body =~ %r{src="(/media[^"]+?)"}
|
7
|
-
url = $1
|
8
|
-
visit(url)
|
9
|
-
end
|
10
|
-
|
11
|
-
When /^I look at the original image$/ do
|
12
|
-
page.body =~ %r{src="(/system[^"]+?)"}
|
13
|
-
url = $1
|
14
|
-
visit(url)
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^I should see a (.+) image of size (.+)$/ do |format, size|
|
18
|
-
tempfile = Tempfile.new('wicked')
|
19
|
-
tempfile.binmode
|
20
|
-
tempfile.write page.source
|
21
|
-
tempfile.close
|
22
|
-
output = `identify #{tempfile.path}`.split(' ')
|
23
|
-
output[1].should == format
|
24
|
-
output[2].should == size
|
25
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'cgi'
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
4
|
-
|
5
|
-
module WithinHelpers
|
6
|
-
def with_scope(locator)
|
7
|
-
locator ? within(*selector_for(locator)) { yield } : yield
|
8
|
-
end
|
9
|
-
end
|
10
|
-
World(WithinHelpers)
|
11
|
-
|
12
|
-
# Single-line step scoper
|
13
|
-
When /^(.*) within (.*[^:])$/ do |step, parent|
|
14
|
-
with_scope(parent) { When step }
|
15
|
-
end
|
16
|
-
|
17
|
-
# Multi-line step scoper
|
18
|
-
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
19
|
-
with_scope(parent) { When "#{step}:", table_or_string }
|
20
|
-
end
|
21
|
-
|
22
|
-
Given /^(?:|I )am on (.+)$/ do |page_name|
|
23
|
-
visit path_to(page_name)
|
24
|
-
end
|
25
|
-
|
26
|
-
When /^(?:|I )go to (.+)$/ do |page_name|
|
27
|
-
visit path_to(page_name)
|
28
|
-
end
|
29
|
-
|
30
|
-
When /^(?:|I )press "([^"]*)"$/ do |button|
|
31
|
-
click_button(button)
|
32
|
-
end
|
33
|
-
|
34
|
-
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
35
|
-
click_link(link)
|
36
|
-
end
|
37
|
-
|
38
|
-
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
39
|
-
fill_in(field, :with => value)
|
40
|
-
end
|
41
|
-
|
42
|
-
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
43
|
-
fill_in(field, :with => value)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Use this to fill in an entire form with data from a table. Example:
|
47
|
-
#
|
48
|
-
# When I fill in the following:
|
49
|
-
# | Account Number | 5002 |
|
50
|
-
# | Expiry date | 2009-11-01 |
|
51
|
-
# | Note | Nice guy |
|
52
|
-
# | Wants Email? | |
|
53
|
-
#
|
54
|
-
# TODO: Add support for checkbox, select og option
|
55
|
-
# based on naming conventions.
|
56
|
-
#
|
57
|
-
When /^(?:|I )fill in the following:$/ do |fields|
|
58
|
-
fields.rows_hash.each do |name, value|
|
59
|
-
When %{I fill in "#{name}" with "#{value}"}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
64
|
-
select(value, :from => field)
|
65
|
-
end
|
66
|
-
|
67
|
-
When /^(?:|I )check "([^"]*)"$/ do |field|
|
68
|
-
check(field)
|
69
|
-
end
|
70
|
-
|
71
|
-
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
72
|
-
uncheck(field)
|
73
|
-
end
|
74
|
-
|
75
|
-
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
76
|
-
choose(field)
|
77
|
-
end
|
78
|
-
|
79
|
-
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
80
|
-
attach_file(field, File.expand_path(path))
|
81
|
-
end
|
82
|
-
|
83
|
-
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
84
|
-
if page.respond_to? :should
|
85
|
-
page.should have_content(text)
|
86
|
-
else
|
87
|
-
assert page.has_content?(text)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
92
|
-
regexp = Regexp.new(regexp)
|
93
|
-
|
94
|
-
if page.respond_to? :should
|
95
|
-
page.should have_xpath('//*', :text => regexp)
|
96
|
-
else
|
97
|
-
assert page.has_xpath?('//*', :text => regexp)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
102
|
-
if page.respond_to? :should
|
103
|
-
page.should have_no_content(text)
|
104
|
-
else
|
105
|
-
assert page.has_no_content?(text)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
110
|
-
regexp = Regexp.new(regexp)
|
111
|
-
|
112
|
-
if page.respond_to? :should
|
113
|
-
page.should have_no_xpath('//*', :text => regexp)
|
114
|
-
else
|
115
|
-
assert page.has_no_xpath?('//*', :text => regexp)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
120
|
-
with_scope(parent) do
|
121
|
-
field = find_field(field)
|
122
|
-
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
123
|
-
if field_value.respond_to? :should
|
124
|
-
field_value.should =~ /#{value}/
|
125
|
-
else
|
126
|
-
assert_match(/#{value}/, field_value)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
132
|
-
with_scope(parent) do
|
133
|
-
field = find_field(field)
|
134
|
-
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
135
|
-
if field_value.respond_to? :should_not
|
136
|
-
field_value.should_not =~ /#{value}/
|
137
|
-
else
|
138
|
-
assert_no_match(/#{value}/, field_value)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
144
|
-
with_scope(parent) do
|
145
|
-
field_checked = find_field(label)['checked']
|
146
|
-
if field_checked.respond_to? :should
|
147
|
-
field_checked.should be_true
|
148
|
-
else
|
149
|
-
assert field_checked
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
155
|
-
with_scope(parent) do
|
156
|
-
field_checked = find_field(label)['checked']
|
157
|
-
if field_checked.respond_to? :should
|
158
|
-
field_checked.should be_false
|
159
|
-
else
|
160
|
-
assert !field_checked
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
166
|
-
current_path = URI.parse(current_url).path
|
167
|
-
if current_path.respond_to? :should
|
168
|
-
current_path.should == path_to(page_name)
|
169
|
-
else
|
170
|
-
assert_equal path_to(page_name), current_path
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
175
|
-
query = URI.parse(current_url).query
|
176
|
-
actual_params = query ? CGI.parse(query) : {}
|
177
|
-
expected_params = {}
|
178
|
-
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
179
|
-
|
180
|
-
if actual_params.respond_to? :should
|
181
|
-
actual_params.should == expected_params
|
182
|
-
else
|
183
|
-
assert_equal expected_params, actual_params
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
Then /^show me the page$/ do
|
188
|
-
save_and_open_page
|
189
|
-
end
|