spec/plurky/client_spec.rb in plurky-0.1.1 vs spec/plurky/client_spec.rb in plurky-0.1.2
- old
+ new
@@ -8,11 +8,11 @@
:oauth_token => 'OT',
:oauth_token_secret => 'OTS'
}
end
- subject { Plurky::Client.new(configuration) }
+ subject(:client) { Plurky::Client.new(configuration) }
context "with module configuration" do
before do
Plurky.configure do |config|
configuration.each do |key, value|
@@ -24,79 +24,80 @@
after do
Plurky.reset!
end
it "inherits the module configuration" do
- client = Plurky.client
+ cached_client = Plurky.client
configuration.each do |key, value|
- client.instance_variable_get(:"@#{key}").should == value
+ expect(cached_client.instance_variable_get(:"@#{key}")).to eq value
end
end
context "with class configuration" do
let(:different_configuration) { configuration.update :oauth_token_secret => 'OS' }
it "overrides the module configuration" do
- client = Plurky::Client.new(different_configuration)
+ different_client = Plurky::Client.new(different_configuration)
different_configuration.each do |key, value|
- client.instance_variable_get(:"@#{key}").should == value
+ expect(different_client.instance_variable_get(:"@#{key}")).to eq value
end
end
end
end
describe "#credentials?" do
it "returns true if all credentials are present" do
- client = Plurky::Client.new(configuration)
- client.credentials?.should be_true
+ client_with_all_credentials = Plurky::Client.new(configuration)
+ expect(client_with_all_credentials.credentials?).to be_true
end
it "returns false if any credentials are missing" do
- client = Plurky::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT')
- client.credentials?.should be_false
+ client_with_missing_credentials =
+ Plurky::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT')
+ expect(client_with_missing_credentials.credentials?).to be_false
end
end
describe "#get" do
let(:path) { '/APP/Profile/getPublicProfile' }
let(:params) { { :user => 34 } }
it "knows how to make get request" do
- subject.should_receive(:request).with(:get, path, params)
- subject.get path, params
+ expect(client).to receive(:request).with(:get, path, params)
+ client.get path, params
end
end
describe "#post" do
let(:path) { '/APP/Timeline/uploadPicture' }
let(:params) { { :image => "" } }
it "knows how to make post request" do
- subject.should_receive(:request).with(:post, path, params)
- subject.post path, params
+ expect(client).to receive(:request).with(:post, path, params)
+ client.post path, params
end
end
describe "#connection" do
it "looks like Faraday connection" do
- subject.send(:connection).should respond_to(:run_request)
+ expect(client.send(:connection)).to respond_to(:run_request)
end
end
describe "#request" do
end
describe "#auth_header" do
it "creates the correct auth headers" do
uri = URI("http://www.plurk.com/APP/Profile/getPublicProfile")
- authorization = subject.send(:auth_header, :get, uri, { :user_id => 34 })
- authorization.options[:signature_method].should == "HMAC-SHA1"
- authorization.options[:version].should == "1.0"
- authorization.options[:consumer_key].should == "CK"
- authorization.options[:consumer_secret].should == "CS"
- authorization.options[:token].should == "OT"
- authorization.options[:token_secret].should == "OTS"
+ authorization = client.send(:auth_header, :get, uri, { :user_id => 34 })
+ expect(authorization.options[:signature_method]).to eq "HMAC-SHA1"
+ expect(authorization.options[:version]).to eq "1.0"
+ expect(authorization.options[:consumer_key]).to eq "CK"
+ expect(authorization.options[:consumer_secret]).to eq "CS"
+ expect(authorization.options[:token]).to eq "OT"
+ expect(authorization.options[:token_secret]).to eq "OTS"
end
end
end