spec/readability/client_spec.rb in readability_parser-0.0.2 vs spec/readability/client_spec.rb in readability_parser-0.0.3

- old
+ new

@@ -1,32 +1,63 @@ require 'helper' -describe Readability::Client do +describe ReadabilityParser::Client do after do - Readability.reset + ReadabilityParser.reset! end - context "when creating a client" do - describe "with no options" do - it "should assign client with default values" do - pending + context "with module configuration" do + before do + ReadabilityParser.configure do |config| + ReadabilityParser::Configuration::VALID_CONFIG_KEYS.each do |key| + config.send("#{key}=", key) + end end end - describe "with options" do + it "inherits the module configuration" do + ReadabilityParser::Configuration::VALID_CONFIG_KEYS.each do |key| + expect(ReadabilityParser.send(:"#{key}")).to eq(key) + end + end + end - it "should accept configuration options" do - pending + context "with class configuration" do + before do + @configuration = { + api_token: '1234', + format: :sriracha + } + end + + it "overrides the module configuration after initialization" do + ReadabilityParser.configure do |config| + @configuration.each do |key, value| + config.send("#{key}=", value) + end end - it "should assign the client with overiden default values" do - pending + ReadabilityParser::Configuration::VALID_OPTIONS_KEYS.each do |key| + expect(ReadabilityParser.send(:"#{key}")).to eq(@configuration[key]) end end end - context "when using a client" do - pending + describe "#connection" do + it "looks like Faraday connection" do + expect(subject.send(:connection)).to respond_to(:run_request) + end end + describe "#request" do + before { ReadabilityParser.api_token = '1234' } + + it "catches Faraday connection errors" do + pending + end + + it "catches Readability Parser API errors" do + pending + end + end end