dilbert 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
@@ -0,0 +1,4 @@
1
+ require "dilbert"
2
+
3
+ console = Dilbert::Console.new($stdout, Dilbert::DilbertService.new)
4
+ console.run(ARGV)
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
23
24
  end
@@ -1,5 +1,19 @@
1
1
  require "dilbert/version"
2
+ require "dilbert/dilbert_service"
2
3
 
3
4
  module Dilbert
4
- # Your code goes here...
5
+
6
+ class Console
7
+
8
+ def initialize(printer, dilbert_service)
9
+ @printer = printer
10
+ @dilbert_service = dilbert_service
11
+ end
12
+
13
+ def run(*args)
14
+ @printer.puts @dilbert_service.fetch_latest
15
+ end
16
+
17
+ end
18
+
5
19
  end
@@ -0,0 +1,11 @@
1
+ module Dilbert
2
+ class DilbertService
3
+ def fetch_latest
4
+ "http://www.dilbert.com#{curl_command.chomp}"
5
+ end
6
+
7
+ def curl_command
8
+ `curl http://dilbert.com/fast | grep img | cut -d'"' -f2 | tail -n1`
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Dilbert
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,18 @@
1
+ module Dilbert
2
+ describe Console do
3
+ subject { Console.new(printer, dilbert_service) }
4
+ let(:printer) { double(puts: true) }
5
+ let(:dilbert_service) { double }
6
+
7
+ describe "#run" do
8
+ let(:url_to_comic) { 'http://dilbert.com/blah.jpg' }
9
+ let(:argv) { [] }
10
+
11
+ it "fetches the latest dilbert comic" do
12
+ dilbert_service.stub(:fetch_latest).and_return(url_to_comic)
13
+ subject.run(argv)
14
+ expect(printer).to have_received(:puts).with(url_to_comic)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Dilbert
2
+ describe DilbertService do
3
+ subject { DilbertService.new }
4
+
5
+ describe "#fetch_latest" do
6
+ let(:returned_image_url) { "/dyn/str_strip/000000000/00000000/0000000/200000/20000/6000/000/226097/226097.strip.print.gif\n" }
7
+
8
+ it "fetches the url to the latest dilbert comic" do
9
+ subject.stub(:curl_command).and_return(returned_image_url)
10
+ expect(subject.fetch_latest).to eql("http://www.dilbert.com#{returned_image_url}".chomp)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,78 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ require "dilbert"
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ =begin
21
+ # These two settings work together to allow you to limit a spec run
22
+ # to individual examples or groups you care about by tagging them with
23
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
+ # get run.
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+
28
+ # Many RSpec users commonly either run the entire suite or an individual
29
+ # file, and it's useful to allow more verbose output when running an
30
+ # individual spec file.
31
+ if config.files_to_run.one?
32
+ # Use the documentation formatter for detailed output,
33
+ # unless a formatter has already been configured
34
+ # (e.g. via a command-line flag).
35
+ config.default_formatter = 'doc'
36
+ end
37
+
38
+ # Print the 10 slowest examples and example groups at the
39
+ # end of the spec run, to help surface which specs are running
40
+ # particularly slow.
41
+ config.profile_examples = 10
42
+
43
+ # Run specs in random order to surface order dependencies. If you find an
44
+ # order dependency and want to debug it, you can fix the order by providing
45
+ # the seed, which is printed after each run.
46
+ # --seed 1234
47
+ config.order = :random
48
+
49
+ # Seed global randomization in this process using the `--seed` CLI option.
50
+ # Setting this allows you to use `--seed` to deterministically reproduce
51
+ # test failures related to randomization by passing the same `--seed` value
52
+ # as the one that triggered the failure.
53
+ Kernel.srand config.seed
54
+
55
+ # rspec-expectations config goes here. You can use an alternate
56
+ # assertion/expectation library such as wrong or the stdlib/minitest
57
+ # assertions if you prefer.
58
+ config.expect_with :rspec do |expectations|
59
+ # Enable only the newer, non-monkey-patching expect syntax.
60
+ # For more details, see:
61
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
62
+ expectations.syntax = :expect
63
+ end
64
+
65
+ # rspec-mocks config goes here. You can use an alternate test double
66
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
67
+ config.mock_with :rspec do |mocks|
68
+ # Enable only the newer, non-monkey-patching expect syntax.
69
+ # For more details, see:
70
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
+ mocks.syntax = :expect
72
+
73
+ # Prevents you from mocking or stubbing a method that does not exist on
74
+ # a real object. This is generally recommended.
75
+ mocks.verify_partial_doubles = true
76
+ end
77
+ =end
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dilbert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,21 +43,44 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  description: Retrieve today's Dilbert comic strip from dilbert.com'
47
63
  email:
48
64
  - s@stephenpeasley.com
49
- executables: []
65
+ executables:
66
+ - dilbert
50
67
  extensions: []
51
68
  extra_rdoc_files: []
52
69
  files:
53
70
  - .gitignore
71
+ - .rspec
54
72
  - Gemfile
55
73
  - LICENSE.txt
56
74
  - README.md
57
75
  - Rakefile
76
+ - bin/dilbert
58
77
  - dilbert.gemspec
59
78
  - lib/dilbert.rb
79
+ - lib/dilbert/dilbert_service.rb
60
80
  - lib/dilbert/version.rb
81
+ - spec/lib/console_spec.rb
82
+ - spec/lib/dilbert_service_spec.rb
83
+ - spec/spec_helper.rb
61
84
  homepage: https://github.com/speasley/dilbert
62
85
  licenses:
63
86
  - MIT
@@ -73,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
96
  version: '0'
74
97
  segments:
75
98
  - 0
76
- hash: -1193172608817564734
99
+ hash: -387335161863302750
77
100
  required_rubygems_version: !ruby/object:Gem::Requirement
78
101
  none: false
79
102
  requirements:
@@ -82,11 +105,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
105
  version: '0'
83
106
  segments:
84
107
  - 0
85
- hash: -1193172608817564734
108
+ hash: -387335161863302750
86
109
  requirements: []
87
110
  rubyforge_project:
88
111
  rubygems_version: 1.8.23
89
112
  signing_key:
90
113
  specification_version: 3
91
114
  summary: Your dose of daily Dilbert
92
- test_files: []
115
+ test_files:
116
+ - spec/lib/console_spec.rb
117
+ - spec/lib/dilbert_service_spec.rb
118
+ - spec/spec_helper.rb