adyen-admin 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. data/.gitignore +5 -0
  2. data/.travis.yml +3 -0
  3. data/CHANGES.md +16 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +26 -0
  6. data/README.md +57 -0
  7. data/Rakefile +24 -0
  8. data/VERSION +1 -0
  9. data/adyen-admin.gemspec +25 -0
  10. data/lib/adyen-admin/client.rb +26 -0
  11. data/lib/adyen-admin/skin.rb +180 -0
  12. data/lib/adyen-admin.rb +16 -0
  13. data/spec/adyen-admin/client_spec.rb +21 -0
  14. data/spec/adyen-admin/skin_spec.rb +177 -0
  15. data/spec/fixtures/cassettes/Adyen_Admin_Client/_login/passes_with_correct_username_password.yml +661 -0
  16. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_all/returns_the_skins.yml +269 -0
  17. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_download/gets_the_file.yml +275 -0
  18. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_test_url/returns_url_to_test.yml +941 -0
  19. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_upload/valid_set/increases_version.yml +7769 -0
  20. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_version/returns_live_value.yml +77 -0
  21. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_version/returns_test_value.yml +77 -0
  22. data/spec/fixtures/cassettes/Adyen_Admin_Skin/_version/returns_uploaded_value.yml +666 -0
  23. data/spec/fixtures/cassettes/login.yml +668 -0
  24. data/spec/fixtures/skins/DV3tf95f/css/screen.css +262 -0
  25. data/spec/fixtures/skins/DV3tf95f/inc/order_data.txt +1 -0
  26. data/spec/fixtures/skins/JH0815/css/screen.css +262 -0
  27. data/spec/fixtures/skins/JH0815/skin.html.erb +13 -0
  28. data/spec/fixtures/skins/base/css/print.css +7 -0
  29. data/spec/fixtures/skins/base/css/screen_ie6.css +1 -0
  30. data/spec/fixtures/skins/base/img/Airliner.airjamaica.a340.arp.750pix.jpg +0 -0
  31. data/spec/fixtures/skins/base/img/Eurofighter.jpg +0 -0
  32. data/spec/fixtures/skins/base/img/bg_gr.jpg +0 -0
  33. data/spec/fixtures/skins/base/img/blog_gr.jpg +0 -0
  34. data/spec/fixtures/skins/base/img/category.gif +0 -0
  35. data/spec/fixtures/skins/base/img/mig.jpg +0 -0
  36. data/spec/fixtures/skins/base/img/top1.jpg +0 -0
  37. data/spec/fixtures/skins/base/img/top2.jpg +0 -0
  38. data/spec/fixtures/skins/base/img/top3.jpg +0 -0
  39. data/spec/fixtures/skins/base/inc/cfooter.txt +15 -0
  40. data/spec/fixtures/skins/base/inc/cheader.txt +11 -0
  41. data/spec/fixtures/skins/base/inc/pmfooter.txt +1 -0
  42. data/spec/fixtures/skins/base/inc/pmheader.txt +4 -0
  43. data/spec/fixtures/skins/base/res/resources.properties +0 -0
  44. data/spec/fixtures/skins/example-7hFAQnmt/css/print.css +17 -0
  45. data/spec/fixtures/skins/example-7hFAQnmt/css/screen.css +704 -0
  46. data/spec/fixtures/skins/example-7hFAQnmt/css/screen_ie6.css +7 -0
  47. data/spec/fixtures/skins/example-7hFAQnmt/img/banner_top.png +0 -0
  48. data/spec/fixtures/skins/example-7hFAQnmt/img/bg.gif +0 -0
  49. data/spec/fixtures/skins/example-7hFAQnmt/img/bg_buttons.png +0 -0
  50. data/spec/fixtures/skins/example-7hFAQnmt/img/button_template.xcf +0 -0
  51. data/spec/fixtures/skins/example-7hFAQnmt/img/gradient.png +0 -0
  52. data/spec/fixtures/skins/example-7hFAQnmt/img/logo.png +0 -0
  53. data/spec/fixtures/skins/example-7hFAQnmt/img/logo.xcf +0 -0
  54. data/spec/fixtures/skins/example-7hFAQnmt/inc/cfooter.txt +1 -0
  55. data/spec/fixtures/skins/example-7hFAQnmt/inc/cheader.txt +2 -0
  56. data/spec/fixtures/skins/example-7hFAQnmt/inc/pmfooter.txt +1 -0
  57. data/spec/fixtures/skins/example-7hFAQnmt/inc/pmheader.txt +2 -0
  58. data/spec/fixtures/skins/example-7hFAQnmt/metadata.yml +5 -0
  59. data/spec/spec_helper.rb +21 -0
  60. metadata +228 -0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.9.2
