From b33acf38fc2376761105b366d764d5e946828ea6 Mon Sep 17 00:00:00 2001 From: Robert Graff Date: Tue, 4 Nov 2014 06:20:40 -0800 Subject: [PATCH 1/4] update rspec, bundler, gemspec to get dev env modernized --- .rspec | 2 +- Gemfile | 14 ++++++ Gemfile.lock | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ Rakefile | 40 ++++++++--------- litmus.gemspec | 33 ++++++++++++-- 5 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/.rspec b/.rspec index 9b79684..2f34fc0 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---tty --colour --profile --format nested +--tty --colour --profile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..52d9bfb --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "http://rubygems.org" + +gem "httparty", ">= 0.6.1" + +group :development do + gem "rspec" + gem "bundler", "~> 1.0" + gem "jeweler", "~> 2.0.1" + gem "simplecov", ">= 0" + gem "fakeweb" + gem 'guard-rspec', '~> 4.3.1' + gem 'guard-bundler' + gem 'terminal-notifier-guard' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..a0c8c73 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,118 @@ +GEM + remote: http://rubygems.org/ + specs: + addressable (2.3.6) + builder (3.2.2) + celluloid (0.15.2) + timers (~> 1.1.0) + coderay (1.1.0) + descendants_tracker (0.0.4) + thread_safe (~> 0.3, >= 0.3.1) + diff-lcs (1.2.5) + docile (1.1.5) + fakeweb (1.3.0) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) + ffi (1.9.3) + formatador (0.2.5) + git (1.2.8) + github_api (0.12.1) + addressable (~> 2.3) + descendants_tracker (~> 0.0.4) + faraday (~> 0.8, < 0.10) + hashie (>= 3.2) + multi_json (>= 1.7.5, < 2.0) + nokogiri (~> 1.6.3) + oauth2 + guard (2.6.1) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-bundler (2.0.0) + bundler (~> 1.0) + guard (~> 2.2) + guard-rspec (4.3.1) + guard (~> 2.1) + rspec (>= 2.14, < 4.0) + hashie (3.3.1) + highline (1.6.21) + httparty (0.13.2) + json (~> 1.8) + multi_xml (>= 0.5.2) + jeweler (2.0.1) + builder + bundler (>= 1.0) + git (>= 1.2.5) + github_api + highline (>= 1.6.15) + nokogiri (>= 1.5.10) + rake + rdoc + json (1.8.1) + jwt (1.0.0) + listen (2.7.8) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.6) + method_source (0.8.2) + mini_portile (0.6.0) + multi_json (1.10.1) + multi_xml (0.5.5) + multipart-post (2.0.0) + nokogiri (1.6.3.1) + mini_portile (= 0.6.0) + oauth2 (1.0.0) + faraday (>= 0.8, < 0.10) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (~> 1.2) + pry (0.10.0) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + rack (1.5.2) + rake (10.3.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + rdoc (4.0.0) + rspec (3.1.0) + rspec-core (~> 3.1.0) + rspec-expectations (~> 3.1.0) + rspec-mocks (~> 3.1.0) + rspec-core (3.1.7) + rspec-support (~> 3.1.0) + rspec-expectations (3.1.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.1.0) + rspec-mocks (3.1.3) + rspec-support (~> 3.1.0) + rspec-support (3.1.2) + simplecov (0.9.0) + docile (~> 1.1.0) + multi_json + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + slop (3.5.0) + terminal-notifier-guard (1.5.3) + thor (0.19.1) + thread_safe (0.3.4) + timers (1.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + bundler (~> 1.0) + fakeweb + guard-bundler + guard-rspec (~> 4.3.1) + httparty (>= 0.6.1) + jeweler (~> 2.0.1) + rspec + simplecov + terminal-notifier-guard diff --git a/Rakefile b/Rakefile index 749200f..380ac36 100644 --- a/Rakefile +++ b/Rakefile @@ -19,27 +19,27 @@ rescue LoadError puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" end -require 'rspec/core' -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = 'spec/**/*_spec.rb' -end - -RSpec::Core::RakeTask.new(:rcov) do |spec| - spec.pattern = 'spec/**/*_spec.rb' - spec.rcov = true -end +# require 'rspec/core' +# require 'rspec/core/rake_task' +# RSpec::Core::RakeTask.new(:spec) do |spec| +# spec.pattern = 'spec/**/*_spec.rb' +# end +# +# RSpec::Core::RakeTask.new(:rcov) do |spec| +# spec.pattern = 'spec/**/*_spec.rb' +# spec.rcov = true +# end task :spec => :check_dependencies task :default => :spec - -require 'rake/rdoctask' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "litmus #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end +# +# require 'rake/rdoctask' +# Rake::RDocTask.new do |rdoc| +# version = File.exist?('VERSION') ? File.read('VERSION') : "" +# +# rdoc.rdoc_dir = 'rdoc' +# rdoc.title = "litmus #{version}" +# rdoc.rdoc_files.include('README*') +# rdoc.rdoc_files.include('lib/**/*.rb') +# end diff --git a/litmus.gemspec b/litmus.gemspec index 4e37823..73f7e43 100644 --- a/litmus.gemspec +++ b/litmus.gemspec @@ -2,14 +2,16 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- +# stub: litmus 0.3.0 ruby lib Gem::Specification.new do |s| s.name = "litmus" s.version = "0.3.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] s.authors = ["Matt Fawcett"] - s.date = "2012-01-14" + s.date = "2014-11-04" s.description = "A wrapper to the Litmus customer API" s.email = "mail@matthewfawcett.co.uk" s.extra_rdoc_files = [ @@ -51,21 +53,44 @@ Gem::Specification.new do |s| "spec/test_version_spec.rb" ] s.homepage = "http://github.com/mattfawcett/litmus" - s.require_paths = ["lib"] - s.rubygems_version = "1.8.11" + s.rubygems_version = "2.2.1" s.summary = "A wrapper to the Litmus customer API" if s.respond_to? :specification_version then - s.specification_version = 3 + s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0.6.1"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["~> 1.0"]) + s.add_development_dependency(%q, ["~> 2.0.1"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["~> 4.3.1"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 1.2.9"]) s.add_runtime_dependency(%q, [">= 0.6.1"]) else + s.add_dependency(%q, [">= 0.6.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 1.0"]) + s.add_dependency(%q, ["~> 2.0.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 4.3.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 1.2.9"]) s.add_dependency(%q, [">= 0.6.1"]) end else + s.add_dependency(%q, [">= 0.6.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 1.0"]) + s.add_dependency(%q, ["~> 2.0.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 4.3.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 1.2.9"]) s.add_dependency(%q, [">= 0.6.1"]) end From be33706aad5e9a0785f99075f0c2b2e303e70412 Mon Sep 17 00:00:00 2001 From: Robert Graff Date: Tue, 4 Nov 2014 06:23:51 -0800 Subject: [PATCH 2/4] Use configure instead of initialize to set up base class. --- lib/litmus/base.rb | 13 ++++++++----- spec/litmus_spec.rb | 12 ++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/litmus/base.rb b/lib/litmus/base.rb index 3d9567d..dcf4d2f 100644 --- a/lib/litmus/base.rb +++ b/lib/litmus/base.rb @@ -1,13 +1,16 @@ module Litmus class Base include HTTParty - + # debug_output $stderr - def initialize(company, username, password, ssl = false) + self.class.configure(company, username, password, ssl) + end + + def self.configure(company, username, password, ssl = false) protocol = ssl ? 'https' : 'http' - self.class.base_uri "#{protocol}://#{company}.litmus.com" - self.class.basic_auth(username, password) + self.base_uri "#{protocol}://#{company}.litmus.com" + self.basic_auth(username, password) end end -end \ No newline at end of file +end diff --git a/spec/litmus_spec.rb b/spec/litmus_spec.rb index c4f5f5f..ff5b5fd 100644 --- a/spec/litmus_spec.rb +++ b/spec/litmus_spec.rb @@ -2,13 +2,13 @@ describe "Litmus" do - describe ".initialize" do + describe ".configure" do it "should use the appropriate protocol for the given account" do - test = Litmus::Base.new('host', 'user', 'password') - test.class.base_uri.should == 'http://host.litmus.com' - test_ssl = Litmus::Base.new('host', 'user', 'password', true) - test_ssl.class.base_uri.should == 'https://host.litmus.com' + Litmus::Base.configure('host', 'user', 'password') + Litmus::Base.base_uri.should == 'http://host.litmus.com' + Litmus::Base.configure('host', 'user', 'password', true) + Litmus::Base.base_uri.should == 'https://host.litmus.com' end end - + end From 517eb750aa3f73ea83a66b3bddbae79461a28381 Mon Sep 17 00:00:00 2001 From: Robert Graff Date: Tue, 4 Nov 2014 06:26:22 -0800 Subject: [PATCH 3/4] Add #retest and #update to report --- README.md | 33 +++++++++++++++--------- lib/litmus/result.rb | 15 ++++++++++- spec/fixtures/update_result.xml | 45 +++++++++++++++++++++++++++++++++ spec/result_spec.rb | 17 ++++++++++++- spec/spec_helper.rb | 7 +++-- 5 files changed, 99 insertions(+), 18 deletions(-) create mode 100644 spec/fixtures/update_result.xml diff --git a/README.md b/README.md index f615811..ea3280c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ Currently Implmented * Litmus::TestVersion.create(test_id) * Litmus::Result.list(test_id, test_version_id) * Litmus::Result.show(test_id, test_version_id, result_id) +* Litmus::Result.retest(test_id, test_version_id, result_id) +* Litmus::Result.update(test_id, test_version_id, result_id, new_state) Install ------- @@ -34,38 +36,45 @@ Example Usage # Setup the authentication details use_ssl = true # You must turn on SSL here if you have SSL enabled in Litmus - Litmus::Base.new("your_company_subdomain", "username", "password", use_ssl) - + Litmus::Base.configure("your_company_subdomain", "username", "password", use_ssl) + # Lets create an email test email_test = Litmus::EmailTest.create - send_test_to = email_test["test_set_versions"].first["url_or_guid"] #=> "f1b17db@emailtests.com" + send_test_to = email_test["test_set_versions"].first["url_or_guid"] #=> "f1b17db@emailtests.com" test_id = email_test["id"] #=> 1716534 version = email_test["test_set_versions"].first["version"] #=> 1 - + # If we query our new version we can see Litmus have not had the email yet Litmus::TestVersion.show(test_id, version)["received"] #=> false - + # Lets send them the email Pony.mail(:to => send_test_to, :from => 'mail@matthewfawcett.co.uk', :subject => 'hi', :body => 'Hello there, this is a test') # Alternatively, we could have included the email when the test was created alternative_test = Litmus::EmailTest.create({:subject => 'Hello', :body => 'Hello, world'}) - + # Now they have it Litmus::TestVersion.show(test_id, version)["received"] #=> "true" - + # Lets poll the results and look at the first client Litmus::TestVersion.poll(test_id, version)["results"].first.inspect #=> {"id"=>33539350, "test_code"=>"hotmail", "state"=>"pending"} - + # The hotmail test is still pending, lets wait for a while sleep 10 - + # Lets poll the results again and see that its complete Litmus::TestVersion.poll(test_id, version).first.inspect #=> {"id"=>33539350, "test_code"=>"hotmail", "state"=>"complete"} - - # Now lets show the result for this test version + + # Now let's show the result for this test version image_url = Litmus::Result.show(test_id, version, 33539350)["result_images"].first["full_image"] #=> "s3.amazonaws.com/resultcaptures/2f21fc9c-08f6-4429-b53d-2e224189526b.fullpageon.png" - + + # And we can retest the results + Litmus::Result.retest(test_id, version, 33539350) + # poll again until you have results + + # And update the the state to ticked + Litmust::Result.update(test_id, version, 33539350, :ticked) + # Let's rename this test to something more intuitive Litmus::Test.rename(test_id, 'My email test') diff --git a/lib/litmus/result.rb b/lib/litmus/result.rb index 5ecf498..d69f54a 100644 --- a/lib/litmus/result.rb +++ b/lib/litmus/result.rb @@ -7,5 +7,18 @@ def self.list(test_id, version_id) def self.show(test_id, version_id, id) get("/tests/#{test_id}/versions/#{version_id}/results/#{id}.xml")["result"] end + + def self.update(test_id, version_id, id, new_state) + builder = Builder::XmlMarkup.new + builder.instruct! :xml, :version=>"1.0" + builder.result do |result| + result.check_state new_state + end + put("/tests/#{test_id}/versions/#{version_id}/results/#{id}.xml")["result"] + end + + def self.retest(test_id, version_id, id) + post("/tests/#{test_id}/versions/#{version_id}/results/#{id}/retest.xml") + end end -end \ No newline at end of file +end diff --git a/spec/fixtures/update_result.xml b/spec/fixtures/update_result.xml new file mode 100644 index 0000000..9b12ee0 --- /dev/null +++ b/spec/fixtures/update_result.xml @@ -0,0 +1,45 @@ + + ticked + + 2010-12-18T22:44:51Z + 33524970 + 2010-12-18T22:44:13Z + ol2003 + complete + email + + + 165 + true + email + true + true + 0 + Windows + Microsoft Windows + ol2003 + Outlook 2003 + + + + full_off + s3.amazonaws.com/resultcaptures/path.png + s3.amazonaws.com/resultcaptures/path.png + + + full_on + s3.amazonaws.com/resultcaptures/path.png + s3.amazonaws.com/resultcaptures/path.png + + + window_off + s3.amazonaws.com/resultcaptures/path.png + s3.amazonaws.com/resultcaptures/path.png + + + window_on + s3.amazonaws.com/resultcaptures/path.png + s3.amazonaws.com/resultcaptures/path.png + + + diff --git a/spec/result_spec.rb b/spec/result_spec.rb index 36f685b..61b867f 100644 --- a/spec/result_spec.rb +++ b/spec/result_spec.rb @@ -16,4 +16,19 @@ result["result_images"].first["full_image"].should =~ /s3.amazonaws.com/ end end -end \ No newline at end of file + + describe ".retest" do + it "should return success" do + result = Litmus::Result.retest(1715760, 1, 33524970) + result.code.should == 201 + end + end + + describe ".update" do + it "should return a result object" do + result = Litmus::Result.update(1715760, 1, 33524970, :ticked) + result["id"].should == 33524970 + result["result_images"].first["full_image"].should =~ /s3.amazonaws.com/ + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 23ecd8d..3f59c4f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,19 +2,18 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'litmus' require 'rspec' -require 'rspec/autorun' require 'fakeweb' FakeWeb.allow_net_connect = false RSpec.configure do |config| - FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests.xml', + FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests.xml', :body => File.join(File.dirname(__FILE__), 'fixtures', 'all_tests.xml'), :content_type => "text/xml") - FakeWeb.register_uri(:post, 'http://matt:yourpassword@matthewfawcett.litmus.com/emails.xml', + FakeWeb.register_uri(:post, 'http://matt:yourpassword@matthewfawcett.litmus.com/emails.xml', :body => File.join(File.dirname(__FILE__), 'fixtures', 'create_email_test.xml'), :content_type => "text/xml") - FakeWeb.register_uri(:post, 'http://matt:yourpassword@matthewfawcett.litmus.com/pages.xml', + FakeWeb.register_uri(:post, 'http://matt:yourpassword@matthewfawcett.litmus.com/pages.xml', :body => File.join(File.dirname(__FILE__), 'fixtures', 'create_page_test.xml'), :content_type => "text/xml") FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests/1716450.xml', From 834de3ae57b63192ed555da1f9892e5228bab45c Mon Sep 17 00:00:00 2001 From: Robert Graff Date: Tue, 4 Nov 2014 06:26:51 -0800 Subject: [PATCH 4/4] Add #list, #create and #update to report --- README.md | 14 +++++++++++++ lib/litmus.rb | 3 ++- lib/litmus/report.rb | 20 +++++++++++++++++++ spec/fixtures/create_report.xml | 6 ++++++ spec/fixtures/list_reports.xml | 35 +++++++++++++++++++++++++++++++++ spec/fixtures/show_report.xml | 11 +++++++++++ spec/report_spec.rb | 26 ++++++++++++++++++++++++ spec/spec_helper.rb | 15 ++++++++++++++ 8 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 lib/litmus/report.rb create mode 100644 spec/fixtures/create_report.xml create mode 100644 spec/fixtures/list_reports.xml create mode 100644 spec/fixtures/show_report.xml create mode 100644 spec/report_spec.rb diff --git a/README.md b/README.md index ea3280c..e6579b3 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ Currently Implmented * Litmus::Result.show(test_id, test_version_id, result_id) * Litmus::Result.retest(test_id, test_version_id, result_id) * Litmus::Result.update(test_id, test_version_id, result_id, new_state) +* Litmus::Report.list +* Litmus::Report.create(new_name) +* Litmus::Report.show(id) Install ------- @@ -85,3 +88,14 @@ Example Usage # Looks good! Let's clean up... Litmus::Test.destroy(test_id) + + # Next, let's try a report of email views + report = Litmus::Report.create("Newsletter") + report_id = report["id"] + html_to_include_in_email = report["bug_html"] # bug as in listening device, I assume + + # Get the report later after the send + report = Litmus::Report.show(report_id) + + # View a list of last 1000 reports + reports = Litmus::Report.list diff --git a/lib/litmus.rb b/lib/litmus.rb index 42a84a2..607b1a2 100644 --- a/lib/litmus.rb +++ b/lib/litmus.rb @@ -6,6 +6,7 @@ require "litmus/page_test" require "litmus/test_version" require "litmus/result" +require "litmus/report" module Litmus -end \ No newline at end of file +end diff --git a/lib/litmus/report.rb b/lib/litmus/report.rb new file mode 100644 index 0000000..b2e5c68 --- /dev/null +++ b/lib/litmus/report.rb @@ -0,0 +1,20 @@ +module Litmus + class Report < Base + def self.list + get("/reports.xml")["reports"] + end + + def self.show(report_id) + get("/reports/#{report_id}.xml")["report"] + end + + def self.create(name) + builder = Builder::XmlMarkup.new + builder.instruct! :xml, :version=>"1.0" + builder.report do |report| + report.name name if name + end + post('/reports.xml', :body => builder.target!, :headers => {"Content-type" => "application/xml"})["report"] + end + end +end diff --git a/spec/fixtures/create_report.xml b/spec/fixtures/create_report.xml new file mode 100644 index 0000000..1552856 --- /dev/null +++ b/spec/fixtures/create_report.xml @@ -0,0 +1,6 @@ + + <style>@media print{#_t { background-image: url('https://a6.emltrk.com/3CDC7925?p');}} div.OutlookMessageHeader, table.moz-email-headers-table, blockquote #_t {background-image:url('https://a6.emltrk.com/3CDC7925?f')}</style><div id="_t"></div><img src="https://a6.emltrk.com/3CDC7925" width="1" height="1" border="0" /> + 2010-06-16T13:31:14Z + 24 + Newsletter + diff --git a/spec/fixtures/list_reports.xml b/spec/fixtures/list_reports.xml new file mode 100644 index 0000000..4ee27b8 --- /dev/null +++ b/spec/fixtures/list_reports.xml @@ -0,0 +1,35 @@ + + + <style>@media print{#_t { background-image: url('https://a6.emltrk.com/E95EEB71?p');}} div.OutlookMessageHeader, table.moz-email-headers-table, blockquote #_t {background-image:url('https://a6.emltrk.com/E95EEB71?f')}</style><div id="_t"></div><img src="https://a6.emltrk.com/E95EEB71" width="1" height="1" border="0" /> + 2010-06-16T12:24:09Z + 24 + Test report + false + + http://export.litmus.com/mailclientusage.aspx/ABC123 + http://export.litmus.com/mailclientengagement.aspx/ABC456 + http://export.litmus.com/activity.aspx/ABC789 + + + <style>@media print{#_t { background-image: url('https://a6.emltrk.com/E95EEB71?p');}} div.OutlookMessageHeader, table.moz-email-headers-table, blockquote #_t {background-image:url('https://a6.emltrk.com/E95EEB71?f')}</style><div id="_t"></div><img src="https://a6.emltrk.com/E95EEB71" width="1" height="1" border="0" /> + 2010-06-16T12:24:09Z + 25 + Test report + false + + http://export.litmus.com/mailclientusage.aspx/ABC123 + http://export.litmus.com/mailclientengagement.aspx/ABC456 + http://export.litmus.com/activity.aspx/ABC789 + + + <style>@media print{#_t { background-image: url('https://a6.emltrk.com/E95EEB71?p');}} div.OutlookMessageHeader, table.moz-email-headers-table, blockquote #_t {background-image:url('https://a6.emltrk.com/E95EEB71?f')}</style><div id="_t"></div><img src="https://a6.emltrk.com/E95EEB71" width="1" height="1" border="0" /> + 2010-06-16T12:24:09Z + 26 + Test report + false + + http://export.litmus.com/mailclientusage.aspx/ABC123 + http://export.litmus.com/mailclientengagement.aspx/ABC456 + http://export.litmus.com/activity.aspx/ABC789 + + diff --git a/spec/fixtures/show_report.xml b/spec/fixtures/show_report.xml new file mode 100644 index 0000000..b3bb4b3 --- /dev/null +++ b/spec/fixtures/show_report.xml @@ -0,0 +1,11 @@ + + <style>@media print{#_t { background-image: url('https://a6.emltrk.com/E95EEB71?p');}} div.OutlookMessageHeader, table.moz-email-headers-table, blockquote #_t {background-image:url('https://a6.emltrk.com/E95EEB71?f')}</style><div id="_t"></div><img src="https://a6.emltrk.com/E95EEB71" width="1" height="1" border="0" /> + 2010-06-16T12:24:09Z + 24 + Test - Yahoo test + false + + http://export.litmus.com/mailclientusage.aspx/ABC123 + http://export.litmus.com/mailclientengagement.aspx/ABC456 + http://export.litmus.com/activity.aspx/ABC789 + diff --git a/spec/report_spec.rb b/spec/report_spec.rb new file mode 100644 index 0000000..3002721 --- /dev/null +++ b/spec/report_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Litmus::Result do + describe ".list" do + it "should give me an array of results" do + results = Litmus::Report.list + results.count.should == 3 + results.first["id"].should == 24 + end + end + + describe ".show" do + it "should return a result object" do + result = Litmus::Report.show(24) + result["id"].should == 24 + end + end + + describe ".create" do + it "should return success" do + result = Litmus::Report.create("Newsletter") + result["id"].should == 24 + result["report_name"].should == 'Newsletter' + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3f59c4f..0e04866 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,6 +42,21 @@ FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests/1715760/versions/1/results/33524970.xml', :body => File.join(File.dirname(__FILE__), 'fixtures', 'show_result.xml'), :content_type => "text/xml") + FakeWeb.register_uri(:post, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests/1715760/versions/1/results/33524970/retest.xml', + :status => [201, 'Created'],:content_type => "text/xml") + FakeWeb.register_uri(:put, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests/1715760/versions/1/results/33524970.xml', + :body => File.join(File.dirname(__FILE__), 'fixtures', 'update_result.xml'), + :content_type => "text/xml") + FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/reports.xml', + :body => File.join(File.dirname(__FILE__), 'fixtures', 'list_reports.xml'), + :content_type => "text/xml") + FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/reports/24.xml', + :body => File.join(File.dirname(__FILE__), 'fixtures', 'show_report.xml'), + :content_type => "text/xml") + FakeWeb.register_uri(:post, 'http://matt:yourpassword@matthewfawcett.litmus.com/reports.xml', + :body => File.join(File.dirname(__FILE__), 'fixtures', 'create_report.xml'), + :content_type => "text/xml") + config.before(:each) do Litmus::Base.new("matthewfawcett", "matt", "yourpassword") end