Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdiogenes committed Dec 26, 2014
1 parent ad1153f commit 7dbf0dc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 40 deletions.
5 changes: 1 addition & 4 deletions lib/s3-upnow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@
require 's3-upnow/config_aws'
require 's3-upnow/form_helper'
require 's3-upnow/engine' if defined?(Rails)
require 's3-upnow/railtie' if defined?(Rails)

ActionView::Base.send(:include, S3UpNow::S3UpNowHelper) if defined?(ActionView::Base)
ActionView::Helpers::FormBuilder.send(:include, S3UpNow::S3UpNowFieldHelper)
require 's3-upnow/railtie' if defined?(Rails)
4 changes: 4 additions & 0 deletions lib/s3-upnow/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module S3UpNow
class Engine < ::Rails::Engine
initializer "s3-upnow.setup", before: :load_environment_config do
ActionView::Base.send(:include, S3UpNow::S3UpNowHelper) if defined?(ActionView::Base)
ActionView::Helpers::FormBuilder.send(:include, S3UpNow::S3UpNowFieldHelper)
end
end
end
4 changes: 2 additions & 2 deletions spec/existance_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spec_helper'
describe S3UpNow do
it "version must be defined" do
S3UpNow::VERSION.should be_true
expect(S3UpNow::VERSION).to be
end

it "config must be defined" do
S3UpNow.config.should be_true
expect(S3UpNow.config).to be
end

end
31 changes: 31 additions & 0 deletions spec/generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require "spec_helper"

describe S3UpNow::Generator do
describe "policy_data" do
describe "starts-with $key" do
it "is configurable with the key_starts_with option" do
key_starts_with = "uploads/"
generator = S3UpNow::Generator.new({:key_starts_with => key_starts_with})
expect(generator.policy_data[:conditions]).to include ["starts-with", "$key", key_starts_with]
end

it "defaults to 'uploads/'" do
generator = S3UpNow::Generator.new({})
expect(generator.policy_data[:conditions]).to include ["starts-with", "$key", "uploads/"]
end
end

describe "starts-with $content-type" do
it "is configurable with the content_type_starts_with option" do
content_type_starts_with = "image/"
generator = S3UpNow::Generator.new({:content_type_starts_with => content_type_starts_with})
expect(generator.policy_data[:conditions]).to include ["starts-with", "$content-type", content_type_starts_with]
end

it "is defaults to an empty string" do
generator = S3UpNow::Generator.new({})
expect(generator.policy_data[:conditions]).to include ["starts-with", "$content-type", ""]
end
end
end
end
33 changes: 0 additions & 33 deletions spec/helpers/form_helper_spec.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 's3-upnow'

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus

Expand Down

0 comments on commit 7dbf0dc

Please sign in to comment.