3
+ script: "bundle exec rake spec"
data/CHANGES.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+ ## vx.x.x - ???
4
+
5
+ ## v0.0.2 - ???
6
+ * update Docu
7
+ * metafile
8
+ * parent
9
+ * build binaries
10
+ * make compatible with Live system
11
+
12
+
13
+ ## v0.0.1 - 10-04-2012
14
+ _inital release_
15
+
16
+ * basic Skin manipulations
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in adyen-admin.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012, SoundCloud, Tobias Bielohlawek
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ - Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+ - Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+ - Neither the name of the SoundCloud nor the names of its contributors may be
14
+ used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Adyen Admin [![](http://travis-ci.org/rngtng/adyen-admin.png)](http://travis-ci.org/rngtng/adyen-admin)
2
+
3
+ Adyen Admin Skin API and Command line tool
4
+
5
+ A little Gem to make your life easier when dealing with Adyen skins. It offers simple functions to maniu
6
+
7
+ ## Setup
8
+ Install gem
9
+
10
+ gem install adyen-admin
11
+
12
+ Make sure you create a Adyen user with [Technical Setting rights](https://ca-test.adyen.com/ca/ca/config/users.shtml). *Std user rights have to be given as well!*
13
+
14
+
15
+ ## Usage
16
+
17
+ Simple usage case to get all Skins:
18
+
19
+ ```ruby
20
+ require 'adyen/admin'
21
+
22
+ Adyen::Admin.login(<accountname>, <username>, <password>)
23
+
24
+ Adyen::Admin::Skin.all #returns all remote skins
25
+
26
+ ```
27
+
28
+ ### Skins
29
+
30
+ By now a Skin can be:
31
+
32
+ * downloaded
33
+ * uploaded
34
+ * compiled
35
+ * retrieve versions
36
+ * retrieve test_url
37
+ * map to local or remote
38
+
39
+ ## Dependencies
40
+
41
+ Depends on [mechanize](http://mechanize.rubyforge.org/) to access the webinterface
42
+
43
+
44
+ ## Contributing
45
+
46
+ We'll check out your contribution if you:
47
+
48
+ - Provide a comprehensive suite of tests for your fork.
49
+ - Have a clear and documented rationale for your changes.
50
+ - Package these up in a pull request.
51
+
52
+ We'll do our best to help you out with any contribution issues you may have.
53
+
54
+
55
+ ## License
56
+
57
+ The license is included as LICENSE in this directory.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :anonym, :tokens do |t, args|
9
+ replace = args[:tokens].split(" ").map do |token|
10
+ from, to = token.split(":")
11
+ "s/#{from}/#{to}/g"
12
+ end
13
+
14
+ `find -E . -regex '^.+\.(rb|yml)$' -exec sed -i "" "#{replace.join(";")}" {} \\;`
15
+ end
16
+
17
+ task :deanonym, :tokens do |t, args|
18
+ replace = args[:tokens].split(" ").map do |token|
19
+ from, to = token.split(":")
20
+ "s/#{to}/#{from}/g"
21
+ end
22
+
23
+ `find -E . -regex '^.+\.(rb|yml)$' -exec sed -i "" "#{replace.join(";")}" {} \\;`
24
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "adyen-admin"
6
+ s.version = File.read("VERSION")
7
+ s.authors = ["Tobias Bielohlawek"]
8
+ s.email = ["tobi@soundcloud.com"]
9
+ s.homepage = "https://github.com/rngtng/adyen-admin"
10
+ s.summary = %q{Adyen Admin Skin API and Command line tool}
11
+ s.description = %q{A little Gem to make your life easier when dealing with Adyen skins}
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+
18
+ %w(mechanize rubyzip).each do |gem|
19
+ s.add_runtime_dependency *gem.split(' ')
20
+ end
21
+
22
+ %w(rake rspec vcr webmock debugger).each do |gem|
23
+ s.add_development_dependency *gem.split(' ')
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require "adyen-admin/skin"
2
+
3
+ module Adyen
4
+ module Admin
5
+ module Client
6
+ LOGIN = "https://ca-test.adyen.com/ca/ca/login.shtml"
7
+ DASHBOARD = "https://ca-test.adyen.com/ca/ca/overview/default.shtml"
8
+
9
+ def login(accountname, username, password)
10
+ page = Adyen::Admin.client.get(LOGIN)
11
+ page = Adyen::Admin.client.submit(page.form.tap do |form|
12
+ form.j_account = accountname
13
+ form.j_username = username
14
+ form.j_password = password
15
+ end)
16
+ raise "Wrong username + password combination" if page.uri.to_s != DASHBOARD
17
+ end
18
+
19
+ def client
20
+ @agent ||= Mechanize.new
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,180 @@
1
+ require 'tmpdir'
2
+ require 'zip/zip'
3
+
4
+ module Adyen
5
+ module Admin
6
+ class Skin
7
+ UPLOAD = "https://ca-test.adyen.com/ca/ca/skin/uploadskin.shtml?skinCode=%s"
8
+ DOWNLOAD = "https://ca-test.adyen.com/ca/ca/skin/downloadskinsubmit.shtml?skinCode=%s"
9
+ TEST = "https://ca-test.adyen.com/ca/ca/skin/testpayment.shtml?skinCode=%s"
10
+
11
+ VERSION_TEST = "https://test.adyen.com/hpp/version.shtml?skinCode=%s"
12
+ VERSION_LIVE = "https://live.adyen.com/hpp/version.shtml?skinCode=%s"
13
+ PUBLISH = "https://ca-test.adyen.com/ca/ca/skin/publishskin.shtml?skinCode=%s"
14
+ SKINS = "https://ca-test.adyen.com/ca/ca/skin/skins.shtml"
15
+
16
+ attr_accessor :code, :name, :path
17
+
18
+ def initialize(attributes = {})
19
+ attributes.each do |key, value|
20
+ send("#{key}=", value)
21
+ end
22
+
23
+ if !path && code
24
+ path = skin_path([code,name].join("-"))
25
+ end
26
+
27
+ raise ArgumentError unless code
28
+ end
29
+
30
+ def self.all(path = nil)
31
+ all_remote + all_local(path)
32
+ end
33
+
34
+ def self.all_remote
35
+ @@skins_remote ||= begin
36
+ page = Adyen::Admin.client.get(SKINS)
37
+ page.search(".data tbody tr").map do |node|
38
+ Skin.new({
39
+ :code => node.search("a")[0].content.strip,
40
+ :name => node.search("td")[1].content.strip
41
+ })
42
+ end
43
+ end
44
+ end
45
+
46
+ def self.all_local(path)
47
+ Dir[File.join(path.to_s, "*")].map do |path|
48
+ Skin.new(:path => path) rescue nil
49
+ end.compact
50
+ end
51
+
52
+ def self.find(skin_code)
53
+ all.select do |skin|
54
+ skin.code == skin_code
55
+ end.first
56
+ end
57
+
58
+ ##################################
59
+ def path=(path)
60
+ if Skin.is_skin_path?(path)
61
+ code, name = File.basename(path).split("-").reverse
62
+ self.code ||= code
63
+ self.name ||= name
64
+ raise ArgumentError if code && self.code != code
65
+ @path = path
66
+ end
67
+ end
68
+
69
+ def version(scope = :local)
70
+ case scope
71
+ when :test
72
+ page = Adyen::Admin.client.get(VERSION_TEST % code)
73
+ page.search("body p").first.content.scan(/Version:(\d+)/).flatten.first.to_i
74
+ when :live
75
+ page = Adyen::Admin.client.get(VERSION_LIVE % code)
76
+ page.search("body p").first.content.scan(/Version:(\d+)/).flatten.first.to_i
77
+ else
78
+ page = Adyen::Admin.client.get(TEST % code)
79
+ page.search(".data tr td")[2].content.to_i
80
+ end
81
+ end
82
+
83
+ def test_url(options = {})
84
+ page = Adyen::Admin.client.get(TEST % code)
85
+ page = Adyen::Admin.client.submit(page.form.tap do |form|
86
+ #:amount => 199, :currency => :shopper_locale, :country_code, :merchant_reference, :merchant_account, :system, :skip, :one_page
87
+ end)
88
+ Addressable::URI.parse(page.form.action).tap do |uri|
89
+ uri.query_values = page.form.fields.inject({}) { |hash, node|
90
+ hash[node.name] = node.value; hash
91
+ }
92
+ end
93
+ end
94
+
95
+ ##########################################
96
+
97
+ # http://stackoverflow.com/questions/4360043/using-wwwmechanize-to-download-a-file-to-disk-without-loading-it-all-in-memory
98
+ # Adyen::Admin.client.pluggable_parser.default = Mechanize::FileSaver
99
+ def download
100
+ "#{code}.zip".tap do |filename|
101
+ Adyen::Admin.client.download(DOWNLOAD % code, filename)
102
+
103
+ if path
104
+ # create backup of current
105
+ # compile
106
+ end
107
+ # unzip
108
+ end
109
+ end
110
+
111
+ def compile
112
+ raise ArgumentError unless path
113
+
114
+ File.join(Dir.tmpdir, "#{code}.zip").tap do |filename|
115
+ `rm -rf #{filename}`
116
+ Zip::ZipFile.open(filename, 'w') do |zipfile|
117
+ Dir["#{path}/**/**"].each do |file|
118
+ next if file.include?(".yml")
119
+ next if file.include?(".erb")
120
+ zipfile.add(file.sub(path, code), file)
121
+ end
122
+
123
+ if dir = skin_path("base")
124
+ Dir["#{dir}/**/**"].each do |file|
125
+ begin
126
+ next if file.include?(".yml")
127
+ next if file.include?(".erb")
128
+ zipfile.add(file.sub(dir, code), file)
129
+ rescue Zip::ZipEntryExistsError
130
+ # NOOP
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ # http://stackoverflow.com/questions/3420587/ruby-mechanize-multipart-form-with-file-upload-to-a-mediawiki
139
+ def upload
140
+ file = self.compile
141
+ page = Adyen::Admin.client.get(UPLOAD % code)
142
+ page = Adyen::Admin.client.submit(page.form.tap do |form|
143
+ form.file_uploads.first.file_name = file
144
+ end)
145
+ form = page.form
146
+ page = form.submit(page.form.button_with(:name => 'submit'))
147
+ end
148
+
149
+ def publish
150
+ raise ArgumentError unless code
151
+
152
+ page = Adyen::Admin.client.get(PUBLISH % code)
153
+ page = Adyen::Admin.client.submit(page.form.tap do |form|
154
+ end)
155
+ end
156
+
157
+ #################################
158
+
159
+ def skin_path(skin_code)
160
+ skin_dir = path ? File.dirname(path) : Adyen::Admin.skin_dir
161
+ File.join(skin_dir, skin_code).tap do |path|
162
+ return nil unless File.directory?(path)
163
+ end
164
+ end
165
+
166
+ def ==(skin)
167
+ self.code == skin.code
168
+ end
169
+
170
+ private
171
+ def self.is_skin_path?(path)
172
+ %w(skin.html.erb inc css js).each do |sub_path|
173
+ return true if File.exists?(File.join(path, sub_path))
174
+ end
175
+ false
176
+ end
177
+ end
178
+ end
179
+ end
180
+
@@ -0,0 +1,16 @@
1
+ # Copyright (c) 2012, SoundCloud Ltd., Tobias Bielohlawek
2
+
3
+ require 'mechanize'
4
+ require 'adyen-admin/client'
5
+ require 'debugger'
6
+
7
+ module Adyen
8
+ module Admin
9
+ extend Adyen::Admin::Client
10
+
11
+ def skin_dir
12
+ "."
13
+ end
14
+ module_function :skin_dir
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ require "adyen-admin/client"
4
+
5
+ describe Adyen::Admin::Client, :vcr do
6
+ let(:login) { Adyen::Admin.login("SoundCloud", "skinadmin", "12312311") }
7
+
8
+ describe "#login" do
9
+ it 'passes with correct username + password' do
10
+ expect do
11
+ login
12
+ end.to_not raise_error
13
+ end
14
+
15
+ it 'fails on wrong username + password' do
16
+ expect do
17
+ Adyen::Admin.login("Tobi", "fake", "wrong")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,177 @@
1
+ require "spec_helper"
2
+
3
+ require "adyen-admin/client"
4
+ require "adyen-admin/skin"
5
+
6
+ module Adyen::Admin
7
+ describe Skin, :vcr do
8
+ let(:skin_fixtures) { 'spec/fixtures/skins' }
9
+ let(:skin_code) { "7hFAQnmt" }
10
+ let(:skin) { Skin.new(:code => skin_code, :name => "example") }
11
+
12
+ before(:all) do
13
+ VCR.use_cassette("login") do
14
+ Adyen::Admin.login("SoundCloud", "skinadmin", "12312311")
15
+ end
16
+ end
17
+
18
+ describe ".all" do
19
+ it 'returns the skins' do
20
+ Skin.all.should == [
21
+ skin,
22
+ Skin.new(:code => "Kx9axnRf", :name => "demo")
23
+ ]
24
+ end
25
+ end
26
+
27
+ describe ".all_local" do
28
+ it 'returns the skins' do
29
+ Skin.all_local(skin_fixtures).should == [
30
+ Skin.new(:code => "base"),
31
+ Skin.new(:code => "DV3tf95f"),
32
+ skin,
33
+ Skin.new(:code => "JH0815"),
34
+ ]
35
+ end
36
+ end
37
+
38
+ describe ".find" do
39
+ it 'returns the skin' do
40
+ Skin.find(skin_code).should == skin
41
+ end
42
+
43
+ it 'returns no skin' do
44
+ Skin.find("dummy code").should == nil
45
+ end
46
+ end
47
+
48
+ describe "#new" do
49
+ let(:path) { "#{skin_fixtures}/example-7hFAQnmt" }
50
+
51
+ it "sets code attribute" do
52
+ Skin.new(:code => skin_code).code.should == skin_code
53
+ end
54
+
55
+ it "sets name attribute" do
56
+ Skin.new(:code => skin_code, :name => "name").name.should == "name"
57
+ end
58
+
59
+ it "sets path attribute" do
60
+ Skin.new(:path => path).path.should == path
61
+ end
62
+
63
+ it "auto sets code from path" do
64
+ Skin.new(:path => path).code.should == "7hFAQnmt"
65
+ end
66
+
67
+ it "raises error on wrong code for path" do
68
+ expect do
69
+ Skin.new(:code => "different", :path => path).path.should == path
70
+ end.to raise_error
71
+ end
72
+
73
+ it "raises error on empty code" do
74
+ expect do
75
+ Skin.new
76
+ end.to raise_error
77
+ end
78
+
79
+ # it "auto sets directory when found" do
80
+ # Skin.new(:code => "7hFAQnmt" , :name => "example").directory.should == "example-7hFAQnmt"
81
+ # end
82
+ end
83
+
84
+ describe "#download" do
85
+ after do
86
+ `rm -rf #{skin.zip_filename}`
87
+ end
88
+
89
+ it "gets the file" do
90
+ skin.download
91
+ File.should be_exists(skin.zip_filename)
92
+ end
93
+ end
94
+
95
+ describe "#compile" do
96
+ let(:skin_code) { "DV3tf95f" }
97
+ let(:skin) { Skin.new(:path => "#{skin_fixtures}/#{skin_code}") }
98
+
99
+ def zip_contains(zip_filename, file)
100
+ Zip::ZipFile.open(zip_filename, 'r') do |zipfile|
101
+ return true if zipfile.find_entry(File.join(skin_code, file))
102
+ end
103
+ false
104
+ end
105
+
106
+ context "without base" do
107
+ before do
108
+ `mv #{skin_fixtures}/base #{skin_fixtures}/base2`
109
+ end
110
+
111
+ after do
112
+ `mv #{skin_fixtures}/base2 #{skin_fixtures}/base`
113
+ end
114
+
115
+ it "includes screen file" do
116
+ zip_contains(skin.compile, "css/screen.css").should be_true
117
+ end
118
+
119
+ it "excludes print files" do
120
+ zip_contains(skin.compile, "css/print.css").should_not be_true
121
+ end
122
+ end
123
+
124
+ it "includes screen file" do
125
+ zip_contains(skin.compile, "css/screen.css").should be_true
126
+ end
127
+
128
+ it "includes print file" do
129
+ zip_contains(skin.compile, "css/print.css").should be_true
130
+ end
131
+
132
+ it "excludes meta file" do
133
+ zip_contains(skin.compile, "metadata.yml").should_not be_true
134
+ end
135
+
136
+ it "excludes skin file" do
137
+ zip_contains(skin.compile, "skin.html.erb").should_not be_true
138
+ end
139
+ end
140
+
141
+ describe "#upload" do
142
+ context "valid set" do
143
+ it "increases version" do
144
+ skin.path = "#{skin_fixtures}/example-7hFAQnmt"
145
+
146
+ expect do
147
+ skin.upload
148
+ end.to change { skin.version }.by(1)
149
+ end
150
+ end
151
+ end
152
+
153
+ describe "#version" do
154
+ let(:skin) { Skin.new(:code => "Kx9axnRf", :name => "demo") }
155
+
156
+ it "returns uploaded value" do
157
+ skin.version.should == 2
158
+ end
159
+
160
+ it "returns test value" do
161
+ skin.version(:test).should == 2
162
+ end
163
+
164
+ it "returns live value" do
165
+ skin.version(:live).should == 0
166
+ end
167
+ end
168
+
169
+ describe "#test_url" do
170
+ it "returns url to test" do
171
+ skin.test_url.to_s.should include("https://test.adyen.com/hpp/select.shtml")
172
+ end
173
+ #todo test with options
174
+ end
175
+
176
+ end
177
+ end